diff options
-rw-r--r-- | lld/ELF/Config.h | 2 | ||||
-rw-r--r-- | lld/ELF/Driver.cpp | 11 | ||||
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 673300dfd21..cedc27c410b 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -106,7 +106,6 @@ struct Configuration { std::vector<uint8_t> BuildIdVector; bool AllowMultipleDefinition; bool AndroidPackDynRelocs = false; - bool ApplyDynamicRelocs; bool ARMHasBlx = false; bool ARMHasMovtMovw = false; bool ARMJ1J2BranchEncoding = false; @@ -154,6 +153,7 @@ struct Configuration { bool Verbose; bool WarnCommon; bool WarnMissingEntry; + bool WriteAddends; bool ZCombreloc; bool ZExecstack; bool ZNocopyreloc; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 630465e99a0..791158eaa6d 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -66,7 +66,7 @@ using namespace lld::elf; Configuration *elf::Config; LinkerDriver *elf::Driver; -static void setConfigs(); +static void setConfigs(opt::InputArgList &Args); bool elf::link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Error) { @@ -375,7 +375,7 @@ void LinkerDriver::main(ArrayRef<const char *> ArgsArr, bool CanExitEarly) { initLLVM(Args); createFiles(Args); inferMachineType(); - setConfigs(); + setConfigs(Args); checkOptions(Args); if (errorCount()) return; @@ -597,8 +597,6 @@ static int parseInt(StringRef S, opt::Arg *Arg) { void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition) || hasZOption(Args, "muldefs"); - Config->ApplyDynamicRelocs = Args.hasFlag(OPT_apply_dynamic_relocs, - OPT_no_apply_dynamic_relocs, false); Config->AuxiliaryList = args::getStrings(Args, OPT_auxiliary); Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic); Config->BsymbolicFunctions = Args.hasArg(OPT_Bsymbolic_functions); @@ -803,7 +801,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { // command line options, but computed based on other Config values. // This function initialize such members. See Config.h for the details // of these values. -static void setConfigs() { +static void setConfigs(opt::InputArgList &Args) { ELFKind Kind = Config->EKind; uint16_t Machine = Config->EMachine; @@ -821,6 +819,9 @@ static void setConfigs() { (Config->Is64 || IsX32 || Machine == EM_PPC) && Machine != EM_MIPS; Config->Pic = Config->Pie || Config->Shared; Config->Wordsize = Config->Is64 ? 8 : 4; + Config->WriteAddends = Args.hasFlag(OPT_apply_dynamic_relocs, + OPT_no_apply_dynamic_relocs, false) || + !Config->IsRela; } // Returns a value of "-format" option. diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 722705b348d..17341f370dc 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1211,7 +1211,7 @@ void RelocationBaseSection::addReloc(uint32_t DynType, // relocations for compatibility with GNU Linkers. There is some system // software such as the Bionic dynamic linker that uses the addend prior // to dynamic relocation resolution. - if ((!Config->IsRela || Config->ApplyDynamicRelocs) && UseSymVA) + if (Config->WriteAddends && UseSymVA) InputSec->Relocations.push_back({Expr, Type, OffsetInSec, Addend, Sym}); addReloc({DynType, InputSec, OffsetInSec, UseSymVA, Sym, Addend}); } |