[lld] 5a3a9e9 - [ELF][AArch64] Rename --force-bti to -z force-bti and --pac-plt to -z pac-plt
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 09:26:39 PST 2019
Author: Fangrui Song
Date: 2019-12-11T09:26:32-08:00
New Revision: 5a3a9e9927b714e94e1c1b839e17429806272052
URL: https://github.com/llvm/llvm-project/commit/5a3a9e9927b714e94e1c1b839e17429806272052
DIFF: https://github.com/llvm/llvm-project/commit/5a3a9e9927b714e94e1c1b839e17429806272052.diff
LOG: [ELF][AArch64] Rename --force-bti to -z force-bti and --pac-plt to -z pac-plt
Summary:
The original design used --foo but the upstream complained that ELF only
options should be -z foo. See https://sourceware.org/ml/binutils/2019-04/msg00151.html
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=8bf6d176b0a442a8091d338d4af971591d19922c
made the rename.
Our --force-bti and --pac-plt implement the same functionality, so it
seems wise to be consistent with GNU ld.
Reviewed By: peter.smith
Subscribers: emaste, arichardson, kristof.beyls, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71327
Added:
Modified:
lld/ELF/Driver.cpp
lld/ELF/Options.td
lld/docs/ld.lld.1
lld/test/ELF/aarch64-bti-pac-cli-error.s
lld/test/ELF/aarch64-feature-bti.s
lld/test/ELF/aarch64-feature-btipac.s
lld/test/ELF/aarch64-feature-pac.s
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index a0987259d24b..c721e872e12e 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -354,9 +354,9 @@ static void checkOptions() {
if (config->emachine != EM_AARCH64) {
if (config->pacPlt)
- error("--pac-plt only supported on AArch64");
+ error("-z pac-plt only supported on AArch64");
if (config->forceBTI)
- error("--force-bti only supported on AArch64");
+ error("-z force-bti only supported on AArch64");
}
}
@@ -412,17 +412,18 @@ static GnuStackKind getZGnuStack(opt::InputArgList &args) {
static bool isKnownZFlag(StringRef s) {
return s == "combreloc" || s == "copyreloc" || s == "defs" ||
- s == "execstack" || s == "global" || s == "hazardplt" ||
- s == "ifunc-noplt" || s == "initfirst" || s == "interpose" ||
- s == "keep-text-section-prefix" || s == "lazy" || s == "muldefs" ||
- s == "separate-code" || s == "separate-loadable-segments" ||
- s == "nocombreloc" || s == "nocopyreloc" || s == "nodefaultlib" ||
- s == "nodelete" || s == "nodlopen" || s == "noexecstack" ||
- s == "nognustack" ||
+ s == "execstack" || s == "force-bti" || s == "global" ||
+ s == "hazardplt" || s == "ifunc-noplt" || s == "initfirst" ||
+ s == "interpose" || s == "keep-text-section-prefix" || s == "lazy" ||
+ s == "muldefs" || s == "separate-code" ||
+ s == "separate-loadable-segments" || s == "nocombreloc" ||
+ s == "nocopyreloc" || s == "nodefaultlib" || s == "nodelete" ||
+ s == "nodlopen" || s == "noexecstack" || s == "nognustack" ||
s == "nokeep-text-section-prefix" || s == "norelro" ||
s == "noseparate-code" || s == "notext" || s == "now" ||
- s == "origin" || s == "relro" || s == "retpolineplt" ||
- s == "rodynamic" || s == "text" || s == "undefs" || s == "wxneeded" ||
+ s == "origin" || s == "pac-plt" || s == "relro" ||
+ s == "retpolineplt" || s == "rodynamic" || s == "text" ||
+ s == "undefs" || s == "wxneeded" ||
s.startswith("common-page-size=") || s.startswith("max-page-size=") ||
s.startswith("stack-size=");
}
@@ -878,7 +879,7 @@ static void readConfigs(opt::InputArgList &args) {
config->fini = args.getLastArgValue(OPT_fini, "_fini");
config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419);
config->fixCortexA8 = args.hasArg(OPT_fix_cortex_a8);
- config->forceBTI = args.hasArg(OPT_force_bti);
+ config->forceBTI = hasZOption(args, "force-bti");
config->requireCET = args.hasArg(OPT_require_cet);
config->gcSections = args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, false);
config->gnuUnique = args.hasFlag(OPT_gnu_unique, OPT_no_gnu_unique, true);
@@ -917,7 +918,7 @@ static void readConfigs(opt::InputArgList &args) {
config->optimize = args::getInteger(args, OPT_O, 1);
config->orphanHandling = getOrphanHandling(args);
config->outputFile = args.getLastArgValue(OPT_o);
- config->pacPlt = args.hasArg(OPT_pac_plt);
+ config->pacPlt = hasZOption(args, "pac-plt");
config->pie = args.hasFlag(OPT_pie, OPT_no_pie, false);
config->printIcfSections =
args.hasFlag(OPT_print_icf_sections, OPT_no_print_icf_sections, false);
@@ -1704,7 +1705,7 @@ template <class ELFT> static uint32_t getAndFeatures() {
for (InputFile *f : objectFiles) {
uint32_t features = cast<ObjFile<ELFT>>(f)->andFeatures;
if (config->forceBTI && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
- warn(toString(f) + ": --force-bti: file does not have BTI property");
+ warn(toString(f) + ": -z force-bti: file does not have BTI property");
features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
} else if (!features && config->requireCET)
error(toString(f) + ": --require-cet: file is not compatible with CET");
diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td
index 101fc438f703..b86a670915c1 100644
--- a/lld/ELF/Options.td
+++ b/lld/ELF/Options.td
@@ -180,9 +180,6 @@ def fix_cortex_a8: F<"fix-cortex-a8">,
// is not complete.
def require_cet: F<"require-cet">;
-def force_bti: F<"force-bti">,
- HelpText<"Force enable AArch64 BTI in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property">;
-
defm format: Eq<"format", "Change the input format of the inputs following this option">,
MetaVarName<"[default,elf,binary]">;
@@ -281,9 +278,6 @@ defm pack_dyn_relocs:
Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
MetaVarName<"[none,android,relr,android+relr]">;
-def pac_plt: F<"pac-plt">,
- HelpText<"AArch64 only, use pointer authentication in PLT">;
-
defm use_android_relr_tags: B<"use-android-relr-tags",
"Use SHT_ANDROID_RELR / DT_ANDROID_RELR* tags instead of SHT_RELR / DT_RELR*",
"Use SHT_RELR / DT_RELR* tags (default)">;
diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1
index 5c558a4bcc7a..7769cd03d503 100644
--- a/lld/docs/ld.lld.1
+++ b/lld/docs/ld.lld.1
@@ -191,8 +191,6 @@ Set the
field to the specified value.
.It Fl -fini Ns = Ns Ar symbol
Specify a finalizer function.
-.It Fl -force-bti
-Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
.It Fl -format Ns = Ns Ar input-format , Fl b Ar input-format
Specify the format of the inputs following this option.
.Ar input-format
@@ -401,8 +399,6 @@ If
.Fl -use-android-relr-tags
is specified, use SHT_ANDROID_RELR instead of SHT_RELR.
.Pp
-.It Fl -pac-plt
-AArch64 only, use pointer authentication in PLT.
.It Fl -pic-veneer
Always generate position independent thunks.
.It Fl -pie , Fl -pic-executable
@@ -599,6 +595,9 @@ Stack permissions are recorded in the
.Dv PT_GNU_STACK
segment.
.Pp
+.It Cm force-bti
+Force enable AArch64 BTI instruction in PLT, warn if Input ELF file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property.
+.Pp
.It Cm global
Sets the
.Dv DF_1_GLOBAL flag in the
@@ -688,6 +687,9 @@ flag to indicate that the object requires
$ORIGIN
processing.
.Pp
+.It Cm pac-plt
+AArch64 only, use pointer authentication in PLT.
+.Pp
.It Cm retpolineplt
Emit retpoline format PLT entries as a mitigation for CVE-2017-5715.
.Pp
diff --git a/lld/test/ELF/aarch64-bti-pac-cli-error.s b/lld/test/ELF/aarch64-bti-pac-cli-error.s
index 1ce7dde19dbb..f3ad7d14bbdc 100644
--- a/lld/test/ELF/aarch64-bti-pac-cli-error.s
+++ b/lld/test/ELF/aarch64-bti-pac-cli-error.s
@@ -1,12 +1,12 @@
# REQUIRES: x86
# RUN: llvm-mc --triple=x86_64-pc-linux --filetype=obj -o %t.o %s
-# RUN: not ld.lld --pac-plt --force-bti %t.o -o %t 2>&1 | FileCheck %s
+# RUN: not ld.lld -z pac-plt -z force-bti %t.o -o %t 2>&1 | FileCheck %s
#
-## Check that we error if --pac-plt and --force-bti are used when target is not
+## Check that we error if -z pac-plt and -z force-bti are used when target is not
## aarch64
-# CHECK: error: --pac-plt only supported on AArch64
-# CHECK-NEXT: error: --force-bti only supported on AArch64
+# CHECK: error: -z pac-plt only supported on AArch64
+# CHECK-NEXT: error: -z force-bti only supported on AArch64
.globl start
start: ret
diff --git a/lld/test/ELF/aarch64-feature-bti.s b/lld/test/ELF/aarch64-feature-bti.s
index 0fa1cf83727b..cbaf17b4d960 100644
--- a/lld/test/ELF/aarch64-feature-bti.s
+++ b/lld/test/ELF/aarch64-feature-bti.s
@@ -169,12 +169,12 @@
# NOEX-NEXT: add x16, x16, #1032
# NOEX-NEXT: br x17
-## Force BTI entries with the --force-bti command line option. Expect a warning
+## Force BTI entries with the -z force-bti command line option. Expect a warning
## from the file without the .note.gnu.property.
-# RUN: ld.lld %t.o %t2.o --force-bti %t.so -o %tforcebti.exe 2>&1 | FileCheck --check-prefix=FORCE-WARN %s
+# RUN: ld.lld %t.o %t2.o -z force-bti %t.so -o %tforcebti.exe 2>&1 | FileCheck --check-prefix=FORCE-WARN %s
-# FORCE-WARN: aarch64-feature-bti.s.tmp2.o: --force-bti: file does not have BTI property
+# FORCE-WARN: aarch64-feature-bti.s.tmp2.o: -z force-bti: file does not have BTI property
# RUN: llvm-readelf -n %tforcebti.exe | FileCheck --check-prefix=BTIPROP %s
diff --git a/lld/test/ELF/aarch64-feature-btipac.s b/lld/test/ELF/aarch64-feature-btipac.s
index 30e00b2dbbd8..17f8487f4d3f 100644
--- a/lld/test/ELF/aarch64-feature-btipac.s
+++ b/lld/test/ELF/aarch64-feature-btipac.s
@@ -109,13 +109,13 @@
# NODYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)
# NODYN-NOT: 0x0000000070000003 (AARCH64_PAC_PLT)
-## Check that combination of --pac-plt and --force-bti warns for the file that
+## Check that combination of -z pac-plt and -z force-bti warns for the file that
## doesn't contain the BTI property, but generates PAC and BTI PLT sequences.
-## The --pac-plt doesn't warn as it is not required for correctness.
+## The -z pac-plt doesn't warn as it is not required for correctness.
-# RUN: ld.lld %t.o %t3.o %t.so --pac-plt --force-bti -o %t.exe 2>&1 | FileCheck --check-prefix=FORCE-WARN %s
+# RUN: ld.lld %t.o %t3.o %t.so -z pac-plt -z force-bti -o %t.exe 2>&1 | FileCheck --check-prefix=FORCE-WARN %s
-# FORCE-WARN: aarch64-feature-btipac.s.tmp3.o: --force-bti: file does not have BTI property
+# FORCE-WARN: aarch64-feature-btipac.s.tmp3.o: -z force-bti: file does not have BTI property
# RUN: llvm-readelf -n %t.exe | FileCheck --check-prefix=BTIPACPROP %s
# RUN: llvm-objdump -d -mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix BTIPACEX %s
diff --git a/lld/test/ELF/aarch64-feature-pac.s b/lld/test/ELF/aarch64-feature-pac.s
index 7a4f8ee64ffd..41c6cb69742a 100644
--- a/lld/test/ELF/aarch64-feature-pac.s
+++ b/lld/test/ELF/aarch64-feature-pac.s
@@ -80,12 +80,12 @@
# PACDYN-NOT: 0x0000000070000001 (AARCH64_BTI_PLT)
# PACDYN: 0x0000000070000003 (AARCH64_PAC_PLT)
-## Turn on PAC entries with the --pac-plt command line option. There are no
+## Turn on PAC entries with the -z pac-plt command line option. There are no
## warnings in this case as the choice to use PAC in PLT entries is orthogonal
## to the choice of using PAC in relocatable objects. The presence of the PAC
## .note.gnu.property is an indication of preference by the relocatable object.
-# RUN: ld.lld %t.o %t2.o --pac-plt %t.so -o %tpacplt.exe
+# RUN: ld.lld %t.o %t2.o -z pac-plt %t.so -o %tpacplt.exe
# RUN: llvm-readelf -n %tpacplt.exe | FileCheck --check-prefix=PACPROP %s
# RUN: llvm-readelf --dynamic-table %tpacplt.exe | FileCheck --check-prefix PACDYN %s
# RUN: llvm-objdump -d -mattr=+v8.3a --no-show-raw-insn %tpacplt.exe | FileCheck --check-prefix PACPLT %s
More information about the llvm-commits
mailing list