[lld] r250215 - ELF2: Add comments.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 12:51:57 PDT 2015


Author: ruiu
Date: Tue Oct 13 14:51:57 2015
New Revision: 250215

URL: http://llvm.org/viewvc/llvm-project?rev=250215&view=rev
Log:
ELF2: Add comments.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=250215&r1=250214&r2=250215&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Oct 13 14:51:57 2015
@@ -9,7 +9,7 @@
 //
 // This file contains the parser/evaluator of the linker script.
 // It does not construct an AST but consume linker script directives directly.
-// Results are written to Symtab or Config object.
+// Results are written to Driver or Config object.
 //
 //===----------------------------------------------------------------------===//
 

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=250215&r1=250214&r2=250215&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Oct 13 14:51:57 2015
@@ -419,6 +419,8 @@ typename ELFFile<ELFT>::uintX_t lld::elf
   llvm_unreachable("Invalid symbol kind");
 }
 
+// Returns a VA which a relocatin RI refers to. Used only for local symbols.
+// For non-local symbols, use getSymVA instead.
 template <class ELFT>
 typename ELFFile<ELFT>::uintX_t
 lld::elf2::getLocalRelTarget(const ObjectFile<ELFT> &File,
@@ -450,9 +452,11 @@ lld::elf2::getLocalRelTarget(const Objec
   return OutSec->getVA() + Section->getOutputSectionOff() + Sym->st_value;
 }
 
+// Returns true if a symbol can be replaced at load-time by a symbol
+// with the same name defined in other ELF executable or DSO.
 bool lld::elf2::canBePreempted(const SymbolBody *Body) {
   if (!Body)
-    return false;
+    return false;  // Body is a local symbol.
   if (Body->isShared())
     return true;
   if (Body->isUndefined() && !Body->isWeak())

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=250215&r1=250214&r2=250215&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Tue Oct 13 14:51:57 2015
@@ -6,6 +6,13 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+//
+// Symbol table is a bag of all known symbols. We put all symbols of
+// all input files to the symbol table. The symbol Table is basically
+// a hash table with the logic to resolve symbol name conflicts using
+// the symbol types.
+//
+//===----------------------------------------------------------------------===//
 
 #include "SymbolTable.h"
 #include "Config.h"

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=250215&r1=250214&r2=250215&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Oct 13 14:51:57 2015
@@ -6,6 +6,19 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+//
+// All symbols are handled as SymbolBodies regardless of their types.
+// This file defines various types of SymbolBodies.
+//
+// File-scope symbols in ELF objects are the only exception of SymbolBody
+// instantiation. We will never create SymbolBodies for them for performance
+// reason. They are often represented as nullptrs. This is fine for symbol
+// resolution because the symbol table naturally cares only about
+// externally-visible symbols. For relocations, you have to deal with both
+// local and non-local functions, and we have two different functions
+// where we need them.
+//
+//===----------------------------------------------------------------------===//
 
 #ifndef LLD_ELF_SYMBOLS_H
 #define LLD_ELF_SYMBOLS_H
@@ -141,8 +154,7 @@ public:
   }
 };
 
-// The base class for any defined symbols, including absolute symbols,
-// etc.
+// The base class for any defined symbols, including absolute symbols, etc.
 template <class ELFT> class Defined : public ELFSymbolBody<ELFT> {
   typedef ELFSymbolBody<ELFT> Base;
 

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=250215&r1=250214&r2=250215&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Oct 13 14:51:57 2015
@@ -6,6 +6,11 @@
 // License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
+//
+// Machine-specific stuff, such as applying relocations, creation of
+// GOT or PLT entries, etc., are is handled in this file.
+//
+//===----------------------------------------------------------------------===//
 
 #include "Target.h"
 #include "Error.h"




More information about the llvm-commits mailing list