[lld] r288885 - Add comments and reorder code a bit to clarify the intention. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 20:45:35 PST 2016


Author: ruiu
Date: Tue Dec  6 22:45:34 2016
New Revision: 288885

URL: http://llvm.org/viewvc/llvm-project?rev=288885&view=rev
Log:
Add comments and reorder code a bit to clarify the intention. NFC.

Modified:
    lld/trunk/ELF/Driver.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=288885&r1=288884&r2=288885&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Dec  6 22:45:34 2016
@@ -764,34 +764,38 @@ template <class ELFT> void LinkerDriver:
   if (Config->OutputFile.empty())
     Config->OutputFile = "a.out";
 
+  // Use default entry point name if -e was missing. AMDGPU binaries
+  // have no entries. For some reason, MIPS' entry point name is
+  // different from others.
+  if (Config->Entry.empty() && !Config->Relocatable &&
+      Config->EMachine != EM_AMDGPU)
+    Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
+
   // Handle --trace-symbol.
   for (auto *Arg : Args.filtered(OPT_trace_symbol))
     Symtab.trace(Arg->getValue());
 
   // Initialize Config->MaxPageSize. The default value is defined by
-  // the target, but it can be overriden using the option.
+  // each target.
   Config->MaxPageSize =
       getZOptionValue(Args, "max-page-size", Target->MaxPageSize);
   if (!isPowerOf2_64(Config->MaxPageSize))
     error("max-page-size: value isn't a power of 2");
 
-  // Add all files to the symbol table. After this, the symbol table
-  // contains all known names except a few linker-synthesized symbols.
+  // Add all files to the symbol table. This will add almost all
+  // symbols that we need to the symbol table.
   for (InputFile *F : Files)
     Symtab.addFile(F);
 
-  // Add the start symbol. Note that AMDGPU binaries have no entries.
-  if (Config->Entry.empty() && !Config->Relocatable &&
-      Config->EMachine != EM_AMDGPU)
-    Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
-
-  // If an object file defining the entry symbol is in an archive file,
-  // extract the file now.
+  // If an entry symbol is in a static archive, pull out that file now
+  // to complete the symbol table. After this, no new names except a
+  // few linker-synthesized ones will be added to the symbol table.
   if (Symtab.find(Config->Entry))
     Symtab.addUndefined(Config->Entry);
 
+  // Return if there were name resolution errors.
   if (ErrorCount)
-    return; // There were duplicate symbols or incompatible files
+    return;
 
   Symtab.scanUndefinedFlags();
   Symtab.scanShlibUndefined();




More information about the llvm-commits mailing list