diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2024-05-22 16:52:11 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2024-05-31 09:47:50 +0100 |
commit | 5df6499c83896c243073d8cad8c5830f89436bd6 (patch) | |
tree | adabb39ea30301b2017f9a7c6fa53160ead05fea /ld/testsuite/ld-aarch64 | |
parent | a71d87680110d854f966d8cda0f1c7887001fcdd (diff) | |
download | gdb-5df6499c83896c243073d8cad8c5830f89436bd6.zip gdb-5df6499c83896c243073d8cad8c5830f89436bd6.tar.gz gdb-5df6499c83896c243073d8cad8c5830f89436bd6.tar.bz2 |
aarch64: Add some DT_RELR ld tests
Diffstat (limited to 'ld/testsuite/ld-aarch64')
-rw-r--r-- | ld/testsuite/ld-aarch64/aarch64-elf.exp | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-align.d | 22 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-align.s | 106 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-data-pie.d | 18 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-data-shared.d | 18 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-data.s | 71 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-got-pie.d | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-got-shared.d | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-got.s | 40 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-text-pie.d | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-text-shared.d | 14 | ||||
-rw-r--r-- | ld/testsuite/ld-aarch64/relr-text.s | 10 |
12 files changed, 351 insertions, 0 deletions
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp index 9ce6157..38929ff 100644 --- a/ld/testsuite/ld-aarch64/aarch64-elf.exp +++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp @@ -468,6 +468,14 @@ run_dump_test_lp64 "bti-far-2" run_dump_test_lp64 "bti-far-opt" run_dump_test_lp64 "bti-far-3" +run_dump_test_lp64 "relr-align" +run_dump_test_lp64 "relr-data-pie" +run_dump_test_lp64 "relr-data-shared" +run_dump_test_lp64 "relr-got-pie" +run_dump_test_lp64 "relr-got-shared" +run_dump_test_lp64 "relr-text-pie" +run_dump_test_lp64 "relr-text-shared" + if { ![skip_sframe_tests] } { run_dump_test "sframe-simple-1" } diff --git a/ld/testsuite/ld-aarch64/relr-align.d b/ld/testsuite/ld-aarch64/relr-align.d new file mode 100644 index 0000000..ac2fa6e --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-align.d @@ -0,0 +1,22 @@ +#source: relr-align.s +#ld: -shared -z pack-relative-relocs -T relocs.ld +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset 0x10090 contains 3 entries: + Offset Info Type Symbol's Value Symbol's Name \+ Addend +0000000012340011 0000000000000403 R_AARCH64_RELATIVE 10000 +0000000012340019 0000000000000403 R_AARCH64_RELATIVE 10000 +0000000012340041 0000000000000403 R_AARCH64_RELATIVE 10000 + +Relocation section '\.relr\.dyn' at offset 0x100d8 contains 9 entries which relocate 10 locations: +Index: Entry Address Symbolic Address +0000: 0000000012340000 0000000012340000 double_0 +0001: 0000000000000003 0000000012340008 double_0 \+ 0x8 +0002: 0000000012340022 0000000012340022 double_2 +0003: 0000000000000003 000000001234002a double_2 \+ 0x8 +0004: 0000000012340038 0000000012340038 single_0 +0005: 000000001234004a 000000001234004a single_2 +0006: 0000000012340058 0000000012340058 big +0007: 8000000100000001 0000000012340158 big \+ 0x100 + 0000000012340250 big \+ 0x1f8 +0008: 0000000000000003 0000000012340258 big \+ 0x200 diff --git a/ld/testsuite/ld-aarch64/relr-align.s b/ld/testsuite/ld-aarch64/relr-align.s new file mode 100644 index 0000000..94223cd --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-align.s @@ -0,0 +1,106 @@ +// Test DT_RELR with differently aligned relative relocs. + +.text +.global _start +_start: +foo: + +.data +.p2align 3 +double_0: +.xword foo +.xword foo +.byte 0 +double_1: +.xword foo +.xword foo +.byte 0 +double_2: +.xword foo +.xword foo +.byte 0 +.byte 0 +.byte 0 +.byte 0 +.byte 0 +.byte 0 +single_0: +.xword foo +.byte 0 +single_1: +.xword foo +.byte 0 +single_2: +.xword foo +.byte 0 +.byte 0 +.byte 0 +.byte 0 +.byte 0 +.byte 0 +big: +.xword foo +.xword 1 +.xword 2 +.xword 3 +.xword 4 +.xword 5 +.xword 6 +.xword 7 +.xword 8 +.xword 9 +.xword 10 +.xword 11 +.xword 12 +.xword 13 +.xword 14 +.xword 15 +.xword 16 +.xword 17 +.xword 18 +.xword 19 +.xword 20 +.xword 21 +.xword 22 +.xword 23 +.xword 24 +.xword 25 +.xword 26 +.xword 27 +.xword 28 +.xword 29 +.xword 30 +.xword 31 +.xword foo + 32 +.xword 33 +.xword 34 +.xword 35 +.xword 36 +.xword 37 +.xword 38 +.xword 39 +.xword 40 +.xword 41 +.xword 42 +.xword 43 +.xword 44 +.xword 45 +.xword 46 +.xword 47 +.xword 48 +.xword 49 +.xword 50 +.xword 51 +.xword 52 +.xword 53 +.xword 54 +.xword 55 +.xword 56 +.xword 57 +.xword 58 +.xword 59 +.xword 60 +.xword 61 +.xword 62 +.xword foo + 63 +.xword foo + 64 diff --git a/ld/testsuite/ld-aarch64/relr-data-pie.d b/ld/testsuite/ld-aarch64/relr-data-pie.d new file mode 100644 index 0000000..b90ff3b --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-data-pie.d @@ -0,0 +1,18 @@ +#source: relr-data.s +#ld: -pie -z pack-relative-relocs -T relocs.ld +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset 0x1.* contains 5 entries: + Offset Info Type Symbol's Value Symbol's Name \+ Addend +0000000012340000 0000000000000403 R_AARCH64_RELATIVE 10004 +0000000012340008 0000000000000403 R_AARCH64_RELATIVE 10008 +0000000012340010 0000000000000403 R_AARCH64_RELATIVE 1000c +0000000012340018 0000000000000403 R_AARCH64_RELATIVE 12340050 +0000000012340040 0000000300000101 R_AARCH64_ABS64 0000000000000000 sym_weak_undef \+ 0 + +Relocation section '\.relr\.dyn' at offset 0x1.* contains 2 entries which relocate 4 locations: +Index: Entry Address Symbolic Address +0000: 0000000012340020 0000000012340020 aligned_local +0001: 0000000000000027 0000000012340028 aligned_hidden + 0000000012340030 aligned_global + 0000000012340048 aligned_DYNAMIC diff --git a/ld/testsuite/ld-aarch64/relr-data-shared.d b/ld/testsuite/ld-aarch64/relr-data-shared.d new file mode 100644 index 0000000..d94b335 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-data-shared.d @@ -0,0 +1,18 @@ +#source: relr-data.s +#ld: -shared -z pack-relative-relocs -T relocs.ld +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset 0x10150 contains 6 entries: + Offset Info Type Symbol's Value Symbol's Name \+ Addend +0000000012340000 0000000000000403 R_AARCH64_RELATIVE 10004 +0000000012340008 0000000000000403 R_AARCH64_RELATIVE 10008 +0000000012340018 0000000000000403 R_AARCH64_RELATIVE 12340050 +0000000012340010 0000000400000101 R_AARCH64_ABS64 000000000001000c sym_global \+ 0 +0000000012340030 0000000400000101 R_AARCH64_ABS64 000000000001000c sym_global \+ 0 +0000000012340040 0000000300000101 R_AARCH64_ABS64 0000000000000000 sym_weak_undef \+ 0 + +Relocation section '\.relr\.dyn' at offset 0x101e0 contains 2 entries which relocate 3 locations: +Index: Entry Address Symbolic Address +0000: 0000000012340020 0000000012340020 aligned_local +0001: 0000000000000023 0000000012340028 aligned_hidden + 0000000012340048 aligned_DYNAMIC diff --git a/ld/testsuite/ld-aarch64/relr-data.s b/ld/testsuite/ld-aarch64/relr-data.s new file mode 100644 index 0000000..93b401e --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-data.s @@ -0,0 +1,71 @@ +// Test symbol references in .data when used with DT_RELR. +// Relocations for unaligned sections are currently not packed. + +.text +.global _start +_start: + nop + +sym_local: + nop + +.global sym_hidden +.hidden sym_hidden +sym_hidden: + nop + +.global sym_global +sym_global: + nop + +.global sym_global_abs +.set sym_global_abs, 42 + +.global sym_weak_undef +.weak sym_weak_undef + +.section .data.unaligned_local +unaligned_local: +.xword sym_local + +.section .data.unaligned_hidden +unaligned_hidden: +.xword sym_hidden + +.section .data.unaligned_global +unaligned_global: +.xword sym_global + +.section .data.unaligned_DYNAMIC +unaligned_DYNAMIC: +.xword _DYNAMIC + +.section .data.aligned_local +.p2align 1 +aligned_local: +.xword sym_local + +.section .data.aligned_hidden +.p2align 1 +aligned_hidden: +.xword sym_hidden + +.section .data.aligned_global +.p2align 1 +aligned_global: +.xword sym_global + +.section .data.aligned_global_abs +.p2align 1 +aligned_global_abs: +.xword sym_global_abs + +.section .data.aligned_weak_undef +.p2align 1 +aligned_weak_undef: +.xword sym_weak_undef + +.section .data.aligned_DYNAMIC +.p2align 1 +aligned_DYNAMIC: +.xword _DYNAMIC diff --git a/ld/testsuite/ld-aarch64/relr-got-pie.d b/ld/testsuite/ld-aarch64/relr-got-pie.d new file mode 100644 index 0000000..f0b7c73 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-got-pie.d @@ -0,0 +1,15 @@ +#source: relr-got.s +#ld: -pie -z pack-relative-relocs -T relocs.ld +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset 0x1.* contains 2 entries: + Offset Info Type Symbol's Value Symbol's Name \+ Addend +0000000000000000 0000000000000000 R_AARCH64_NONE 0 +0000000000020030 0000000200000401 R_AARCH64_GLOB_DAT 0000000000000000 sym_weak_undef \+ 0 + +Relocation section '\.relr\.dyn' at offset 0x1.* contains 2 entries which relocate 4 locations: +Index: Entry Address Symbolic Address +0000: 0000000000020008 0000000000020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8 +0001: 000000000000000f 0000000000020010 _GLOBAL_OFFSET_TABLE_ \+ 0x10 + 0000000000020018 _GLOBAL_OFFSET_TABLE_ \+ 0x18 + 0000000000020020 _GLOBAL_OFFSET_TABLE_ \+ 0x20 diff --git a/ld/testsuite/ld-aarch64/relr-got-shared.d b/ld/testsuite/ld-aarch64/relr-got-shared.d new file mode 100644 index 0000000..5952694 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-got-shared.d @@ -0,0 +1,15 @@ +#source: relr-got.s +#ld: -shared -z pack-relative-relocs -T relocs.ld +#readelf: -rW + +Relocation section '\.rela\.dyn' at offset 0x10168 contains 3 entries: + Offset Info Type Symbol's Value Symbol's Name \+ Addend +0000000000020020 0000000300000401 R_AARCH64_GLOB_DAT 0000000000010038 sym_global \+ 0 +0000000000020028 0000000500000401 R_AARCH64_GLOB_DAT 000000000000002a sym_global_abs \+ 0 +0000000000020030 0000000200000401 R_AARCH64_GLOB_DAT 0000000000000000 sym_weak_undef \+ 0 + +Relocation section '\.relr\.dyn' at offset 0x101b0 contains 2 entries which relocate 3 locations: +Index: Entry Address Symbolic Address +0000: 0000000000020008 0000000000020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8 +0001: 0000000000000007 0000000000020010 _GLOBAL_OFFSET_TABLE_ \+ 0x10 + 0000000000020018 _GLOBAL_OFFSET_TABLE_ \+ 0x18 diff --git a/ld/testsuite/ld-aarch64/relr-got.s b/ld/testsuite/ld-aarch64/relr-got.s new file mode 100644 index 0000000..44e4463 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-got.s @@ -0,0 +1,40 @@ +// Test GOT relocations with DT_RELR. + +.text +.global _start +_start: + adrp x0, :got:sym_local + ldr x0, [x0, :got_lo12:sym_local] + + adrp x0, :got:sym_hidden + ldr x0, [x0, :got_lo12:sym_hidden] + + adrp x0, :got:sym_global + ldr x0, [x0, :got_lo12:sym_global] + + adrp x0, :got:sym_global + ldr x0, [x0, :got_lo12:sym_global_abs] + + adrp x0, :got:sym_weak_undef + ldr x0, [x0, :got_lo12:sym_weak_undef] + + adrp x0, :got:_DYNAMIC + ldr x0, [x0, :got_lo12:_DYNAMIC] + +sym_local: + nop + +.global sym_hidden +.hidden sym_hidden +sym_hidden: + nop + +.global sym_global +sym_global: + nop + +.global sym_global_abs +.set sym_global_abs, 42 + +.global sym_weak_undef +.weak sym_weak_undef diff --git a/ld/testsuite/ld-aarch64/relr-text-pie.d b/ld/testsuite/ld-aarch64/relr-text-pie.d new file mode 100644 index 0000000..6036979 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-text-pie.d @@ -0,0 +1,14 @@ +#source: relr-text.s +#ld: -pie -z pack-relative-relocs -T relocs.ld +#readelf: -drW + +#... + 0x0000000000000016 \(TEXTREL\) 0x0 +#... + 0x0000000000000024 \(RELR\) 0x1.* + 0x0000000000000023 \(RELRSZ\) 8 \(bytes\) + 0x0000000000000025 \(RELRENT\) 8 \(bytes\) +#... +Relocation section '\.relr\.dyn' at offset 0x1.* contains 1 entry which relocates 1 location: +Index: Entry Address Symbolic Address +0000: 0000000000010000 0000000000010000 _start diff --git a/ld/testsuite/ld-aarch64/relr-text-shared.d b/ld/testsuite/ld-aarch64/relr-text-shared.d new file mode 100644 index 0000000..06895d4 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-text-shared.d @@ -0,0 +1,14 @@ +#source: relr-text.s +#ld: -shared -z pack-relative-relocs -T relocs.ld +#readelf: -drW + +#... + 0x0000000000000016 \(TEXTREL\) 0x0 +#... + 0x0000000000000024 \(RELR\) 0x10098 + 0x0000000000000023 \(RELRSZ\) 8 \(bytes\) + 0x0000000000000025 \(RELRENT\) 8 \(bytes\) +#... +Relocation section '.relr.dyn' at offset 0x10098 contains 1 entry which relocates 1 location: +Index: Entry Address Symbolic Address +0000: 0000000000010000 0000000000010000 _start diff --git a/ld/testsuite/ld-aarch64/relr-text.s b/ld/testsuite/ld-aarch64/relr-text.s new file mode 100644 index 0000000..83ac557 --- /dev/null +++ b/ld/testsuite/ld-aarch64/relr-text.s @@ -0,0 +1,10 @@ +// Test DT_RELR with DT_TEXTREL. + +.text +.p2align 3 +.global _start +_start: +.global foo +.hidden foo +foo: +.xword foo |