[lld] a7e14e2 - [ELF] Replace config-> with ctx.arg.

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 22:54:42 PDT 2024


Author: Fangrui Song
Date: 2024-09-21T22:54:37-07:00
New Revision: a7e14e24876a9f6465a719c759dad5e4905417cd

URL: https://github.com/llvm/llvm-project/commit/a7e14e24876a9f6465a719c759dad5e4905417cd
DIFF: https://github.com/llvm/llvm-project/commit/a7e14e24876a9f6465a719c759dad5e4905417cd.diff

LOG: [ELF] Replace config-> with ctx.arg.

Added: 
    

Modified: 
    lld/ELF/DWARF.cpp
    lld/ELF/DriverUtils.cpp
    lld/ELF/EhFrame.cpp
    lld/ELF/LTO.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp
index 517d26810a3785..133e66baabe2de 100644
--- a/lld/ELF/DWARF.cpp
+++ b/lld/ELF/DWARF.cpp
@@ -112,7 +112,7 @@ LLDDwarfObj<ELFT>::findAux(const InputSectionBase &sec, uint64_t pos,
   const RelTy &rel = *it;
 
   const ObjFile<ELFT> *file = sec.getFile<ELFT>();
-  uint32_t symIndex = rel.getSymbol(config->isMips64EL);
+  uint32_t symIndex = rel.getSymbol(ctx.arg.isMips64EL);
   const typename ELFT::Sym &sym = file->template getELFSyms<ELFT>()[symIndex];
   uint32_t secIndex = file->getSectionIndex(sym);
 

diff  --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index ac74604408152d..f001f2c994e4cb 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -137,7 +137,7 @@ opt::InputArgList ELFOptTable::parse(ArrayRef<const char *> argv) {
 
 void elf::printHelp() {
   ELFOptTable().printHelp(
-      lld::outs(), (config->progName + " [options] file...").str().c_str(),
+      lld::outs(), (ctx.arg.progName + " [options] file...").str().c_str(),
       "lld", false /*ShowHidden*/, true /*ShowAllAliases*/);
   lld::outs() << "\n";
 
@@ -145,7 +145,7 @@ void elf::printHelp() {
   // targets:.* elf/ in a message for the --help option. If it doesn't match,
   // the scripts assume that the linker doesn't support very basic features
   // such as shared libraries. Therefore, we need to print out at least "elf".
-  lld::outs() << config->progName << ": supported targets: elf\n";
+  lld::outs() << ctx.arg.progName << ": supported targets: elf\n";
 }
 
 static std::string rewritePath(StringRef s) {
@@ -214,7 +214,7 @@ static std::optional<std::string> findFile(StringRef path1,
                                            const Twine &path2) {
   SmallString<128> s;
   if (path1.starts_with("="))
-    path::append(s, config->sysroot, path1.substr(1), path2);
+    path::append(s, ctx.arg.sysroot, path1.substr(1), path2);
   else
     path::append(s, path1, path2);
 
@@ -224,7 +224,7 @@ static std::optional<std::string> findFile(StringRef path1,
 }
 
 std::optional<std::string> elf::findFromSearchPaths(StringRef path) {
-  for (StringRef dir : config->searchPaths)
+  for (StringRef dir : ctx.arg.searchPaths)
     if (std::optional<std::string> s = findFile(dir, path))
       return s;
   return std::nullopt;
@@ -233,8 +233,8 @@ std::optional<std::string> elf::findFromSearchPaths(StringRef path) {
 // This is for -l<basename>. We'll look for lib<basename>.so or lib<basename>.a from
 // search paths.
 std::optional<std::string> elf::searchLibraryBaseName(StringRef name) {
-  for (StringRef dir : config->searchPaths) {
-    if (!config->isStatic)
+  for (StringRef dir : ctx.arg.searchPaths) {
+    if (!ctx.arg.isStatic)
       if (std::optional<std::string> s = findFile(dir, "lib" + name + ".so"))
         return s;
     if (std::optional<std::string> s = findFile(dir, "lib" + name + ".a"))

diff  --git a/lld/ELF/EhFrame.cpp b/lld/ELF/EhFrame.cpp
index db58c549007b88..efedbd35d47ccf 100644
--- a/lld/ELF/EhFrame.cpp
+++ b/lld/ELF/EhFrame.cpp
@@ -101,7 +101,7 @@ static size_t getAugPSize(unsigned enc) {
   switch (enc & 0x0f) {
   case DW_EH_PE_absptr:
   case DW_EH_PE_signed:
-    return config->wordsize;
+    return ctx.arg.wordsize;
   case DW_EH_PE_udata2:
   case DW_EH_PE_sdata2:
     return 2;

diff  --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 6f5c320779e805..1dca824554bf36 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -214,9 +214,9 @@ BitcodeCompiler::~BitcodeCompiler() = default;
 
 void BitcodeCompiler::add(BitcodeFile &f) {
   lto::InputFile &obj = *f.obj;
-  bool isExec = !config->shared && !config->relocatable;
+  bool isExec = !ctx.arg.shared && !ctx.arg.relocatable;
 
-  if (config->thinLTOEmitIndexFiles)
+  if (ctx.arg.thinLTOEmitIndexFiles)
     thinIndices.insert(obj.getName());
 
   ArrayRef<Symbol *> syms = f.getSymbols();
@@ -244,7 +244,7 @@ void BitcodeCompiler::add(BitcodeFile &f) {
     // 4) Symbols that are defined in bitcode files and used for dynamic
     //    linking.
     // 5) Symbols that will be referenced after linker wrapping is performed.
-    r.VisibleToRegularObj = config->relocatable || sym->isUsedInRegularObj ||
+    r.VisibleToRegularObj = ctx.arg.relocatable || sym->isUsedInRegularObj ||
                             sym->referencedAfterWrap ||
                             (r.Prevailing && sym->includeInDynsym()) ||
                             usedStartStop.count(objSym.getSectionName());
@@ -252,7 +252,7 @@ void BitcodeCompiler::add(BitcodeFile &f) {
     // referenced by a shared library not visible to the linker.
     r.ExportDynamic =
         sym->computeBinding() != STB_LOCAL &&
-        (config->exportDynamic || sym->exportDynamic || sym->inDynamicList);
+        (ctx.arg.exportDynamic || sym->exportDynamic || sym->inDynamicList);
     const auto *dr = dyn_cast<Defined>(sym);
     r.FinalDefinitionInLinkageUnit =
         (isExec || sym->visibility() != STV_DEFAULT) && dr &&
@@ -299,7 +299,7 @@ static void thinLTOCreateEmptyIndexFiles() {
     ModuleSummaryIndex m(/*HaveGVs*/ false);
     m.setSkipModuleByDistributedBackend();
     writeIndexToFile(m, *os);
-    if (config->thinLTOEmitImportsFiles)
+    if (ctx.arg.thinLTOEmitImportsFiles)
       openFile(path + ".imports");
   }
 }


        


More information about the llvm-commits mailing list