Skip to content

[PAC][lld] Support -z nopac-plt flag #132973

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

Merged
merged 1 commit into from
Mar 28, 2025
Merged

Conversation

kovdan01
Copy link
Contributor

Support -z nopac-plt so it's possible to cancel previous -z pac-plt.

Support `-z nopac-plt` so it's possible to cancel previous `-z pac-plt`.
@kovdan01 kovdan01 requested review from asl, MaskRay and smithp35 March 25, 2025 18:44
@kovdan01 kovdan01 self-assigned this Mar 25, 2025
@kovdan01 kovdan01 moved this to In Progress in Pointer Authentication Tasks Mar 25, 2025
@kovdan01 kovdan01 marked this pull request as ready for review March 25, 2025 18:46
@llvmbot
Copy link
Member

llvmbot commented Mar 25, 2025

@llvm/pr-subscribers-lld-elf

@llvm/pr-subscribers-lld

Author: Daniil Kovalev (kovdan01)

Changes

Support -z nopac-plt so it's possible to cancel previous -z pac-plt.


Full diff: https://github.com/llvm/llvm-project/pull/132973.diff

2 Files Affected:

  • (modified) lld/ELF/Driver.cpp (+1-1)
  • (modified) lld/test/ELF/aarch64-feature-pac.s (+9-4)
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 3e7e05746483a..0f862cab5d026 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1566,7 +1566,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
   ctx.arg.zNodlopen = hasZOption(args, "nodlopen");
   ctx.arg.zNow = getZFlag(args, "now", "lazy", false);
   ctx.arg.zOrigin = hasZOption(args, "origin");
-  ctx.arg.zPacPlt = hasZOption(args, "pac-plt");
+  ctx.arg.zPacPlt = getZFlag(args, "pac-plt", "nopac-plt", false);
   ctx.arg.zRelro = getZFlag(args, "relro", "norelro", true);
   ctx.arg.zRetpolineplt = hasZOption(args, "retpolineplt");
   ctx.arg.zRodynamic = hasZOption(args, "rodynamic");
diff --git a/lld/test/ELF/aarch64-feature-pac.s b/lld/test/ELF/aarch64-feature-pac.s
index 4fd1fd2acea73..3a1032647f7c2 100644
--- a/lld/test/ELF/aarch64-feature-pac.s
+++ b/lld/test/ELF/aarch64-feature-pac.s
@@ -8,10 +8,15 @@
 ## We do not add PAC support when the inputs don't have the .note.gnu.property
 ## field.
 
-# RUN: ld.lld %tno.o %t3.o --shared -o %tno.so
-# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno.so | FileCheck --check-prefix=NOPAC %s
-# RUN: llvm-readelf -x .got.plt %tno.so | FileCheck --check-prefix SOGOTPLT %s
-# RUN: llvm-readelf --dynamic-table %tno.so | FileCheck --check-prefix NOPACDYN %s
+# RUN: ld.lld %tno.o %t3.o --shared -o %tno1.so
+# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno1.so | FileCheck --check-prefix=NOPAC %s
+# RUN: llvm-readelf -x .got.plt %tno1.so | FileCheck --check-prefix SOGOTPLT %s
+# RUN: llvm-readelf --dynamic-table %tno1.so | FileCheck --check-prefix NOPACDYN %s
+
+# RUN: ld.lld %tno.o %t3.o --shared -o %tno2.so -z pac-plt -znopac-plt
+# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno2.so | FileCheck --check-prefix=NOPAC %s
+# RUN: llvm-readelf -x .got.plt %tno2.so | FileCheck --check-prefix SOGOTPLT %s
+# RUN: llvm-readelf --dynamic-table %tno2.so | FileCheck --check-prefix NOPACDYN %s
 
 # NOPAC: 00000000000102b8 <func2>:
 # NOPAC-NEXT:    102b8: bl      0x102f0 <func3@plt>

@kovdan01 kovdan01 merged commit e3f1c46 into llvm:main Mar 28, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Pointer Authentication Tasks Mar 28, 2025
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 28, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building lld at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/15065

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: lang/cpp/break-on-initializers/TestBreakOnCPP11Initializers.py (758 of 2112)
PASS: lldb-api :: lang/cpp/bitfields/TestCppBitfields.py (759 of 2112)
PASS: lldb-api :: lang/c/vla/TestVLA.py (760 of 2112)
PASS: lldb-api :: lang/cpp/class-loading-via-member-typedef/TestClassLoadingViaMemberTypedef.py (761 of 2112)
PASS: lldb-api :: lang/cpp/class-template-non-type-parameter-pack/TestClassTemplateNonTypeParameterPack.py (762 of 2112)
PASS: lldb-api :: lang/cpp/call-function/TestCallCPPFunction.py (763 of 2112)
PASS: lldb-api :: lang/cpp/chained-calls/TestCppChainedCalls.py (764 of 2112)
PASS: lldb-api :: lang/cpp/class-template-type-parameter-pack/TestClassTemplateTypeParameterPack.py (765 of 2112)
PASS: lldb-api :: lang/cpp/char8_t/TestCxxChar8_t.py (766 of 2112)
PASS: lldb-api :: lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py (767 of 2112)
FAIL: lldb-api :: lang/cpp/char1632_t/TestChar1632T.py (768 of 2112)
******************** TEST 'lldb-api :: lang/cpp/char1632_t/TestChar1632T.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/lang/cpp/char1632_t -p TestChar1632T.py
--
Exit Code: -11

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision e3f1c464f7283e79f566b33b87258ee55f77e139)
  clang revision e3f1c464f7283e79f566b33b87258ee55f77e139
  llvm revision e3f1c464f7283e79f566b33b87258ee55f77e139
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_dsym (TestChar1632T.Char1632TestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_dwarf (TestChar1632T.Char1632TestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_dwo (TestChar1632T.Char1632TestCase)
----------------------------------------------------------------------
Ran 3 tests in 0.978s

OK (skipped=1)

--

********************
PASS: lldb-api :: lang/cpp/class-template-parameter-pack/TestTemplatePackArgs.py (769 of 2112)
PASS: lldb-api :: lang/cpp/complete-type-check/TestCppIsTypeComplete.py (770 of 2112)
PASS: lldb-api :: lang/cpp/const_static_integral_member_int128/TestConstStaticIntegralMemberInt128.py (771 of 2112)
PASS: lldb-api :: lang/cpp/class_static/TestStaticVariables.py (772 of 2112)
PASS: lldb-api :: lang/cpp/class_types/TestClassTypesDisassembly.py (773 of 2112)
PASS: lldb-api :: lang/cpp/const_this/TestConstThis.py (774 of 2112)
PASS: lldb-api :: lang/cpp/constructors/TestCppConstructors.py (775 of 2112)
PASS: lldb-api :: lang/cpp/crtp/TestCppCRTP.py (776 of 2112)
PASS: lldb-api :: lang/cpp/covariant-return-types/TestCovariantReturnTypes.py (777 of 2112)
PASS: lldb-api :: lang/cpp/default-template-args/TestDefaultTemplateArgs.py (778 of 2112)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants