binutils-gdb/ld/testsuite/ld-s390/weakundef-2.dd
Jens Remus 6f8b365b65 s390: Avoid reloc overflows on undefined weak symbols (cont)
This complements and reuses logic from Andreas Krebbel's commit
896a639bab ("s390: Avoid reloc overflows on undefined weak symbols").

Replace relative long addressing instructions of weak symbols, which
will definitely resolve to zero, with either a load address of 0 or a
a trapping insn.

This prevents the PLT32DBL relocation from overflowing in case the
binary will be loaded at 4GB or more.

bfd/
	* elf64-s390.c (elf_s390_relocate_section): Replace
	instructions using undefined weak symbols with relative
	addressing to avoid relocation overflows.

ld/
	* testsuite/ld-s390/s390.exp: Add new test.
	* testsuite/ld-s390/weakundef-2.s: New test.
	* testsuite/ld-s390/weakundef-2.dd: Likewise.

Reported-by: Alexander Gordeev <agordeev@linux.ibm.com>
Suggested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Suggested-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-07-12 16:53:47 +02:00

18 lines
457 B
Plaintext

tmpdir/weakundef-2: file format elf64-s390
Disassembly of section .text:
0+200000000 <foo>:
.*: c0 10 00 00 00 12 [ ]*larl %r1,200000024 <d>
.*: c0 10 00 00 00 10 [ ]*larl %r1,200000026 <wd>
.*: e3 10 00 00 00 71 [ ]*lay %r1,0
.*: c0 e5 00 00 00 09 [ ]*brasl %r14,200000024 <d>
.*: c0 e5 00 00 00 07 [ ]*brasl %r14,200000026 <wd>
.*: c0 f4 00 00 00 01 [ ]*jg .*
0+200000024 <d>:
.*: 07 fe [ ]*br %r14
0+200000026 <wd>:
.*: 07 fe [ ]*br %r14