Omit unused section symbols from the symbol table.

Section symbols exist as an optimization: instead of having multiple relocations
point to different symbols, many of them can point to a single section symbol.

When that optimization is unused, a section symbol is also unused and adds no
extra information to the object file.

This saves a bit of space on the object files and makes the output of
llvm-objdump -t easier to read and consequently some tests get quite a bit
simpler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239045 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-06-04 15:33:30 +00:00
parent 800411deea
commit 9f299abc05
16 changed files with 55 additions and 147 deletions

View File

@@ -688,6 +688,8 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
auto *ELFSec = cast_or_null<MCSectionELF>(SecA);
const auto *SectionSymbol =
ELFSec ? cast<MCSymbolELF>(ELFSec->getBeginSymbol()) : nullptr;
if (SectionSymbol)
SectionSymbol->setUsedInReloc();
ELFRelocationEntry Rec(FixupOffset, SectionSymbol, Type, Addend);
Relocations[&FixupSection].push_back(Rec);
return;
@@ -733,12 +735,12 @@ bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
if (Symbol.isUndefined() && !Symbol.isBindingSet())
return false;
if (Symbol.getType() == ELF::STT_SECTION)
return true;
if (Symbol.isTemporary())
return false;
if (Symbol.getType() == ELF::STT_SECTION)
return false;
return true;
}