public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [SPARC] Skip IFUNC relocations in debug section
@ 2020-08-30 12:34 Mikael Pettersson
  2020-09-17  9:51 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Pettersson @ 2020-08-30 12:34 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

Skip IFUNC relocations in debug sections ignored by ld.so.
Fixes the following ld test failures on sparc-linux-gnu:

FAIL: Build libpr18808.so
FAIL: Build libpr18808n.so
FAIL: Run pr18808
FAIL: Run pr18808 (-z now)

due to "aborting at bfd/elfxx-sparc.c:2906 in _bfd_sparc_elf_relocate_section".

Based on a similar fix made previously for AArch64.

bfd/
        PR ld/18808
        * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Skip IFUNC
        relocations in debug sections, change abort to _bfd_error_handler.
---
 bfd/elfxx-sparc.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 273789e5f7..be82612aef 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -2904,7 +2904,25 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
                 STT_GNU_IFUNC symbol as STT_FUNC.  */
              if (elf_section_type (input_section) == SHT_NOTE)
                goto skip_ifunc;
-             abort ();
+
+             /* Dynamic relocs are not propagated for SEC_DEBUGGING
+                sections because such sections are not SEC_ALLOC and
+                thus ld.so will not process them.  */
+             if ((input_section->flags & SEC_ALLOC) == 0
+                 && (input_section->flags & SEC_DEBUGGING) != 0)
+               continue;
+
+             _bfd_error_handler
+               /* xgettext:c-format */
+               (_("%pB(%pA+%#" PRIx64 "): "
+                  "unresolvable %s relocation against symbol `%s'"),
+                input_bfd,
+                input_section,
+                (uint64_t) rel->r_offset,
+                howto->name,
+                h->root.root.string);
+             bfd_set_error (bfd_error_bad_value);
+             return FALSE;
            }

          plt_sec = htab->elf.splt;
-- 
2.25.4

[-- Attachment #2: 0001-SPARC-Skip-IFUNC-relocations-in-debug-section.patch --]
[-- Type: text/x-patch, Size: 1826 bytes --]

From 7a935489a87ba2c16826e2daa2b0b528772ee6b9 Mon Sep 17 00:00:00 2001
From: Mikael Pettersson <mikpelinux@gmail.com>
Date: Sat, 29 Aug 2020 21:17:10 +0200
Subject: [PATCH] [SPARC] Skip IFUNC relocations in debug section

Skip IFUNC relocations in debug sections ignored by ld.so.
Fixes the following ld test failures on sparc-linux-gnu:

FAIL: Build libpr18808.so
FAIL: Build libpr18808n.so
FAIL: Run pr18808
FAIL: Run pr18808 (-z now)

due to "aborting at bfd/elfxx-sparc.c:2906 in _bfd_sparc_elf_relocate_section".

Based on a similar fix made previously for AArch64.

bfd/
	PR ld/18808
	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Skip IFUNC
	relocations in debug sections, change abort to _bfd_error_handler.
---
 bfd/elfxx-sparc.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 273789e5f7..be82612aef 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -2904,7 +2904,25 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
 	         STT_GNU_IFUNC symbol as STT_FUNC.  */
 	      if (elf_section_type (input_section) == SHT_NOTE)
 		goto skip_ifunc;
-	      abort ();
+
+	      /* Dynamic relocs are not propagated for SEC_DEBUGGING
+		 sections because such sections are not SEC_ALLOC and
+		 thus ld.so will not process them.  */
+	      if ((input_section->flags & SEC_ALLOC) == 0
+		  && (input_section->flags & SEC_DEBUGGING) != 0)
+		continue;
+
+	      _bfd_error_handler
+		/* xgettext:c-format */
+		(_("%pB(%pA+%#" PRIx64 "): "
+		   "unresolvable %s relocation against symbol `%s'"),
+		 input_bfd,
+		 input_section,
+		 (uint64_t) rel->r_offset,
+		 howto->name,
+		 h->root.root.string);
+	      bfd_set_error (bfd_error_bad_value);
+	      return FALSE;
 	    }
 
 	  plt_sec = htab->elf.splt;
-- 
2.25.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] [SPARC] Skip IFUNC relocations in debug section
  2020-08-30 12:34 [PATCH] [SPARC] Skip IFUNC relocations in debug section Mikael Pettersson
@ 2020-09-17  9:51 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2020-09-17  9:51 UTC (permalink / raw)
  To: Mikael Pettersson, binutils

Hi Mikael,

> bfd/
>         PR ld/18808
>         * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Skip IFUNC
>         relocations in debug sections, change abort to _bfd_error_handler.

Approved and applied.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-17  9:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-30 12:34 [PATCH] [SPARC] Skip IFUNC relocations in debug section Mikael Pettersson
2020-09-17  9:51 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).