diff options
author | Alan Modra <amodra@gmail.com> | 2025-07-12 01:25:53 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@orcam.me.uk> | 2025-07-12 01:25:53 +0100 |
commit | 7ea90d9316d375924b342485eb0cf99d268bf62f (patch) | |
tree | 0e222823851fba00533fb0fb1a91b4c790afce7c /ld | |
parent | 78f28b69ff1cdd8fcdf1944cfd82ea45f23e94d2 (diff) | |
download | gdb-master.zip gdb-master.tar.gz gdb-master.tar.bz2 |
With REL targets TLS HI16/LO16 relocations need to combine the low part
with the high part just as all the remaining HI16/LO16 relocations, so
as to determine the borrow in calculation correctly.
2025-07-12 Alan Modra <amodra@gmail.com>
bfd/
PR 19977
* elfxx-mips.c (tls_hi16_reloc_p): New function.
(mips_elf_add_lo16_rel_addend): Handle tls relocs.
(_bfd_mips_elf_relocate_section): Likewise.
2025-07-12 Maciej W. Rozycki <macro@orcam.me.uk>
ld/
PR 19977
* testsuite/ld-mips-elf/pr19977.d: New test.
* testsuite/ld-mips-elf/pr19977-mips16.d: New test.
* testsuite/ld-mips-elf/pr19977-micromips.d: New test.
* testsuite/ld-mips-elf/pr19977-r.d: New test.
* testsuite/ld-mips-elf/pr19977-r-mips16.d: New test.
* testsuite/ld-mips-elf/pr19977-r-micromips.d: New test.
* testsuite/ld-mips-elf/pr19977-r.s: New test source.
* testsuite/ld-mips-elf/pr19977.ld: New test linker script.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977-micromips.d | 25 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977-mips16.d | 24 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977-r-micromips.d | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977-r-mips16.d | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977-r.d | 32 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977-r.s | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977.d | 23 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/pr19977.ld | 14 |
9 files changed, 145 insertions, 0 deletions
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 6fc960d..e8a1d42 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -867,6 +867,16 @@ run_dump_test_n64 "pcrel-hilo-srec" \ [list [list name (n64)] \ [list objdump [expr { [istarget *el-*-*] ? "-EL" : "-EB" }]]] +run_dump_test_o32 "pr19977" +run_dump_test_n32 "pr19977" [list [list name (n32)]] +run_dump_test_o32 "pr19977-mips16" noarch +run_dump_test_n32 "pr19977-mips16" [list noarch [list name (n32)]] +run_dump_test_o32 "pr19977-micromips" noarch +run_dump_test_n32 "pr19977-micromips" [list noarch [list name (n32)]] +run_dump_test_o32 "pr19977-r" +run_dump_test_o32 "pr19977-r-mips16" noarch +run_dump_test_o32 "pr19977-r-micromips" noarch + if { $linux_gnu } { run_dump_test_n32 "textrel-1" run_dump_test "got-page-1" diff --git a/ld/testsuite/ld-mips-elf/pr19977-micromips.d b/ld/testsuite/ld-mips-elf/pr19977-micromips.d new file mode 100644 index 0000000..021b29c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977-micromips.d @@ -0,0 +1,25 @@ +#name: pr19977 microMIPS +#source: ../../../gas/testsuite/gas/mips/pr19977.s +#as: -mmicromips -march=mips64r2 +#objdump: -d +#ld: -Tpr19977.ld -e 0 -N +#notarget: mips*el-ps2-elf* + +.*: file format elf.*mips.* + +Disassembly of section \.text: + +10000000 <[^>]*>: +10000000: 3060 1122 li v1,4386 +10000004: 0063 8000 sll v1,v1,0x10 +10000008: 3063 2988 addiu v1,v1,10632 +1000000c: 3060 1122 li v1,4386 +10000010: 0063 8000 sll v1,v1,0x10 +10000014: 3063 1988 addiu v1,v1,6536 +10000018: 3060 1122 li v1,4386 +1000001c: 0063 8000 sll v1,v1,0x10 +10000020: 3063 a988 addiu v1,v1,-22136 +10000024: 3060 1122 li v1,4386 +10000028: 0063 8000 sll v1,v1,0x10 +1000002c: 3063 9988 addiu v1,v1,-26232 +#pass diff --git a/ld/testsuite/ld-mips-elf/pr19977-mips16.d b/ld/testsuite/ld-mips-elf/pr19977-mips16.d new file mode 100644 index 0000000..c927357 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977-mips16.d @@ -0,0 +1,24 @@ +#name: pr19977 MIPS16 +#source: ../../../gas/testsuite/gas/mips/pr19977.s +#as: -mips16 -march=mips3 +#objdump: -d +#ld: -Tpr19977.ld -e 0 -N + +.*: file format elf.*mips.* + +Disassembly of section \.text: + +10000000 <[^>]*>: +10000000: f122 6b02 li v1,4386 +10000004: f400 3360 sll v1,16 +10000008: f185 4b08 addiu v1,10632 +1000000c: f122 6b02 li v1,4386 +10000010: f400 3360 sll v1,16 +10000014: f183 4b08 addiu v1,6536 +10000018: f122 6b02 li v1,4386 +1000001c: f400 3360 sll v1,16 +10000020: f195 4b08 addiu v1,-22136 +10000024: f122 6b02 li v1,4386 +10000028: f400 3360 sll v1,16 +1000002c: f193 4b08 addiu v1,-26232 +#pass diff --git a/ld/testsuite/ld-mips-elf/pr19977-r-micromips.d b/ld/testsuite/ld-mips-elf/pr19977-r-micromips.d new file mode 100644 index 0000000..db99b97 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977-r-micromips.d @@ -0,0 +1,8 @@ +#name: pr19977 microMIPS -r +#source: pr19977-r.s +#source: ../../../gas/testsuite/gas/mips/pr19977.s +#as: -mmicromips -march=mips64r2 +#objdump: -dr +#ld: -r +#notarget: mips*el-ps2-elf* +#dump: pr19977-r.d diff --git a/ld/testsuite/ld-mips-elf/pr19977-r-mips16.d b/ld/testsuite/ld-mips-elf/pr19977-r-mips16.d new file mode 100644 index 0000000..dafa793 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977-r-mips16.d @@ -0,0 +1,7 @@ +#name: pr19977 MIPS16 -r +#source: pr19977-r.s +#source: ../../../gas/testsuite/gas/mips/pr19977.s +#as: -mips16 -march=mips3 +#objdump: -dr +#ld: -r +#dump: pr19977-r.d diff --git a/ld/testsuite/ld-mips-elf/pr19977-r.d b/ld/testsuite/ld-mips-elf/pr19977-r.d new file mode 100644 index 0000000..166194b --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977-r.d @@ -0,0 +1,32 @@ +#name: pr19977 MIPS -r +#source: pr19977-r.s +#source: ../../../gas/testsuite/gas/mips/pr19977.s +#objdump: -dr +#ld: -r + +.* + +Disassembly of section \.text: + +0+ <foo>: + 0: .* li v1,4387 + 0: R_(|MICRO)MIPS(|16)_TLS_TPREL_HI16 \$loc0 + 4: .* sll .* + 8: .* addiu v1(|,v1),-26232 + 8: R_(|MICRO)MIPS(|16)_TLS_TPREL_LO16 \$loc0 + c: .* li v1,4387 + c: R_(|MICRO)MIPS(|16)_TLS_DTPREL_HI16 \$loc0 + 10: .* sll .* + 14: .* addiu v1(|,v1),-26232 + 14: R_(|MICRO)MIPS(|16)_TLS_DTPREL_LO16 \$loc0 + 18: .* li v1,4387 + 18: R_(|MICRO)MIPS(|16)_TLS_TPREL_HI16 \.tdata + 1c: .* sll .* + 20: .* addiu v1(|,v1),-30328 + 20: R_(|MICRO)MIPS(|16)_TLS_TPREL_LO16 \.tdata + 24: .* li v1,4387 + 24: R_(|MICRO)MIPS(|16)_TLS_DTPREL_HI16 \.tdata + 28: .* sll .* + 2c: .* addiu v1(|,v1),-30328 + 2c: R_(|MICRO)MIPS(|16)_TLS_DTPREL_LO16 \.tdata +#pass diff --git a/ld/testsuite/ld-mips-elf/pr19977-r.s b/ld/testsuite/ld-mips-elf/pr19977-r.s new file mode 100644 index 0000000..4a46b30 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977-r.s @@ -0,0 +1,2 @@ + .section .tdata,"awT",%progbits + .space 28672 diff --git a/ld/testsuite/ld-mips-elf/pr19977.d b/ld/testsuite/ld-mips-elf/pr19977.d new file mode 100644 index 0000000..145f697 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977.d @@ -0,0 +1,23 @@ +#name: pr19977 MIPS +#source: ../../../gas/testsuite/gas/mips/pr19977.s +#objdump: -d +#ld: -Tpr19977.ld -e 0 -N + +.*: file format elf.*mips.* + +Disassembly of section \.text: + +10000000 <[^>]*>: +10000000: 24031122 li v1,4386 +10000004: 00031c00 sll v1,v1,0x10 +10000008: 24632988 addiu v1,v1,10632 +1000000c: 24031122 li v1,4386 +10000010: 00031c00 sll v1,v1,0x10 +10000014: 24631988 addiu v1,v1,6536 +10000018: 24031122 li v1,4386 +1000001c: 00031c00 sll v1,v1,0x10 +10000020: 2463a988 addiu v1,v1,-22136 +10000024: 24031122 li v1,4386 +10000028: 00031c00 sll v1,v1,0x10 +1000002c: 24639988 addiu v1,v1,-26232 +#pass diff --git a/ld/testsuite/ld-mips-elf/pr19977.ld b/ld/testsuite/ld-mips-elf/pr19977.ld new file mode 100644 index 0000000..0b2f7c1 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/pr19977.ld @@ -0,0 +1,14 @@ +MEMORY +{ + text (rx) : ORIGIN = 0x10000000, LENGTH = 0x40000 + data (w) : ORIGIN = 0x34560000, LENGTH = 0x40000 +} +SECTIONS +{ + .text : { *(.text) } >text + .tdata : { *(.tdata) } >data + .symtab : { *(.symtab) } + .strtab : { *(.strtab) } + .shstrtab : { *(.shstrtab) } + /DISCARD/ : { *(*) } +} |