Skip to contentSkip to conversation

or1k: Fix incorrect value in PLT GOT entries, causing infinite loop

PATCH New Stafford Horne 2 participants 3 messages Aug 22, 2019 – Aug 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 or1k: Fix incorrect value in PLT GOT entries, causing infinite loop

The PLT GOT entry should point to the first PLT entry which contains the runtime linker function. It was pointing back to the symbol PLT entry causing an infinite loop.

I found this when testing the OpenRISC glibc port which uses the runtime dynamic linker. It seems other libc's we use so far have not been making use of the initial PLT GOT entries.

bfd/ChangeLog:

* elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Use correct value for PLT GOT entries.

---
 bfd/elf32-or1k.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
bfd/elf32-or1k.c +5 -2
index c1bbac98fb..cb7c0da5fd 100644
@@ -2377,8 +2377,11 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
       or1k_write_plt_entry (output_bfd, splt->contents + h->plt.offset,
 			    plt0, plt1, plt2, OR1K_JR(12));
 
-      /* Fill in the entry in the global offset table.  */
-      bfd_put_32 (output_bfd, plt_addr, sgot->contents + got_offset);
+      /* Fill in the entry in the global offset table.  We initialize it to
+	 point to the top of the plt.  This is done to lazy lookup the actual
+	 symbol as the first plt entry will be setup by libc to call the
+	 runtime dynamic linker.  */
+      bfd_put_32 (output_bfd, plt_base_addr, sgot->contents + got_offset);
 
       /* Fill in the entry in the .rela.plt section.  */
       rela.r_offset = got_addr;
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 or1k: Fix incorrect value in PLT GOT entries, causing infinite loop

Hi Stafford,

Quoted 4 lines

bfd/ChangeLog:

* elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Use correct value for PLT GOT entries.

Approved - please apply.

Cheers
Nick

#2 lore raw

PATCH 1/1 or1k: Fix incorrect value in PLT GOT entries, causing infinite loop

Quoted 8 lines · Nick Clifton

Hi Stafford,

Quoted 4 lines

bfd/ChangeLog:

* elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Use correct value for PLT GOT entries.

Approved - please apply.

Done now.

Thanks,

-Stafford