[lld] [PAC][lld] Support `-z nopac-plt` flag (PR #132973)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 25 11:47:16 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld
Author: Daniil Kovalev (kovdan01)
<details>
<summary>Changes</summary>
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
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 at plt>
``````````
</details>
https://github.com/llvm/llvm-project/pull/132973
More information about the llvm-commits
mailing list