[lld] r262031 - Simplify. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 08:38:40 PST 2016


Author: ruiu
Date: Fri Feb 26 10:38:39 2016
New Revision: 262031

URL: http://llvm.org/viewvc/llvm-project?rev=262031&view=rev
Log:
Simplify. NFC.

Regarding the comment, it is out of context because it describes
what it does not do there. It got too long because it was originally
two different comments that were simply merged together.
The semantics is described in fixAbsoluteSymbols, so we don't need it.

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=262031&r1=262030&r2=262031&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Feb 26 10:38:39 2016
@@ -914,30 +914,22 @@ template <class ELFT> void Writer<ELFT>:
   if (!isOutputDynamic())
     Symtab.addIgnored("__tls_get_addr");
 
-  auto Define = [this](StringRef Name, StringRef Alias, Elf_Sym &Sym) {
-    if (Symtab.find(Name))
-      Symtab.addAbsolute(Name, Sym);
-    if (SymbolBody *B = Symtab.find(Alias))
+  auto Define = [this](StringRef S, Elf_Sym &Sym) {
+    if (Symtab.find(S))
+      Symtab.addAbsolute(S, Sym);
+
+    // The name without the underscore is not a reserved name,
+    // so it is defined only when there is a reference against it.
+    assert(Name.startswith("_"));
+    S = S.substr(1);
+    if (SymbolBody *B = Symtab.find(S))
       if (B->isUndefined())
-        Symtab.addAbsolute(Alias, Sym);
+        Symtab.addAbsolute(S, Sym);
   };
 
-  // If the "_end" symbol is referenced, it is expected to point to the address
-  // right after the data segment. Usually, this symbol points to the end
-  // of .bss section or to the end of .data section if .bss section is absent.
-  // We don't know the final address of _end yet, so just add a symbol here,
-  // and fix ElfSym<ELFT>::End.st_value later.
-  // Define "end" as an alias to "_end" if it is used but not defined.
-  // We don't want to define that unconditionally because we don't want to
-  // break programs that uses "end" as a regular symbol.
-  // The similar history with _etext/etext and _edata/edata:
-  // Address of _etext is the first location after the last read-only loadable
-  // segment. Address of _edata points to the end of the last non SHT_NOBITS
-  // section. That is how gold/bfd do. We update the values for these symbols
-  // later, after assigning sections to segments.
-  Define("_end", "end", ElfSym<ELFT>::End);
-  Define("_etext", "etext", ElfSym<ELFT>::Etext);
-  Define("_edata", "edata", ElfSym<ELFT>::Edata);
+  Define("_end", ElfSym<ELFT>::End);
+  Define("_etext", ElfSym<ELFT>::Etext);
+  Define("_edata", ElfSym<ELFT>::Edata);
 }
 
 // Sort input sections by section name suffixes for




More information about the llvm-commits mailing list