aarch64: Add DT_RELR tests for ILP32 ABI

This commit is contained in:
Szabolcs Nagy
2024-06-13 13:40:35 +01:00
parent c9cf7bdfe5
commit 22a8698b56
6 changed files with 166 additions and 1 deletions

View File

@@ -473,7 +473,7 @@ proc supports_dt_relr {} {
if { ([istarget x86_64-*-*]
|| [istarget i?86-*-*]
|| [istarget powerpc64*-*-*]
|| ([istarget aarch64*-*-*] && ![istarget *-*-*ilp32]))
|| [istarget aarch64*-*-*])
&& ([istarget *-*-linux*]
|| [istarget *-*-gnu*]) } {
return 1

View File

@@ -478,6 +478,10 @@ if { [supports_dt_relr] } {
run_dump_test_lp64 "relr-text-shared"
run_dump_test_lp64 "relr-discard-pie"
run_dump_test_lp64 "relr-discard-shared"
run_dump_test "relr-align-ilp32"
run_dump_test "relr-got-pie-ilp32"
run_dump_test "relr-got-shared-ilp32"
}
if { ![skip_sframe_tests] } {

View File

@@ -0,0 +1,23 @@
#source: relr-align-ilp32.s
#as: -mabi=ilp32
#ld: -m [aarch64_choose_ilp32_emul] -shared -z pack-relative-relocs -T relocs-ilp32.ld
#readelf: -rW
Relocation section '\.rela\.dyn' at offset 0x1.* contains 3 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
12340009 000000b7 R_AARCH64_P32_RELATIVE 10000
1234000d 000000b7 R_AARCH64_P32_RELATIVE 10000
12340025 000000b7 R_AARCH64_P32_RELATIVE 10000
Relocation section '\.relr\.dyn' at offset 0x1.* contains 10 entries which relocate 10 locations:
Index: Entry Address Symbolic Address
0000: 12340000 12340000 double_0
0001: 00000003 12340004 double_0 \+ 0x4
0002: 12340012 12340012 double_2
0003: 00000003 12340016 double_2 \+ 0x4
0004: 12340020 12340020 single_0
0005: 1234002a 1234002a single_2
0006: 12340034 12340034 big
0007: 123400b4 123400b4 big \+ 0x80
0008: 80000001 12340130 big \+ 0xfc
0009: 00000003 12340134 big \+ 0x100

View File

@@ -0,0 +1,106 @@
// Test DT_RELR with differently aligned relative relocs.
.text
.global _start
_start:
foo:
.data
.p2align 3
double_0:
.word foo
.word foo
.byte 0
double_1:
.word foo
.word foo
.byte 0
double_2:
.word foo
.word foo
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
single_0:
.word foo
.byte 0
single_1:
.word foo
.byte 0
single_2:
.word foo
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
.byte 0
big:
.word foo
.word 1
.word 2
.word 3
.word 4
.word 5
.word 6
.word 7
.word 8
.word 9
.word 10
.word 11
.word 12
.word 13
.word 14
.word 15
.word 16
.word 17
.word 18
.word 19
.word 20
.word 21
.word 22
.word 23
.word 24
.word 25
.word 26
.word 27
.word 28
.word 29
.word 30
.word 31
.word foo + 32
.word 33
.word 34
.word 35
.word 36
.word 37
.word 38
.word 39
.word 40
.word 41
.word 42
.word 43
.word 44
.word 45
.word 46
.word 47
.word 48
.word 49
.word 50
.word 51
.word 52
.word 53
.word 54
.word 55
.word 56
.word 57
.word 58
.word 59
.word 60
.word 61
.word 62
.word foo + 63
.word foo + 64

View File

@@ -0,0 +1,16 @@
#source: relr-got.s
#as: -mabi=ilp32
#ld: -m [aarch64_choose_ilp32_emul] -pie -z pack-relative-relocs -T relocs-ilp32.ld
#readelf: -rW
Relocation section '\.rela\.dyn' at offset 0x1.* contains 2 entries:
Offset Info Type Sym\. Value Symbol's Name \+ Addend
00000000 .* R_AARCH64_NONE 0
00020018 .* R_AARCH64_P32_GLOB_DAT 00000000 sym_weak_undef \+ 0
Relocation section '\.relr\.dyn' at offset 0x1.* contains 2 entries which relocate 4 locations:
Index: Entry Address Symbolic Address
0000: 00020004 00020004 _GLOBAL_OFFSET_TABLE_ \+ 0x4
0001: 0000000f 00020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8
0002000c _GLOBAL_OFFSET_TABLE_ \+ 0xc
00020010 _GLOBAL_OFFSET_TABLE_ \+ 0x10

View File

@@ -0,0 +1,16 @@
#source: relr-got.s
#as: -mabi=ilp32
#ld: -m [aarch64_choose_ilp32_emul] -shared -z pack-relative-relocs -T relocs-ilp32.ld
#readelf: -rW
Relocation section '\.rela\.dyn' at offset 0x1.* contains 3 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
00020010 .* R_AARCH64_P32_GLOB_DAT 00010038 sym_global \+ 0
00020014 .* R_AARCH64_P32_GLOB_DAT 0000002a sym_global_abs \+ 0
00020018 .* R_AARCH64_P32_GLOB_DAT 00000000 sym_weak_undef \+ 0
Relocation section '\.relr\.dyn' at offset 0x1.* contains 2 entries which relocate 3 locations:
Index: Entry Address Symbolic Address
0000: 00020004 00020004 _GLOBAL_OFFSET_TABLE_ \+ 0x4
0001: 00000007 00020008 _GLOBAL_OFFSET_TABLE_ \+ 0x8
0002000c _GLOBAL_OFFSET_TABLE_ \+ 0xc