Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions lld/test/ELF/lto/aarch64-pac-got-func.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@

; CHECK: Relocation section '.rela.dyn' at offset 0x3d0 contains 8 entries:
; CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
; CHECK-NEXT: 00000000000206a0 0000000100000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 func_undef + 0
; CHECK-NEXT: 00000000000206a8 0000000200000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g1 + 0
; CHECK-NEXT: 00000000000206b0 0000000300000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g2 + 0
; CHECK-NEXT: 00000000000206b8 0000000400000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g3 + 0
; CHECK-NEXT: 00000000000206c0 0000000500000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g4 + 0
; CHECK-NEXT: 00000000000206c8 0000000600000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 var_undef + 0
; CHECK-NEXT: 0000000000020690 0000000700000412 R_AARCH64_AUTH_GLOB_DAT 0000000000010490 func + 0
; CHECK-NEXT: 0000000000020698 0000000a00000412 R_AARCH64_AUTH_GLOB_DAT 00000000000306d0 var + 0
; CHECK-NEXT: 00000000000210b8 0000000100000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 func_undef + 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use

[[#%x, ADDR:]]
{{0*}}[[#ADDR+0x8]]

so that the next time we change addresses, we only need to change one line.

Copy link
Contributor Author

@kovdan01 kovdan01 Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Applied your suggestion in 5dbfbff

; CHECK-NEXT: 00000000000210c0 0000000200000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g1 + 0
; CHECK-NEXT: 00000000000210c8 0000000300000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g2 + 0
; CHECK-NEXT: 00000000000210d0 0000000400000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g3 + 0
; CHECK-NEXT: 00000000000210d8 0000000500000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g4 + 0
; CHECK-NEXT: 00000000000210e0 0000000600000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 var_undef + 0
; CHECK-NEXT: 00000000000210a8 0000000700000412 R_AARCH64_AUTH_GLOB_DAT 0000000000010800 func + 0
; CHECK-NEXT: 00000000000210b0 0000000a00000412 R_AARCH64_AUTH_GLOB_DAT 0000000000031400 var + 0

; CHECK: Hex dump of section '.got':
; CHECK-NEXT: 0x00020690 00000000 00000080 00000000 000000a0
; CHECK-NEXT: 0x000210a8 00000000 00000080 00000000 000000a0
;; ^^ func: 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
;; ^^ var: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
; CHECK-NEXT: 0x000206a0 00000000 00000080 00000000 000000a0
; CHECK-NEXT: 0x000210b8 00000000 00000080 00000000 000000a0
;; ^^ func_undef: 0b10000000 bit 63 address diversity = true, bits 61..60 key = IA
;; ^^ g1: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
; CHECK-NEXT: 0x000206b0 00000000 000000a0 00000000 000000a0
; CHECK-NEXT: 0x000210c8 00000000 000000a0 00000000 000000a0
;; ^^ g2: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
;; ^^ g3: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
; CHECK-NEXT: 0x000206c0 00000000 000000a0 00000000 000000a0
; CHECK-NEXT: 0x000210d8 00000000 000000a0 00000000 000000a0
;; ^^ g4: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA
;; ^^ var_undef: 0b10100000 bit 63 address diversity = true, bits 61..60 key = DA

Expand All @@ -37,16 +37,26 @@ target triple = "aarch64-unknown-linux-gnu"
@g3 = external global ptr
@g4 = external global ptr

define void @func() {
; Minor codegen changes may influence function sizes and thus move subsequent
; symbols. To prevent accidental changes to symbol addresses, request an
; alignment that is larger than any expected function's size.
;
; Note that it is handy to have a trivial function like _start at the end of
; the .text section, as most offsets of interest point to the dynamic section,
; and one cannot easily control its alignment. On the other hand, the _start
; function almost certainly contains a single ret instruction and is itself
; aligned, making offsets of the subsequent sections predictable.
Copy link
Contributor

@atrosinenko atrosinenko Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With your latest commit, this paragraph is probably not relevant anymore as the address of the dynamic section is not hardcoded anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted, thanks, see 9d94626


define void @func() align 1024 {
entry:
ret void
}
declare void @func_undef()

@var = global i32 42
@var = global i32 42, align 1024
@var_undef = external global i32

define void @bar() #0 {
define void @bar() #0 align 1024 {
entry:
store ptr ptrauth (ptr @func, i32 0), ptr @g1
store ptr ptrauth (ptr @func_undef, i32 0), ptr @g2
Expand All @@ -55,7 +65,7 @@ entry:
ret void
}

define void @_start() {
define void @_start() align 1024 {
entry:
ret void
}
Expand Down