[lld] r257211 - ELF: Consistently return SymbolBody * from SymbolTable::add functions.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 8 13:53:28 PST 2016
Author: ruiu
Date: Fri Jan 8 15:53:28 2016
New Revision: 257211
URL: http://llvm.org/viewvc/llvm-project?rev=257211&view=rev
Log:
ELF: Consistently return SymbolBody * from SymbolTable::add functions.
For historical reasons, some add* functions for SymbolTable returns a
pointer to a SymbolBody, while some are not. This patch is to make them
consistently return a pointer to a newly added symbol.
Modified:
lld/trunk/ELF/SymbolTable.cpp
lld/trunk/ELF/SymbolTable.h
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=257211&r1=257210&r2=257211&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Jan 8 15:53:28 2016
@@ -101,17 +101,20 @@ SymbolBody *SymbolTable<ELFT>::addUndefi
}
template <class ELFT>
-void SymbolTable<ELFT>::addAbsolute(StringRef Name,
- typename ELFFile<ELFT>::Elf_Sym &ESym) {
- resolve(new (Alloc) DefinedRegular<ELFT>(Name, ESym, nullptr));
+SymbolBody *SymbolTable<ELFT>::addAbsolute(StringRef Name, Elf_Sym &ESym) {
+ // Pass nullptr because absolute symbols have no corresponding input sections.
+ auto *Sym = new (Alloc) DefinedRegular<ELFT>(Name, ESym, nullptr);
+ resolve(Sym);
+ return Sym;
}
template <class ELFT>
-void SymbolTable<ELFT>::addSynthetic(StringRef Name,
- OutputSectionBase<ELFT> &Section,
- typename ELFFile<ELFT>::uintX_t Value) {
+SymbolBody *SymbolTable<ELFT>::addSynthetic(StringRef Name,
+ OutputSectionBase<ELFT> &Section,
+ uintX_t Value) {
auto *Sym = new (Alloc) DefinedSynthetic<ELFT>(Name, Value, Section);
resolve(Sym);
+ return Sym;
}
// Add Name as an "ignored" symbol. An ignored symbol is a regular
@@ -119,10 +122,7 @@ void SymbolTable<ELFT>::addSynthetic(Str
// file's symbol table. Such symbols are useful for some linker-defined symbols.
template <class ELFT>
SymbolBody *SymbolTable<ELFT>::addIgnored(StringRef Name) {
- auto *Sym = new (Alloc)
- DefinedRegular<ELFT>(Name, ElfSym<ELFT>::IgnoreUndef, nullptr);
- resolve(Sym);
- return Sym;
+ return addAbsolute(Name, ElfSym<ELFT>::IgnoreUndef);
}
// Rename SYM as __wrap_SYM. The original symbol is preserved as __real_SYM.
Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=257211&r1=257210&r2=257211&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Fri Jan 8 15:53:28 2016
@@ -31,6 +31,9 @@ class Undefined;
// undefined, it'll read an archive member to read a real definition
// to replace the lazy symbol. The logic is implemented in resolve().
template <class ELFT> class SymbolTable {
+ typedef typename llvm::object::ELFFile<ELFT>::Elf_Sym Elf_Sym;
+ typedef typename llvm::object::ELFFile<ELFT>::uintX_t uintX_t;
+
public:
SymbolTable();
@@ -50,11 +53,11 @@ public:
SymbolBody *addUndefined(StringRef Name);
SymbolBody *addUndefinedOpt(StringRef Name);
- void addAbsolute(StringRef Name,
- typename llvm::object::ELFFile<ELFT>::Elf_Sym &ESym);
- void addSynthetic(StringRef Name, OutputSectionBase<ELFT> &Section,
- typename llvm::object::ELFFile<ELFT>::uintX_t Value);
+ SymbolBody *addAbsolute(StringRef Name, Elf_Sym &ESym);
+ SymbolBody *addSynthetic(StringRef Name, OutputSectionBase<ELFT> &Section,
+ uintX_t Value);
SymbolBody *addIgnored(StringRef Name);
+
void scanShlibUndefined();
SymbolBody *find(StringRef Name);
void wrap(StringRef Name);
More information about the llvm-commits
mailing list