forked from OSchip/llvm-project
ELF2: Avoid using "finalize" as a function name.
"finalize" does not give a hint about what that function is actually going to do. This patch make it more specific by renaming scanShlibUndefined. Also add a comment that we basically ignore undefined symbols in DSOs except this function. llvm-svn: 250191
This commit is contained in:
parent
0d7e83bbc4
commit
93bfee5f70
|
@ -227,6 +227,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
|
||||||
Config->OutputFile = "a.out";
|
Config->OutputFile = "a.out";
|
||||||
|
|
||||||
// Write the result to the file.
|
// Write the result to the file.
|
||||||
Symtab.finalize();
|
Symtab.scanShlibUndefined();
|
||||||
writeResult<ELFT>(&Symtab);
|
writeResult<ELFT>(&Symtab);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,13 +237,14 @@ template <class ELFT> void SymbolTable<ELFT>::addMemberFile(Lazy *Body) {
|
||||||
addFile(std::move(File));
|
addFile(std::move(File));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ELFT> void SymbolTable<ELFT>::finalize() {
|
// This function takes care of the case in which shared libraries depend on
|
||||||
// This code takes care of the case in which shared libraries depend on
|
// the user program (not the other way, which is usual). Shared libraries
|
||||||
// the user program (not the other way, which is usual). Shared libraries
|
// may have undefined symbols, expecting that the user program provides
|
||||||
// may have undefined symbols, expecting that the user program provides
|
// the definitions for them. An example is BSD's __progname symbol.
|
||||||
// the definitions for them. An example is BSD's __progname symbol.
|
// We need to put such symbols to the main program's .dynsym so that
|
||||||
// We need to put such symbols to the main program's .dynsym so that
|
// shared libraries can find them.
|
||||||
// shared libraries can find them.
|
// Except this, we ignore undefined symbols in DSOs.
|
||||||
|
template <class ELFT> void SymbolTable<ELFT>::scanShlibUndefined() {
|
||||||
for (std::unique_ptr<SharedFile<ELFT>> &File : SharedFiles)
|
for (std::unique_ptr<SharedFile<ELFT>> &File : SharedFiles)
|
||||||
for (StringRef U : File->getUndefinedSymbols())
|
for (StringRef U : File->getUndefinedSymbols())
|
||||||
if (SymbolBody *Sym = find(U))
|
if (SymbolBody *Sym = find(U))
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void addSyntheticSym(StringRef Name, OutputSection<ELFT> &Section,
|
void addSyntheticSym(StringRef Name, OutputSection<ELFT> &Section,
|
||||||
typename llvm::object::ELFFile<ELFT>::uintX_t Value);
|
typename llvm::object::ELFFile<ELFT>::uintX_t Value);
|
||||||
void addIgnoredSym(StringRef Name);
|
void addIgnoredSym(StringRef Name);
|
||||||
void finalize();
|
void scanShlibUndefined();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Symbol *insert(SymbolBody *New);
|
Symbol *insert(SymbolBody *New);
|
||||||
|
|
Loading…
Reference in New Issue