Questions about ld h->pointer_equality_needed on x86-64
Jens Remus
jremus@linux.ibm.com
Thu Mar 27 11:47:13 GMT 2025
I am working on fixing Binutils PR ld/29655 ("s390x gas generates
PC32DBL instead of PLT32DBL for function call") [1]. Part of that is
to port logic from x86-64 revolving around h->pointer_equality_needed
to s390x.
IIUC and (over)simplified scan_relocs sets h->pointer_equality_needed
on x86-64 [2] in case of the following relocation types. Presumably
the intention is that these are assumed to be used in address taking
context, requiring pointer equality, whereas e.g. R_X86_64_PLT32
would be assumed to be used in function call context, which does
not require pointer equality.
- R_X86_64_8
- R_X86_64_16
- R_X86_64_32
- R_X86_64_32S
- R_X86_64_64, iff in SEC_READONLY
- R_X86_64_PC8
- R_X86_64_PC16
- R_X86_64_PC32, iff not in SEC_CODE
Why are/were R_X86_64_PC64 and previously also R_X86_64_PC32 explicitly
excluded? I could not find any explanation in the Git history.
See:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=47a9f7b34f7a3
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=d6ab8113e328
Wouldn't lea with R_X86_64_PC32 instead of movl with R_X86_64_32S also
be valid? Then restricting R_X86_64_PC32 to non-SEC_CODE would be wrong.
For example:
lea shlib_shlibvar1(%rip), %edi
instead of:
movl $shlib_shlibvar1, %edi
Why are R_X86_64_8, R_X86_64_16, R_X86_64_32 included? How are
addresses of functions taken using these? Or is that a simplification
that it does not hurt to have h->pointer_equality_needed set for these?
[1]: s390x gas generates PC32DBL instead of PLT32DBL for function call,
https://sourceware.org/bugzilla/show_bug.cgi?id=29655
[2]: Binutils, bfd/elf64-x86-64.c, scan_relocs(),
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf64-x86-64.c;h=1e08f2e7125424f6409bcfdaabcda8761e4f558a;hb=refs/heads/master#l2869
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the Binutils
mailing list