diff options
-rw-r--r-- | lld/ELF/Config.h | 2 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 6325b1b1b48..1e3bec762e1 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -145,7 +145,7 @@ struct Configuration { bool ZWxneeded; DiscardPolicy Discard; SortSectionPolicy SortSection; - StripPolicy Strip = StripPolicy::None; + StripPolicy Strip; UnresolvedPolicy UnresolvedSymbols; Target2Policy Target2 = Target2Policy::GotRel; BuildIdKind BuildId = BuildIdKind::None; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 037b404b8ba..c1dbaf6fa60 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -437,6 +437,7 @@ static bool isOutputFormatBinary(opt::InputArgList &Args) { static DiscardPolicy getDiscardOption(opt::InputArgList &Args) { if (Args.hasArg(OPT_relocatable)) return DiscardPolicy::None; + auto *Arg = Args.getLastArg(OPT_discard_all, OPT_discard_locals, OPT_discard_none); if (!Arg) @@ -456,12 +457,15 @@ static StringRef getDynamicLinkerOption(opt::InputArgList &Args) { } static StripPolicy getStripOption(opt::InputArgList &Args) { - if (auto *Arg = Args.getLastArg(OPT_strip_all, OPT_strip_debug)) { - if (Arg->getOption().getID() == OPT_strip_all) - return StripPolicy::All; - return StripPolicy::Debug; - } - return StripPolicy::None; + if (Args.hasArg(OPT_relocatable)) + return StripPolicy::None; + + auto *Arg = Args.getLastArg(OPT_strip_all, OPT_strip_debug); + if (!Arg) + return StripPolicy::None; + if (Arg->getOption().getID() == OPT_strip_all) + return StripPolicy::All; + return StripPolicy::Debug; } static uint64_t parseSectionAddress(StringRef S, opt::Arg *Arg) { @@ -575,6 +579,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->SingleRoRx = Args.hasArg(OPT_no_rosegment); Config->SoName = getString(Args, OPT_soname); Config->SortSection = getSortKind(Args); + Config->Strip = getStripOption(Args); Config->Sysroot = getString(Args, OPT_sysroot); Config->Target1Rel = getArg(Args, OPT_target1_rel, OPT_target1_abs, false); Config->Target2 = getTarget2Option(Args); @@ -620,9 +625,6 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { if (Config->Omagic) Config->ZRelro = false; - if (!Config->Relocatable) - Config->Strip = getStripOption(Args); - std::tie(Config->SysvHash, Config->GnuHash) = getHashStyle(Args); // Parse --build-id or --build-id=<style>. |