[PATCH] s390: Rewrite emitted relocations when rewriting instructions

Jens Remus jremus@linux.ibm.com
Wed Oct 15 16:02:39 GMT 2025


On 10/13/2025 1:27 PM, Andreas Krebbel wrote:
> On 10/1/25 3:28 PM, Jens Remus wrote:
>> bfd/
>>     * elf64-s390.c (elf_s390_relocate_section): Rewrite emitted
>>     relocations when rewriting instructions.
>>     * elf32-s390.c (elf_s390_relocate_section): Likewise.
>>
>> ld/testsuite/
>>     * ld-s390/s390.exp: Link gotreloc* and weakundef* tests with
>>     option --emit-relocs.
>>     * ld-s390/gotreloc_31-1.dd: Expect rewritten instructions to be
>>     accompanied by a PC32DBL or NONE relocation respectively.
>>     * ld-s390/gotreloc_31-no-pie-1.dd: Likewise.
>>     * ld-s390/gotreloc_64-no-pie-1.dd: Likewise.
>>     * ld-s390/gotreloc_64-norelro-1.dd: Likewise.
>>     * ld-s390/gotreloc_64-relro-1.dd: Likewise.
>>     * ld-s390/weakundef-1.dd: Likewise.
>>     * ld-s390/weakundef-2.dd: Likewise.
> 
> Good catch. Ok, thanks for fixing this!

Thank you!  Sorry for the hassle, but I just sent a v2 with a slightly
reworded commit message.  Following is the git range-diff v1 against v2:

1:  07f5884c4146 ! 1:  3a6b19c0bf8e s390: Rewrite emitted relocations when rewriting instructions
    @@ Commit message
         - GOT access using lgrl to larl, changing the GOTENT to a PC32DBL reloc
         - GOT access using lg to larl, changing the GOT20 to a PC32DBL reloc
         - Relative long addressing instructions of weak symbols, which
    -      definitively resolve to zero to either (1) load address of zero,
    +      definitively resolve to zero, to either (1) load address of zero,
           (2) a NOP, or (3) a trapping instruction.

         In case of a rewrite of GOT access using lgrl/lg to larl emit the
    @@ Commit message
         the gotreloc* and weakundef* tests to check for the respective
         relocations.

    +    This aligns with how GNU linker behaves on x86-64, when rewriting
    +    instructions/relocations in elf_x86_64_convert_load_reloc().
    +
         bfd/
                 * elf64-s390.c (elf_s390_relocate_section): Rewrite emitted
                 relocations when rewriting instructions.

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