This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Re: Don't relax undefined symbols on ppc.




On 07/09/2018 06:27 PM, Alan Modra wrote:
On Mon, Jul 09, 2018 at 01:58:33PM -0700, Douglas B Rupp wrote:
There is a problem with --relax in the partial link trying to relax the
undefined symbols, leading to the RTP failing at startup with signal 11.

Please describe the problem in detail.  ld -r --relax non-pic is
supposed to work for ppc32, with a branch to an undefined symbol being
resolved to a trampoline which has relocations to the symbol.  Are the
emitted relocations wrong?

I solicit comments on the attached patch, which causes undefined symbols to
be ignored during the relax process.  Leaving them to be relaxed and
resolved during the final link.

If ld -r mashes together sections such that the resulting output
section size exceeds the reach of a branch, then it may not be
possible to for branches to reach trampolines placed at the end of the
section.  That's the problem ld -r --relax is trying to solve, by
placing trampolines at the end of each input section.


The problem is that "tsec" is the undefined section and basically a no-op in the following line, so existing trampolines are found when they shouldn't be found.

elf32-ppc.c: if (f->tsec == tsec && f->toff == toff)

The attached patch fixes it.
I don't have write privs.

--Doug

Attachment: ChangeLog.Entry
Description: Text document

diff --git bfd/elf32-ppc.c bfd/elf32-ppc.c
index 5e9251b..ee785bd 100644
--- bfd/elf32-ppc.c
+++ bfd/elf32-ppc.c
@@ -7251,6 +7251,9 @@ ppc_elf_relax_section (bfd *abfd,
   struct one_branch_fixup
   {
     struct one_branch_fixup *next;
+    /* For undefined symbols in partial linking operations, tsec will always
+       be the undefined section and not sufficient to differentiate.  */
+    bfd *abfd;
     asection *tsec;
     /* Final link, can use the symbol offset.  For a
        relocatable link we use the symbol's index.  */
@@ -7599,7 +7602,7 @@ ppc_elf_relax_section (bfd *abfd,
 
 	  /* Look for an existing fixup to this address.  */
 	  for (f = branch_fixups; f ; f = f->next)
-	    if (f->tsec == tsec && f->toff == toff)
+	    if (f->abfd == abfd && f->tsec == tsec && f->toff == toff)
 	      break;
 
 	  if (f == NULL)
@@ -7644,6 +7647,7 @@ ppc_elf_relax_section (bfd *abfd,
 	      /* Record the fixup so we don't do it again this section.  */
 	      f = bfd_malloc (sizeof (*f));
 	      f->next = branch_fixups;
+	      f->abfd = abfd;
 	      f->tsec = tsec;
 	      f->toff = toff;
 	      f->trampoff = trampoff;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]