[PATCH] D101513: [lld-macho] Make everything PIE by default
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 29 12:11:40 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e115da5df47: [lld-macho] Make everything PIE by default (authored by int3).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101513/new/
https://reviews.llvm.org/D101513
Files:
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/x86-64-reloc-unsigned.s
Index: lld/test/MachO/x86-64-reloc-unsigned.s
===================================================================
--- lld/test/MachO/x86-64-reloc-unsigned.s
+++ lld/test/MachO/x86-64-reloc-unsigned.s
@@ -7,16 +7,7 @@
# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
# RUN: %lld -pie -no_pie -o %t-no-pie %t.o
# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s --check-prefix=NO-PIE
-# RUN: %lld -no_pie -pie -o %t-no-pie %t.o
-# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s --check-prefix=NO-PIE
-
-# RUN: %lld -platform_version macos 10.6.0 11.0 -o %t-pie %t.o
-# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
-# RUN: %lld -platform_version macos 10.5.0 11.0 -o %t-no-pie %t.o
-# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s --check-prefix=NO-PIE
-# RUN: %lld -platform_version ios-simulator 11.0.0 14.2 -o %t-pie %t.o
-# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
-# RUN: %lld -platform_version driverkit 19.0 20.0 -o %t-pie %t.o
+# RUN: %lld -no_pie -pie -o %t-pie %t.o
# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
# CHECK: Contents of section __DATA,foo:
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -370,10 +370,10 @@
def grp_main : OptionGroup<"main">, HelpText<"MAIN EXECUTABLE">;
def pie : Flag<["-"], "pie">,
- HelpText<"Build a position independent executable (default for macOS 10.7 and later)">,
+ HelpText<"Build a position independent executable (default)">,
Group<grp_main>;
def no_pie : Flag<["-"], "no_pie">,
- HelpText<"Do not build a position independent executable (default for macOS 10.6 and earlier)">,
+ HelpText<"Do not build a position independent executable">,
Group<grp_main>;
def pagezero_size : Separate<["-"], "pagezero_size">,
MetaVarName<"<size>">,
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -697,29 +697,6 @@
return getenv("LLD_REPRODUCE");
}
-static bool isPie(InputArgList &args) {
- if (config->outputType != MH_EXECUTE || args.hasArg(OPT_no_pie))
- return false;
- if (config->arch() == AK_arm64 || config->arch() == AK_arm64e ||
- config->arch() == AK_arm64_32)
- return true;
-
- // TODO: add logic here as we support more archs. E.g. i386 should default
- // to PIE from 10.7
- assert(config->arch() == AK_x86_64 || config->arch() == AK_x86_64h ||
- config->arch() == AK_arm64_32);
-
- PlatformKind kind = config->platformInfo.target.Platform;
- if (kind == PlatformKind::macOS &&
- config->platformInfo.minimum >= VersionTuple(10, 6))
- return true;
-
- if (kind == PlatformKind::iOSSimulator || kind == PlatformKind::driverKit)
- return true;
-
- return args.hasArg(OPT_pie);
-}
-
static void parseClangOption(StringRef opt, const Twine &msg) {
std::string err;
raw_string_ostream os(err);
@@ -1095,7 +1072,9 @@
createFiles(args);
config->isPic = config->outputType == MH_DYLIB ||
- config->outputType == MH_BUNDLE || isPie(args);
+ config->outputType == MH_BUNDLE ||
+ (config->outputType == MH_EXECUTE &&
+ args.hasFlag(OPT_pie, OPT_no_pie, true));
// Now that all dylibs have been loaded, search for those that should be
// re-exported.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101513.341603.patch
Type: text/x-patch
Size: 3557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210429/7d656270/attachment.bin>
More information about the llvm-commits
mailing list