55; RUN: llvm-readelf -r -x.got %t | FileCheck %s
66
77; CHECK: Relocation section '.rela.dyn' at offset 0x3d0 contains 8 entries:
8- ; CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
9- ; CHECK-NEXT: {{(0{8})}}[[OFFSET1:([[:xdigit:]]{8})]] 0000000100000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 func_undef + 0
10- ; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000200000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g1 + 0
11- ; CHECK-NEXT: {{(0{8})}}[[OFFSET2:([[:xdigit:]]{8})]] 0000000300000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g2 + 0
12- ; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000400000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g3 + 0
13- ; CHECK-NEXT: {{(0{8})}}[[OFFSET3:([[:xdigit:]]{8})]] 0000000500000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g4 + 0
14- ; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000600000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 var_undef + 0
15- ; CHECK-NEXT: {{(0{8})}}[[OFFSET4:([[:xdigit:]]{8})]] 0000000700000412 R_AARCH64_AUTH_GLOB_DAT {{([[:xdigit:]]{16})}} func + 0
16- ; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000a00000412 R_AARCH64_AUTH_GLOB_DAT {{([[:xdigit:]]{16})}} var + 0
8+ ; CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
9+ ; CHECK-NEXT: 00000000000210b8 0000000100000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 func_undef + 0
10+ ; CHECK-NEXT: 00000000000210c0 0000000200000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g1 + 0
11+ ; CHECK-NEXT: 00000000000210c8 0000000300000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g2 + 0
12+ ; CHECK-NEXT: 00000000000210d0 0000000400000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g3 + 0
13+ ; CHECK-NEXT: 00000000000210d8 0000000500000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g4 + 0
14+ ; CHECK-NEXT: 00000000000210e0 0000000600000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 var_undef + 0
15+ ; CHECK-NEXT: 00000000000210a8 0000000700000412 R_AARCH64_AUTH_GLOB_DAT 0000000000010800 func + 0
16+ ; CHECK-NEXT: 00000000000210b0 0000000a00000412 R_AARCH64_AUTH_GLOB_DAT 0000000000031400 var + 0
1717
1818; CHECK: Hex dump of section '.got':
19- ; CHECK-NEXT: 0x[[OFFSET4]] 00000000 00000080 00000000 000000a0
20- ;; ^^ func: 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
21- ;; ^^ var: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
22- ; CHECK-NEXT: 0x[[OFFSET1]] 00000000 00000080 00000000 000000a0
23- ;; ^^ func_undef: 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
24- ;; ^^ g1: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
25- ; CHECK-NEXT: 0x[[OFFSET2]] 00000000 000000a0 00000000 000000a0
26- ;; ^^ g2: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
27- ;; ^^ g3: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
28- ; CHECK-NEXT: 0x[[OFFSET3]] 00000000 000000a0 00000000 000000a0
29- ;; ^^ g4: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
30- ;; ^^ var_undef: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
19+ ; CHECK-NEXT: 0x000210a8 00000000 00000080 00000000 000000a0
20+ ;; ^^ func: 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
21+ ;; ^^ var: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
22+ ; CHECK-NEXT: 0x000210b8 00000000 00000080 00000000 000000a0
23+ ;; ^^ func_undef: 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
24+ ;; ^^ g1: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
25+ ; CHECK-NEXT: 0x000210c8 00000000 000000a0 00000000 000000a0
26+ ;; ^^ g2: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
27+ ;; ^^ g3: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
28+ ; CHECK-NEXT: 0x000210d8 00000000 000000a0 00000000 000000a0
29+ ;; ^^ g4: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
30+ ;; ^^ var_undef: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
3131
3232target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
3333target triple = "aarch64-unknown-linux-gnu"
@@ -37,16 +37,26 @@ target triple = "aarch64-unknown-linux-gnu"
3737@g3 = external global ptr
3838@g4 = external global ptr
3939
40- define void @func () {
40+ ; Minor codegen changes may influence function sizes and thus move subsequent
41+ ; symbols. To prevent accidental changes to symbol addresses, request an
42+ ; alignment that is larger than any expected function's size.
43+ ;
44+ ; Note that it is handy to have a trivial function like _start at the end of
45+ ; the .text section, as most offsets of interest point to the dynamic section,
46+ ; and one cannot easily control its alignment. On the other hand, the _start
47+ ; function almost certainly contains a single ret instruction and is itself
48+ ; aligned, making offsets of the subsequent sections predictable.
49+
50+ define void @func () align 1024 {
4151entry:
4252 ret void
4353}
4454declare void @func_undef ()
4555
46- @var = global i32 42
56+ @var = global i32 42 , align 1024
4757@var_undef = external global i32
4858
49- define void @bar () #0 {
59+ define void @bar () #0 align 1024 {
5060entry:
5161 store ptr ptr auth (ptr @func , i32 0 ), ptr @g1
5262 store ptr ptr auth (ptr @func_undef , i32 0 ), ptr @g2
5565 ret void
5666}
5767
58- define void @_start () {
68+ define void @_start () align 1024 {
5969entry:
6070 ret void
6171}
0 commit comments