aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2024-06-04 09:23:41 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2024-06-07 08:23:23 +0100
commitb284a87b49c9546445469fd4fa7c61bb782c6bd6 (patch)
treefeaf4564e26dc6c0a42d95a82aff950647982fb5 /ld/testsuite
parent961befd69308895bf1dc39737d1598246dc296a8 (diff)
downloadbinutils-b284a87b49c9546445469fd4fa7c61bb782c6bd6.zip
binutils-b284a87b49c9546445469fd4fa7c61bb782c6bd6.tar.gz
binutils-b284a87b49c9546445469fd4fa7c61bb782c6bd6.tar.bz2
aarch64: Test DT_RELR with discarded sections
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ld-aarch64/aarch64-elf.exp2
-rw-r--r--ld/testsuite/ld-aarch64/relr-discard-pie.d18
-rw-r--r--ld/testsuite/ld-aarch64/relr-discard-shared.d18
-rw-r--r--ld/testsuite/ld-aarch64/relr-discard.ld13
-rw-r--r--ld/testsuite/ld-aarch64/relr-discard.s63
5 files changed, 114 insertions, 0 deletions
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index 38929ff..0e70ca3 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -475,6 +475,8 @@ 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"
+run_dump_test_lp64 "relr-discard-pie"
+run_dump_test_lp64 "relr-discard-shared"
if { ![skip_sframe_tests] } {
run_dump_test "sframe-simple-1"
diff --git a/ld/testsuite/ld-aarch64/relr-discard-pie.d b/ld/testsuite/ld-aarch64/relr-discard-pie.d
new file mode 100644
index 0000000..7e7f341
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/relr-discard-pie.d
@@ -0,0 +1,18 @@
+#source: relr-discard.s
+#ld: -pie --no-apply-dynamic-relocs -z pack-relative-relocs -T relr-discard.ld
+#readelf: -rW
+
+# Note: There are unnecessary GOT entries and *_NONE relocations
+# for those GOT entries and discarded locations, this is bug 31850.
+
+Relocation section '\.rela\.dyn' at offset 0x1.* contains 4 entries:
+ Offset Info Type Symbol's Value Symbol's Name \+ Addend
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+
+Relocation section '\.relr\.dyn' at offset 0x1.* contains 2 entries which relocate 2 locations:
+Index: Entry Address Symbolic Address
+0000: 0000000000020008 0000000000020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8
+0001: 0000000000000003 0000000000020010 _GLOBAL_OFFSET_TABLE_ \+ 0x10
diff --git a/ld/testsuite/ld-aarch64/relr-discard-shared.d b/ld/testsuite/ld-aarch64/relr-discard-shared.d
new file mode 100644
index 0000000..9260a6d
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/relr-discard-shared.d
@@ -0,0 +1,18 @@
+#source: relr-discard.s
+#ld: -shared --no-apply-dynamic-relocs -z pack-relative-relocs -T relr-discard.ld
+#readelf: -rW
+
+# Note: There are unnecessary GOT entries and *_NONE relocations
+# for those GOT entries and discarded locations, this is bug 31850.
+
+Relocation section '\.rela\.dyn' at offset 0x1.* contains 5 entries:
+ Offset Info Type Symbol's Value Symbol's Name \+ Addend
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000000000 0000000000000000 R_AARCH64_NONE 0
+0000000000020010 .* R_AARCH64_GLOB_DAT 000000000001000c sym_global \+ 0
+
+Relocation section '\.relr\.dyn' at offset 0x1.* contains 1 entry which relocates 1 location:
+Index: Entry Address Symbolic Address
+0000: 0000000000020008 0000000000020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8
diff --git a/ld/testsuite/ld-aarch64/relr-discard.ld b/ld/testsuite/ld-aarch64/relr-discard.ld
new file mode 100644
index 0000000..288ba23
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/relr-discard.ld
@@ -0,0 +1,13 @@
+OUTPUT_ARCH(aarch64)
+ENTRY(_start)
+SECTIONS
+{
+ /DISCARD/ : { *(.discard.*) }
+
+ . = 0x10000;
+ .text : { *(.text) }
+ . = 0x20000;
+ .got : { *(.got) *(.got.plt)}
+ . = 0x30000;
+ .data : { *(.data) *(.data.*) }
+}
diff --git a/ld/testsuite/ld-aarch64/relr-discard.s b/ld/testsuite/ld-aarch64/relr-discard.s
new file mode 100644
index 0000000..0ed9b4a
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/relr-discard.s
@@ -0,0 +1,63 @@
+// Test DT_RELR with references in discarded sections.
+
+.text
+.p2align 3
+.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 .discard.got_local,"ax"
+ adrp x0, :got:sym_local
+ ldr x0, [x0, :got_lo12:sym_local]
+
+.section .discard.got_global,"ax"
+ adrp x0, :got:sym_global
+ ldr x0, [x0, :got_lo12:sym_global]
+
+.section .discard.local,"a"
+.p2align 1
+discard_local:
+.xword sym_local
+
+.section .discard.hidden,"a"
+.p2align 1
+discard_hidden:
+.xword sym_hidden
+
+.section .discard.global,"a"
+.p2align 1
+discard_global:
+.xword sym_global
+
+.section .discard.global_abs,"a"
+.p2align 1
+discard_global_abs:
+.xword sym_global_abs
+
+.section .discard.weak_undef,"a"
+.p2align 1
+discard_weak_undef:
+.xword sym_weak_undef
+
+.section .discard._DYNAMIC,"a"
+.p2align 1
+discard_DYNAMIC:
+.xword _DYNAMIC