Skip to content

Commit e3f1c46

Browse files
authored
[PAC][lld] Support -z nopac-plt flag (#132973)
Support `-z nopac-plt` so it's possible to cancel previous `-z pac-plt`.
1 parent 5b36835 commit e3f1c46

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lld/ELF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
15751575
ctx.arg.zNodlopen = hasZOption(args, "nodlopen");
15761576
ctx.arg.zNow = getZFlag(args, "now", "lazy", false);
15771577
ctx.arg.zOrigin = hasZOption(args, "origin");
1578-
ctx.arg.zPacPlt = hasZOption(args, "pac-plt");
1578+
ctx.arg.zPacPlt = getZFlag(args, "pac-plt", "nopac-plt", false);
15791579
ctx.arg.zRelro = getZFlag(args, "relro", "norelro", true);
15801580
ctx.arg.zRetpolineplt = hasZOption(args, "retpolineplt");
15811581
ctx.arg.zRodynamic = hasZOption(args, "rodynamic");

lld/test/ELF/aarch64-feature-pac.s

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88
## We do not add PAC support when the inputs don't have the .note.gnu.property
99
## field.
1010

11-
# RUN: ld.lld %tno.o %t3.o --shared -o %tno.so
12-
# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno.so | FileCheck --check-prefix=NOPAC %s
13-
# RUN: llvm-readelf -x .got.plt %tno.so | FileCheck --check-prefix SOGOTPLT %s
14-
# RUN: llvm-readelf --dynamic-table %tno.so | FileCheck --check-prefix NOPACDYN %s
11+
# RUN: ld.lld %tno.o %t3.o --shared -o %tno1.so
12+
# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno1.so | FileCheck --check-prefix=NOPAC %s
13+
# RUN: llvm-readelf -x .got.plt %tno1.so | FileCheck --check-prefix SOGOTPLT %s
14+
# RUN: llvm-readelf --dynamic-table %tno1.so | FileCheck --check-prefix NOPACDYN %s
15+
16+
# RUN: ld.lld %tno.o %t3.o --shared -o %tno2.so -z pac-plt -znopac-plt
17+
# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.3a --no-show-raw-insn %tno2.so | FileCheck --check-prefix=NOPAC %s
18+
# RUN: llvm-readelf -x .got.plt %tno2.so | FileCheck --check-prefix SOGOTPLT %s
19+
# RUN: llvm-readelf --dynamic-table %tno2.so | FileCheck --check-prefix NOPACDYN %s
1520

1621
# NOPAC: 00000000000102b8 <func2>:
1722
# NOPAC-NEXT: 102b8: bl 0x102f0 <func3@plt>

0 commit comments

Comments
 (0)