mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 17:28:30 +08:00
Implement --trace-symbol=symbol option.
Patch by Shridhar Joshi. This option provides names of all the link time modules which define and reference symbols requested by user. This helps to speed up application development by detecting references causing undefined symbols. It also helps in detecting symbols being resolved to wrong (unintended) definitions in case of applications containing multiple definitions for same symbols with different types, bindings. Implements PR28226. llvm-svn: 273536
This commit is contained in:
@@ -313,6 +313,14 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec) {
|
||||
return new (IAlloc.Allocate()) InputSection<ELFT>(this, &Sec);
|
||||
}
|
||||
|
||||
// Print the module names which reference the notified
|
||||
// symbols provided through -y or --trace-symbol option.
|
||||
template <class ELFT>
|
||||
void elf::ObjectFile<ELFT>::traceUndefined(StringRef Name) {
|
||||
if (!Config->TraceSymbol.empty() && Config->TraceSymbol.count(Name))
|
||||
outs() << getFilename(this) << ": reference to " << Name << "\n";
|
||||
}
|
||||
|
||||
template <class ELFT> void elf::ObjectFile<ELFT>::initializeSymbols() {
|
||||
this->initStringTable();
|
||||
Elf_Sym_Range Syms = this->getElfSymbols(false);
|
||||
@@ -350,6 +358,7 @@ SymbolBody *elf::ObjectFile<ELFT>::createSymbolBody(const Elf_Sym *Sym) {
|
||||
|
||||
switch (Sym->st_shndx) {
|
||||
case SHN_UNDEF:
|
||||
traceUndefined(Name);
|
||||
return elf::Symtab<ELFT>::X
|
||||
->addUndefined(Name, Binding, Sym->st_other, Sym->getType(),
|
||||
/*CanOmitFromDynSym*/ false, this)
|
||||
|
||||
Reference in New Issue
Block a user