int tls_type;
asection *base_got = htab->elf.sgot;
bool resolved_to_zero;
+ bool relax;
r_type = ELF32_R_TYPE (rel->r_info);
if (r_type == (int) R_390_GNU_VTINHERIT
resolved_to_zero = (h != NULL
&& UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+ /* Rewrite instructions and related relocations if (1) relaxation
+ disabled by default, (2) enabled by target, or (3) enabled by
+ user. Suppress rewriting if linker option --no-relax is used. */
+ relax = info->disable_target_specific_optimizations <= 1;
+
switch (r_type)
{
case R_390_GOTPLT12:
h->got.offset |= 1;
}
- if ((h->def_regular
- && SYMBOL_REFERENCES_LOCAL (info, h))
+ if (relax
+ && h->def_regular
+ && SYMBOL_REFERENCES_LOCAL (info, h)
/* lrl rx,sym@GOTENT -> larl rx, sym */
&& ((r_type == R_390_GOTENT
&& (bfd_get_16 (input_bfd,
bfd_reloc_status_type r;
int tls_type;
bool resolved_to_zero;
+ bool relax;
r_type = ELF64_R_TYPE (rel->r_info);
if (r_type == (int) R_390_GNU_VTINHERIT
resolved_to_zero = (h != NULL
&& UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+ /* Rewrite instructions and related relocations if (1) relaxation
+ disabled by default, (2) enabled by target, or (3) enabled by
+ user. Suppress rewriting if linker option --no-relax is used. */
+ relax = info->disable_target_specific_optimizations <= 1;
+
switch (r_type)
{
case R_390_GOTPLT12:
reference using larl we have to make sure that
the symbol is 1. properly aligned and 2. it is no
ABS symbol or will become one. */
- if (h->def_regular
+ if (relax
+ && h->def_regular
&& SYMBOL_REFERENCES_LOCAL (info, h)
/* lgrl rx,sym@GOTENT -> larl rx, sym */
&& ((r_type == R_390_GOTENT
either a load address of 0 or a trapping insn.
This prevents the PLT32DBL relocation from overflowing in
case the binary will be loaded at 4GB or more. */
- if (h->root.type == bfd_link_hash_undefweak
+ if (relax
+ && h->root.type == bfd_link_hash_undefweak
&& !h->root.linker_def
&& (bfd_link_executable (info)
|| ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
either a load address of 0, a NOP, or a trapping insn.
This prevents the PC32DBL relocation from overflowing in
case the binary will be loaded at 4GB or more. */
- if (h != NULL
+ if (relax
+ && h != NULL
&& h->root.type == bfd_link_hash_undefweak
&& !h->root.linker_def
&& (bfd_link_executable (info)
--- /dev/null
+
+tmpdir/gotreloc_31-1b: file format elf32-s390
+
+Disassembly of section .text:
+
+.* <foo>:
+.*: c4 18 00 00 08 56 [ ]*lgrl %r1,11b4 <_GLOBAL_OFFSET_TABLE_\+0x14>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: e3 10 c0 14 00 04 [ ]*lg %r1,20\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 1d 00 00 08 50 [ ]*lrl %r1,11b4 <_GLOBAL_OFFSET_TABLE_\+0x14>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: 58 10 c0 14 [ ]*l %r1,20\(%r12\)
+[ ]*.*: R_390_GOT12 bar
+.*: e3 10 c0 14 00 58 [ ]*ly %r1,20\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 18 00 00 08 46 [ ]*lgrl %r1,11b0 <_GLOBAL_OFFSET_TABLE_\+0x10>
+[ ]*.*: R_390_GOTENT _GLOBAL_OFFSET_TABLE_\+0x2
+.*: c4 18 00 00 08 41 [ ]*lgrl %r1,11ac <_GLOBAL_OFFSET_TABLE_\+0xc>
+[ ]*.*: R_390_GOTENT misaligned_sym\+0x2
--- /dev/null
+
+tmpdir/gotreloc_31-1b: file format elf32-s390
+
+Disassembly of section .text:
+
+.* <foo>:
+.*: c4 18 00 00 08 1e [ ]*lgrl %r1,4010b0 <_GLOBAL_OFFSET_TABLE_\+0x14>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: e3 10 c0 14 00 04 [ ]*lg %r1,20\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 1d 00 00 08 18 [ ]*lrl %r1,4010b0 <_GLOBAL_OFFSET_TABLE_\+0x14>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: 58 10 c0 14 [ ]*l %r1,20\(%r12\)
+[ ]*.*: R_390_GOT12 bar
+.*: e3 10 c0 14 00 58 [ ]*ly %r1,20\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 18 00 00 08 0e [ ]*lgrl %r1,4010ac <_GLOBAL_OFFSET_TABLE_\+0x10>
+[ ]*.*: R_390_GOTENT _GLOBAL_OFFSET_TABLE_\+0x2
+.*: c4 18 00 00 08 09 [ ]*lgrl %r1,4010a8 <_GLOBAL_OFFSET_TABLE_\+0xc>
+[ ]*.*: R_390_GOTENT misaligned_sym\+0x2
--- /dev/null
+tmpdir/gotreloc_64-1b: file format elf64-s390
+
+Disassembly of section .text:
+
+.* <foo>:
+.*: c4 18 00 00 08 28 [ ]*lgrl %r1,1001100 <_GLOBAL_OFFSET_TABLE_\+0x28>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: e3 10 c0 28 00 04 [ ]*lg %r1,40\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 1d 00 00 08 22 [ ]*lrl %r1,1001100 <_GLOBAL_OFFSET_TABLE_\+0x28>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: 58 10 c0 28 [ ]*l %r1,40\(%r12\)
+[ ]*.*: R_390_GOT12 bar
+.*: e3 10 c0 28 00 58 [ ]*ly %r1,40\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 18 00 00 08 16 [ ]*lgrl %r1,10010f8 <_GLOBAL_OFFSET_TABLE_\+0x20>
+[ ]*.*: R_390_GOTENT _GLOBAL_OFFSET_TABLE_\+0x2
+.*: c4 18 00 00 08 0f [ ]*lgrl %r1,10010f0 <_GLOBAL_OFFSET_TABLE_\+0x18>
+[ ]*.*: R_390_GOTENT misaligned_sym\+0x2
--- /dev/null
+tmpdir/gotreloc_64-1b: file format elf64-s390
+
+Disassembly of section .text:
+
+.* <foo>:
+.*: c4 18 00 00 08 98 [ ]*lgrl %r1,12e0 <_GLOBAL_OFFSET_TABLE_\+0x28>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: e3 10 c0 28 00 04 [ ]*lg %r1,40\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 1d 00 00 08 92 [ ]*lrl %r1,12e0 <_GLOBAL_OFFSET_TABLE_\+0x28>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: 58 10 c0 28 [ ]*l %r1,40\(%r12\)
+[ ]*.*: R_390_GOT12 bar
+.*: e3 10 c0 28 00 58 [ ]*ly %r1,40\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 18 00 00 08 86 [ ]*lgrl %r1,12d8 <_GLOBAL_OFFSET_TABLE_\+0x20>
+[ ]*.*: R_390_GOTENT _GLOBAL_OFFSET_TABLE_\+0x2
+.*: c4 18 00 00 08 7f [ ]*lgrl %r1,12d0 <_GLOBAL_OFFSET_TABLE_\+0x18>
+[ ]*.*: R_390_GOTENT misaligned_sym\+0x2
--- /dev/null
+tmpdir/gotreloc_64-1b: file format elf64-s390
+
+Disassembly of section .text:
+
+.* <foo>:
+.*: c4 18 00 00 0f 08 [ ]*lgrl %r1,1ff8 <_GLOBAL_OFFSET_TABLE_\+0x28>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: e3 10 c0 28 00 04 [ ]*lg %r1,40\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 1d 00 00 0f 02 [ ]*lrl %r1,1ff8 <_GLOBAL_OFFSET_TABLE_\+0x28>
+[ ]*.*: R_390_GOTENT bar\+0x2
+.*: 58 10 c0 28 [ ]*l %r1,40\(%r12\)
+[ ]*.*: R_390_GOT12 bar
+.*: e3 10 c0 28 00 58 [ ]*ly %r1,40\(%r12\)
+[ ]*.*: R_390_GOT20 bar
+.*: c4 18 00 00 0e f6 [ ]*lgrl %r1,1ff0 <_GLOBAL_OFFSET_TABLE_\+0x20>
+[ ]*.*: R_390_GOTENT _GLOBAL_OFFSET_TABLE_\+0x2
+.*: c4 18 00 00 0e ef [ ]*lgrl %r1,1fe8 <_GLOBAL_OFFSET_TABLE_\+0x18>
+[ ]*.*: R_390_GOTENT misaligned_sym\+0x2
"-m31" {gotreloc-1.s}
{{objdump -dzrj.text gotreloc_31-1a.dd}}
"gotreloc_31-1a"}
+ {"GOT: no symbol address load from got to larl (--no-relax)"
+ "-shared -melf_s390 --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs --no-relax" ""
+ "-m31" {gotreloc-1.s}
+ {{objdump -dzrj.text gotreloc_31-1b.dd}}
+ "gotreloc_31-1b"}
{"GOT: no-pie symbol address load from got to larl"
"-shared -melf_s390 --no-pie --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs" ""
"-m31" {gotreloc-1.s}
{{objdump -dzrj.text gotreloc_31-no-pie-1a.dd}}
"gotreloc_31-1a"}
+ {"GOT: no no-pie symbol address load from got to larl (--no-relax)"
+ "-shared -melf_s390 --no-pie --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs --no-relax" ""
+ "-m31" {gotreloc-1.s}
+ {{objdump -dzrj.text gotreloc_31-no-pie-1b.dd}}
+ "gotreloc_31-1b"}
{"Helper shared library (PLT test)"
"-shared -m elf_s390" "" "-m31" {pltlib.s}
{}
"-m64" {gotreloc-1.s}
{{objdump -dzrj.text gotreloc_64-norelro-1a.dd}}
"gotreloc_64-1a"}
+ {"GOT: no norelro symbol address load from got (--no-relax)"
+ "-shared -melf64_s390 -z norelro --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs --no-relax" ""
+ "-m64" {gotreloc-1.s}
+ {{objdump -dzrj.text gotreloc_64-norelro-1b.dd}}
+ "gotreloc_64-1b"}
{"GOT: relro symbol address load from got to larl"
"-shared -melf64_s390 -z relro --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs" ""
"-m64" {gotreloc-1.s}
{{objdump -dzrj.text gotreloc_64-relro-1a.dd}}
"gotreloc_64-1a"}
+ {"GOT: relro symbol address load from got (--no-relax)"
+ "-shared -melf64_s390 -z relro --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs --no-relax" ""
+ "-m64" {gotreloc-1.s}
+ {{objdump -dzrj.text gotreloc_64-relro-1b.dd}}
+ "gotreloc_64-1b"}
{"GOT: no-pie symbol address load from got to larl"
"-shared -melf64_s390 --no-pie --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs" ""
"-m64" {gotreloc-1.s}
{{objdump -dzrj.text gotreloc_64-no-pie-1a.dd}}
"gotreloc_64-1a"}
+ {"GOT: no-pie symbol address load from got (--no-relax)"
+ "-shared -melf64_s390 --no-pie --hash-style=sysv --version-script=gotreloc-1.ver --emit-relocs --no-relax" ""
+ "-m64" {gotreloc-1.s}
+ {{objdump -dzrj.text gotreloc_64-no-pie-1b.dd}}
+ "gotreloc_64-1b"}
{"PLT: offset test"
"-shared -m elf64_s390 -dT pltoffset-1.ld --no-error-rwx-segments" ""
"-m64" {pltoffset-1.s}
if [istarget "s390x-*-*"] {
run_ld_link_tests $s390xtests
+ run_dump_test "weakundef-1b"
+ run_dump_test "weakundef-2b"
+
if { ![skip_sframe_tests] } {
run_dump_test "sframe-simple-1"
run_dump_test "sframe-plt-1"
--- /dev/null
+#source: weakundef-1.s
+#as: -m64
+#ld: -m elf64_s390 -dT 8GB.ld --emit-relocs --no-error-rwx-segments --no-relax
+#objdump: -dzrj.text
+#error: tmpdir/weakundef-1.o: in function `foo':\n
+#error: \(\.text\+0xe\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x14\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x1a\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x20\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x26\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x2c\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x32\): relocation truncated to fit: R_390_PC32DBL against undefined symbol `wu'\n?
--- /dev/null
+#source: weakundef-2.s
+#as: -m64
+#ld: -m elf64_s390 -dT 8GB.ld --no-pie --emit-relocs --no-error-rwx-segments --no-relax
+#objdump: -dzrj.text
+#error: tmpdir/weakundef-2.o: in function `foo':\n
+#error: \(\.text\+0xe\): relocation truncated to fit: R_390_PLT32DBL against undefined symbol `wu'\n?
+#error: \(\.text\+0x20\): relocation truncated to fit: R_390_PLT32DBL against undefined symbol `wu'\n?