[Bug ld/30787] New: DT_JMPREL/DT_PLTRELSZ incorrect when PLT and REL/RELA relocations share an ELF output section

2023-08-22 Thread peadar at arista dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30787

Bug ID: 30787
   Summary: DT_JMPREL/DT_PLTRELSZ incorrect when PLT and REL/RELA
relocations share an ELF output section
   Product: binutils
   Version: 2.42 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: peadar at arista dot com
  Target Milestone: ---

Created attachment 15080
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15080&action=edit
Reproduce problem

By default, PLT and standard REL/RELA relocations end up in .rel[a].plt and
.rel[a].dyn

However, there's no requirement that the different relocations will be output
in separate ELF sections, as far as I can gather.

The output of these fields currently just emits the VMA of the output section
and the size of that output section for DT_JMPREL and DT_PLTRELSZ dynamic
entries. In the case that there are other relocations in the section, this
means that some relocations can be processed multiple times.

For x86_64, this looks like it's generally idempotent, but on i686, we can get
double-processing of R_386_RELATIVE relocations, which use the previous
resolution as the offset for the second one. 

This seems to be a regression introduced by
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9577f60b5a1 

Easy repro in attached repro.tar.gz, suggested fix in patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30787] DT_JMPREL/DT_PLTRELSZ incorrect when PLT and REL/RELA relocations share an ELF output section

2023-08-22 Thread peadar at arista dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30787

--- Comment #1 from Peter Edwards  ---
Created attachment 15081
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15081&action=edit
Suggested fix

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30787] DT_JMPREL/DT_PLTRELSZ incorrect when PLT and REL/RELA relocations share an ELF output section

2023-08-23 Thread peadar at arista dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30787

--- Comment #4 from Peter Edwards  ---
Thanks for the fast turn-around!

-- 
You are receiving this mail because:
You are on the CC list for the bug.