[lld] r324271 - Replace ApplyDynamicRelocs with WriteAddends.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 12:55:46 PST 2018


Author: rafael
Date: Mon Feb  5 12:55:46 2018
New Revision: 324271

URL: http://llvm.org/viewvc/llvm-project?rev=324271&view=rev
Log:
Replace ApplyDynamicRelocs with WriteAddends.

The difference is that WriteAddends also takes IsRela into
consideration.

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/SyntheticSections.cpp

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=324271&r1=324270&r2=324271&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Mon Feb  5 12:55:46 2018
@@ -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;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=324271&r1=324270&r2=324271&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Feb  5 12:55:46 2018
@@ -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 c
   initLLVM(Args);
   createFiles(Args);
   inferMachineType();
-  setConfigs();
+  setConfigs(Args);
   checkOptions(Args);
   if (errorCount())
     return;
@@ -597,8 +597,6 @@ static int parseInt(StringRef S, opt::Ar
 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::Inpu
 // 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.

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=324271&r1=324270&r2=324271&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Mon Feb  5 12:55:46 2018
@@ -1211,7 +1211,7 @@ void RelocationBaseSection::addReloc(uin
   // 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});
 }




More information about the llvm-commits mailing list