diff options
-rw-r--r-- | lld/ELF/Config.h | 4 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 22 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 99999e21b7e..6325b1b1b48 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -109,7 +109,7 @@ struct Configuration { bool FatalWarnings; bool GcSections; bool GdbIndex; - bool GnuHash = false; + bool GnuHash; bool ICF; bool Mips64EL = false; bool MipsN32Abi = false; @@ -127,7 +127,7 @@ struct Configuration { bool SingleRoRx; bool Shared; bool Static = false; - bool SysvHash = true; + bool SysvHash; bool Target1Rel; bool Threads; bool Trace; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 0d83f9fbd9f..037b404b8ba 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -502,6 +502,17 @@ static SortSectionPolicy getSortKind(opt::InputArgList &Args) { return SortSectionPolicy::Default; } +static std::pair<bool, bool> getHashStyle(opt::InputArgList &Args) { + StringRef S = getString(Args, OPT_hash_style, "sysv"); + if (S == "sysv") + return {true, false}; + if (S == "gnu") + return {false, true}; + if (S != "both") + error("unknown -hash-style: " + S); + return {true, true}; +} + static std::vector<StringRef> getLines(MemoryBufferRef MB) { SmallVector<StringRef, 0> Arr; MB.getBuffer().split(Arr, '\n'); @@ -612,16 +623,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { if (!Config->Relocatable) Config->Strip = getStripOption(Args); - if (auto *Arg = Args.getLastArg(OPT_hash_style)) { - StringRef S = Arg->getValue(); - if (S == "gnu") { - Config->GnuHash = true; - Config->SysvHash = false; - } else if (S == "both") { - Config->GnuHash = true; - } else if (S != "sysv") - error("unknown hash style: " + S); - } + std::tie(Config->SysvHash, Config->GnuHash) = getHashStyle(Args); // Parse --build-id or --build-id=<style>. if (Args.hasArg(OPT_build_id)) |