[PATCH] s390: Bind defined symbol locally in PIE

Jens Remus jremus@linux.ibm.com
Fri Nov 7 16:36:51 GMT 2025


On 11/6/2025 3:07 PM, Andreas Krebbel wrote:
> On 11/4/25 2:23 PM, Jens Remus wrote:
>> Symbols defined in PIE should be bound locally, the same as -shared
>> -Bsymbolic.
>>
>> Port x86 commit 4e0c91e45402 ("Bind defined symbol locally in PIE")
>> change of relocate_section as well as linker tests to s390.  Similar as
>> done for other architectures with the following commits:
>> - AArch64: ac33b731d214 ("[AArch64] Bind defined symbol locally in PIE")
>> - ARM: 1dcb9720d62c ("[ARM] Bind defined symbol locally in PIE")
>> - RISC-V: 39c7793ba8be ("RISC-V: Bind defined symbol locally in PIE")
>> - x86: 4e0c91e45402 ("Bind defined symbol locally in PIE")
>> With this change symbols defined in an executable (i.e. PDE or PIE) are
>> bound locally, as they cannot be interposed.  In the same way as symbols
>> defined in a shared library linked with -Bsymbolic are bound locally.
>>
>> This also ensures that all defined symbols are bound locally in
>> static PIE.
>>
>> Do not port the x86 change of check_relocs (now scan_relocs).  None of
>> the linker tests where the change in condition triggers (e.g. bootstrap,
>> cdtest) produce different readelf -Wa output.  The change appears to
>> affect accounting of space required for dynamic relocations.  Instead of
>> accounting them in check_relocs and later filtering them away in
>> allocate_dynrelocs, they would not get accounted in the first place:
>> The change in the expression would only have an effect if the following
>> conditions are all met in addition to PIE:  ALLOC, PC-relative
>> relocation, global symbol, not defined weak, and defined regular.  In
>> this specific case the accounting of the PC relative relocation in
>> h->dyn_relocs would be skipped for PIE.  But allocate_dynrelocs later
>> eliminates any PC-relative dynamic relocations if PIC (= PIE or shared
>> library) and SYMBOL_CALLS_LOCAL.
>>
>> bfd/
>>     PR ld/33141
>>     * elf64-s390.c (elf_s390_relocate_section): Bind defined symbol
>>     locally in PIE.
>>
>> ld/testsuite/
>>     PR ld/33141
>>     * ld-s390/s390.exp: Add pr33141 tests.
>>     * ld-s390/pr33141.rd: New file.
>>     * ld-s390/pr33141a.s: Likewise.
>>     * ld-s390/pr33141b.s: Likewise.
>>
>> Signed-off-by: Jens Remus <jremus@linux.ibm.com>
> 
> Ok. Thanks!

Thank you for the review!  Committed to mainline.

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