-
Notifications
You must be signed in to change notification settings - Fork 14k
[lld][test][PAC] Do not rely on concrete offsets in LTO tests #143358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lld][test][PAC] Do not rely on concrete offsets in LTO tests #143358
Conversation
@llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: Daniil Kovalev (kovdan01) ChangesWhen changing codegen (e.g. in #130809), offsets in binaries produced by LTO tests might change. We do not need to match concrete offset values, it's enough to ensure that hex values in particular places are identical. Full diff: https://github.com/llvm/llvm-project/pull/143358.diff 1 Files Affected:
diff --git a/lld/test/ELF/lto/aarch64-pac-got-func.ll b/lld/test/ELF/lto/aarch64-pac-got-func.ll
index a37c67a2f3ba8..aa84952e7aad8 100644
--- a/lld/test/ELF/lto/aarch64-pac-got-func.ll
+++ b/lld/test/ELF/lto/aarch64-pac-got-func.ll
@@ -5,29 +5,29 @@
; RUN: llvm-readelf -r -x.got %t | FileCheck %s
; 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: Offset Info Type Symbol's Value Symbol's Name + Addend
+; CHECK-NEXT: {{(0{8})}}[[OFFSET1:([[:xdigit:]]{8})]] 0000000100000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 func_undef + 0
+; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000200000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g1 + 0
+; CHECK-NEXT: {{(0{8})}}[[OFFSET2:([[:xdigit:]]{8})]] 0000000300000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g2 + 0
+; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000400000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g3 + 0
+; CHECK-NEXT: {{(0{8})}}[[OFFSET3:([[:xdigit:]]{8})]] 0000000500000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 g4 + 0
+; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000600000412 R_AARCH64_AUTH_GLOB_DAT 0000000000000000 var_undef + 0
+; CHECK-NEXT: {{(0{8})}}[[OFFSET4:([[:xdigit:]]{8})]] 0000000700000412 R_AARCH64_AUTH_GLOB_DAT {{([[:xdigit:]]{16})}} func + 0
+; CHECK-NEXT: {{([[:xdigit:]]{16})}} 0000000a00000412 R_AARCH64_AUTH_GLOB_DAT {{([[:xdigit:]]{16})}} var + 0
; CHECK: Hex dump of section '.got':
-; CHECK-NEXT: 0x00020690 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
-;; ^^ 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
-;; ^^ 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
-;; ^^ 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
+; CHECK-NEXT: 0x[[OFFSET4]] 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: 0x[[OFFSET1]] 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: 0x[[OFFSET2]] 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: 0x[[OFFSET3]] 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
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
|
When changing codegen (e.g. in llvm#130809), offsets in binaries produced by LTO tests might change. We do not need to match concrete offset values, it's enough to ensure that hex values in particular places are identical.
18e28a0
to
4d322b5
Compare
@kovdan01 As discussed, I tried specifying large symbol alignments and this seems to look cleaner. I pushed my proposal here, please feel free to revert if not needed. |
@atrosinenko Thanks! I don't mind using this approach if noone else has objections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a neat trick to me
; 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
9fe76a8
to
5dbfbff
Compare
; 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted, thanks, see 9d94626
…43358) When changing codegen (e.g. in llvm#130809), offsets in binaries produced by LTO tests might change. We do not need to match concrete offset values, it's enough to ensure that hex values in particular places are identical. --------- Co-authored-by: Anatoly Trosinenko <atrosinenko@accesssoftek.com>
When changing codegen (e.g. in #130809), offsets in binaries produced by LTO tests might change. We do not need to match concrete offset values, it's enough to ensure that hex values in particular places are identical.