From a401eee22fabea8d214ab604037c937277477c38 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 4 Jun 2015 15:33:30 +0000 Subject: 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. llvm-svn: 239045 --- llvm/lib/MC/ELFObjectWriter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/ELFObjectWriter.cpp') diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index f8cf7d2..b4e41062 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -688,6 +688,8 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm, auto *ELFSec = cast_or_null(SecA); const auto *SectionSymbol = ELFSec ? cast(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; } -- cgit v1.1