-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[PAC][lld] Do not emit warnings for -z pac-plt
with valid PAuth core info
#112959
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
[PAC][lld] Do not emit warnings for -z pac-plt
with valid PAuth core info
#112959
Conversation
@llvm/pr-subscribers-lld-elf Author: Daniil Kovalev (kovdan01) ChangesWhen PAuth core info is present and (platform,version) is not (0,0), Full diff: https://github.com/llvm/llvm-project/pull/112959.diff 3 Files Affected:
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index fb77e67e9fc5ca..c436be6b24e001 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2753,6 +2753,10 @@ static void readSecurityNotes(Ctx &ctx) {
referenceFileName = (*it)->getName();
}
}
+ bool hasValidPauthAbiCoreInfo =
+ (!ctx.aarch64PauthAbiCoreInfo.empty() &&
+ llvm::any_of(ctx.aarch64PauthAbiCoreInfo,
+ [](uint8_t c) { return c != 0; }));
for (ELFFileBase *f : ctx.objectFiles) {
uint32_t features = f->andFeatures;
@@ -2789,9 +2793,11 @@ static void readSecurityNotes(Ctx &ctx) {
"GNU_PROPERTY_X86_FEATURE_1_IBT property");
features |= GNU_PROPERTY_X86_FEATURE_1_IBT;
}
- if (ctx.arg.zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
+ if (ctx.arg.zPacPlt && !(hasValidPauthAbiCoreInfo ||
+ (features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC))) {
warn(toString(f) + ": -z pac-plt: file does not have "
- "GNU_PROPERTY_AARCH64_FEATURE_1_PAC property");
+ "GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no "
+ "valid PAuth core info present for this link job");
features |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC;
}
ctx.arg.andFeatures &= features;
diff --git a/lld/test/ELF/aarch64-feature-pac.s b/lld/test/ELF/aarch64-feature-pac.s
index b85a33216cb5bd..4fd1fd2acea737 100644
--- a/lld/test/ELF/aarch64-feature-pac.s
+++ b/lld/test/ELF/aarch64-feature-pac.s
@@ -82,7 +82,7 @@
# RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe 2>&1 | FileCheck -DFILE=%t2.o --check-prefix WARN %s
-# WARN: warning: [[FILE]]: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property
+# WARN: warning: [[FILE]]: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
# RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s
# RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN2 %s
diff --git a/lld/test/ELF/aarch64-feature-pauth.s b/lld/test/ELF/aarch64-feature-pauth.s
index 699a650d72295a..c11073dba86f24 100644
--- a/lld/test/ELF/aarch64-feature-pauth.s
+++ b/lld/test/ELF/aarch64-feature-pauth.s
@@ -33,13 +33,53 @@
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu no-info.s -o noinfo1.o
# RUN: cp noinfo1.o noinfo2.o
# RUN: not ld.lld -z pauth-report=error noinfo1.o tag1.o noinfo2.o -o /dev/null 2>&1 | FileCheck --check-prefix ERR5 %s
-# RUN: ld.lld -z pauth-report=warning noinfo1.o tag1.o noinfo2.o -o /dev/null 2>&1 | FileCheck --check-prefix WARN %s
+# RUN: ld.lld -z pauth-report=warning noinfo1.o tag1.o noinfo2.o -o /dev/null 2>&1 | FileCheck --check-prefix WARN1 %s
# RUN: ld.lld -z pauth-report=none noinfo1.o tag1.o noinfo2.o --fatal-warnings -o /dev/null
# ERR5: error: noinfo1.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
# ERR5-NEXT: error: noinfo2.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
-# WARN: warning: noinfo1.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
-# WARN-NEXT: warning: noinfo2.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
+# WARN1: warning: noinfo1.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
+# WARN1-NEXT: warning: noinfo2.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu abi-tag-zero.s -o tag-zero.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func2.s -o func2.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o func3.o
+# RUN: ld.lld func3.o --shared -o func3.so
+# RUN: ld.lld tag1.o func2.o func3.so -z pac-plt --shared -o pacplt-nowarn --fatal-warnings
+# RUN: ld.lld tag-zero.o func2.o func3.so -z pac-plt --shared -o pacplt-warn 2>&1 | FileCheck --check-prefix WARN2 %s
+
+# WARN2: warning: tag-zero.o: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
+# WARN2-NEXT: warning: func2.o: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
+
+# RUN: llvm-readelf -d pacplt-nowarn | FileCheck --check-prefix=PACPLTTAG %s
+# RUN: llvm-readelf -d pacplt-warn | FileCheck --check-prefix=PACPLTTAG %s
+
+# PACPLTTAG: 0x0000000070000003 (AARCH64_PAC_PLT)
+
+# RUN: llvm-objdump -d pacplt-nowarn | FileCheck --check-prefix PACPLT -DA=10380 -DB=478 -DC=480 %s
+# RUN: llvm-objdump -d pacplt-warn | FileCheck --check-prefix PACPLT -DA=10390 -DB=488 -DC=490 %s
+
+# PACPLT: Disassembly of section .text:
+# PACPLT: <func2>:
+# PACPLT-NEXT: bl 0x[[A]] <func3@plt>
+# PACPLT-NEXT: ret
+# PACPLT: Disassembly of section .plt:
+# PACPLT: <.plt>:
+# PACPLT-NEXT: stp x16, x30, [sp, #-0x10]!
+# PACPLT-NEXT: adrp x16, 0x30000 <func3+0x30000>
+# PACPLT-NEXT: ldr x17, [x16, #0x[[B]]]
+# PACPLT-NEXT: add x16, x16, #0x[[B]]
+# PACPLT-NEXT: br x17
+# PACPLT-NEXT: nop
+# PACPLT-NEXT: nop
+# PACPLT-NEXT: nop
+# PACPLT: <func3@plt>:
+# PACPLT-NEXT: adrp x16, 0x30000 <func3+0x30000>
+# PACPLT-NEXT: ldr x17, [x16, #0x[[C]]]
+# PACPLT-NEXT: add x16, x16, #0x[[C]]
+# PACPLT-NEXT: autia1716
+# PACPLT-NEXT: br x17
+# PACPLT-NEXT: nop
#--- abi-tag-short.s
@@ -106,6 +146,18 @@
.quad 42 // platform
.quad 2 // version
+#--- abi-tag-zero.s
+
+.section ".note.gnu.property", "a"
+.long 4
+.long 24
+.long 5
+.asciz "GNU"
+.long 0xc0000001
+.long 16
+.quad 0 // platform
+.quad 0 // version
+
#--- no-info.s
## define _start to avoid missing entry warning and use --fatal-warnings to assert no diagnostic
|
@llvm/pr-subscribers-lld Author: Daniil Kovalev (kovdan01) ChangesWhen PAuth core info is present and (platform,version) is not (0,0), Full diff: https://github.com/llvm/llvm-project/pull/112959.diff 3 Files Affected:
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index fb77e67e9fc5ca..c436be6b24e001 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2753,6 +2753,10 @@ static void readSecurityNotes(Ctx &ctx) {
referenceFileName = (*it)->getName();
}
}
+ bool hasValidPauthAbiCoreInfo =
+ (!ctx.aarch64PauthAbiCoreInfo.empty() &&
+ llvm::any_of(ctx.aarch64PauthAbiCoreInfo,
+ [](uint8_t c) { return c != 0; }));
for (ELFFileBase *f : ctx.objectFiles) {
uint32_t features = f->andFeatures;
@@ -2789,9 +2793,11 @@ static void readSecurityNotes(Ctx &ctx) {
"GNU_PROPERTY_X86_FEATURE_1_IBT property");
features |= GNU_PROPERTY_X86_FEATURE_1_IBT;
}
- if (ctx.arg.zPacPlt && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) {
+ if (ctx.arg.zPacPlt && !(hasValidPauthAbiCoreInfo ||
+ (features & GNU_PROPERTY_AARCH64_FEATURE_1_PAC))) {
warn(toString(f) + ": -z pac-plt: file does not have "
- "GNU_PROPERTY_AARCH64_FEATURE_1_PAC property");
+ "GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no "
+ "valid PAuth core info present for this link job");
features |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC;
}
ctx.arg.andFeatures &= features;
diff --git a/lld/test/ELF/aarch64-feature-pac.s b/lld/test/ELF/aarch64-feature-pac.s
index b85a33216cb5bd..4fd1fd2acea737 100644
--- a/lld/test/ELF/aarch64-feature-pac.s
+++ b/lld/test/ELF/aarch64-feature-pac.s
@@ -82,7 +82,7 @@
# RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe 2>&1 | FileCheck -DFILE=%t2.o --check-prefix WARN %s
-# WARN: warning: [[FILE]]: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property
+# WARN: warning: [[FILE]]: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
# RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s
# RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN2 %s
diff --git a/lld/test/ELF/aarch64-feature-pauth.s b/lld/test/ELF/aarch64-feature-pauth.s
index 699a650d72295a..c11073dba86f24 100644
--- a/lld/test/ELF/aarch64-feature-pauth.s
+++ b/lld/test/ELF/aarch64-feature-pauth.s
@@ -33,13 +33,53 @@
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu no-info.s -o noinfo1.o
# RUN: cp noinfo1.o noinfo2.o
# RUN: not ld.lld -z pauth-report=error noinfo1.o tag1.o noinfo2.o -o /dev/null 2>&1 | FileCheck --check-prefix ERR5 %s
-# RUN: ld.lld -z pauth-report=warning noinfo1.o tag1.o noinfo2.o -o /dev/null 2>&1 | FileCheck --check-prefix WARN %s
+# RUN: ld.lld -z pauth-report=warning noinfo1.o tag1.o noinfo2.o -o /dev/null 2>&1 | FileCheck --check-prefix WARN1 %s
# RUN: ld.lld -z pauth-report=none noinfo1.o tag1.o noinfo2.o --fatal-warnings -o /dev/null
# ERR5: error: noinfo1.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
# ERR5-NEXT: error: noinfo2.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
-# WARN: warning: noinfo1.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
-# WARN-NEXT: warning: noinfo2.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
+# WARN1: warning: noinfo1.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
+# WARN1-NEXT: warning: noinfo2.o: -z pauth-report: file does not have AArch64 PAuth core info while 'tag1.o' has one
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu abi-tag-zero.s -o tag-zero.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func2.s -o func2.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o func3.o
+# RUN: ld.lld func3.o --shared -o func3.so
+# RUN: ld.lld tag1.o func2.o func3.so -z pac-plt --shared -o pacplt-nowarn --fatal-warnings
+# RUN: ld.lld tag-zero.o func2.o func3.so -z pac-plt --shared -o pacplt-warn 2>&1 | FileCheck --check-prefix WARN2 %s
+
+# WARN2: warning: tag-zero.o: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
+# WARN2-NEXT: warning: func2.o: -z pac-plt: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_PAC property and no valid PAuth core info present for this link job
+
+# RUN: llvm-readelf -d pacplt-nowarn | FileCheck --check-prefix=PACPLTTAG %s
+# RUN: llvm-readelf -d pacplt-warn | FileCheck --check-prefix=PACPLTTAG %s
+
+# PACPLTTAG: 0x0000000070000003 (AARCH64_PAC_PLT)
+
+# RUN: llvm-objdump -d pacplt-nowarn | FileCheck --check-prefix PACPLT -DA=10380 -DB=478 -DC=480 %s
+# RUN: llvm-objdump -d pacplt-warn | FileCheck --check-prefix PACPLT -DA=10390 -DB=488 -DC=490 %s
+
+# PACPLT: Disassembly of section .text:
+# PACPLT: <func2>:
+# PACPLT-NEXT: bl 0x[[A]] <func3@plt>
+# PACPLT-NEXT: ret
+# PACPLT: Disassembly of section .plt:
+# PACPLT: <.plt>:
+# PACPLT-NEXT: stp x16, x30, [sp, #-0x10]!
+# PACPLT-NEXT: adrp x16, 0x30000 <func3+0x30000>
+# PACPLT-NEXT: ldr x17, [x16, #0x[[B]]]
+# PACPLT-NEXT: add x16, x16, #0x[[B]]
+# PACPLT-NEXT: br x17
+# PACPLT-NEXT: nop
+# PACPLT-NEXT: nop
+# PACPLT-NEXT: nop
+# PACPLT: <func3@plt>:
+# PACPLT-NEXT: adrp x16, 0x30000 <func3+0x30000>
+# PACPLT-NEXT: ldr x17, [x16, #0x[[C]]]
+# PACPLT-NEXT: add x16, x16, #0x[[C]]
+# PACPLT-NEXT: autia1716
+# PACPLT-NEXT: br x17
+# PACPLT-NEXT: nop
#--- abi-tag-short.s
@@ -106,6 +146,18 @@
.quad 42 // platform
.quad 2 // version
+#--- abi-tag-zero.s
+
+.section ".note.gnu.property", "a"
+.long 4
+.long 24
+.long 5
+.asciz "GNU"
+.long 0xc0000001
+.long 16
+.quad 0 // platform
+.quad 0 // version
+
#--- no-info.s
## define _start to avoid missing entry warning and use --fatal-warnings to assert no diagnostic
|
Would be glad to see everyone's feedback on the changes. |
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.
lgtm
Merge activity
|
51235d7
to
ceefe60
Compare
lld/test/ELF/aarch64-feature-pauth.s
Outdated
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func2.s -o func2.o | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o func3.o | ||
# RUN: ld.lld func3.o --shared -o func3.so | ||
# RUN: ld.lld tag1.o func2.o func3.so -z pac-plt --shared -o pacplt-nowarn --fatal-warnings |
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.
excess spaces
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.
Removed in 58b0ffa. Initially added to align with the next RUN line, but I'm OK with deleting the spaces if it's considered not needed.
35d5c86
to
7f1e0fc
Compare
…e info When PAuth core info is present and (platform,version) is not (0,0), treat input files as pac-enabled and do not emit a warning with `-z pac-plt` passed.
With `llvm::any_of(ctx.aarch64PauthAbiCoreInfo, /*...*/)` being true, the byte range is always non-empty.
7f1e0fc
to
58b0ffa
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/4/builds/3472 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/55/builds/3462 Here is the relevant piece of the build log for the reference
|
Both buildbot failures present at the moment look not related to this PR and are probably caused by some CI instabilities:
|
…e info (llvm#112959) When PAuth core info is present and (platform,version) is not (0,0), treat input files as pac-enabled and do not emit a warning with `-z pac-plt` passed.
When PAuth core info is present and (platform,version) is not (0,0),
treat input files as pac-enabled and do not emit a warning with
-z pac-plt
passed.