diff options
author | Paul Semel <semelpaul@gmail.com> | 2018-05-25 11:01:25 +0000 |
---|---|---|
committer | Paul Semel <semelpaul@gmail.com> | 2018-05-25 11:01:25 +0000 |
commit | 99dda0bab837f003d710252a7b62eda898e48111 (patch) | |
tree | c3210a7f70284bbe5721e9fab3c882f937a7db06 /llvm/tools/llvm-objcopy/Object.cpp | |
parent | a2aad28f6d18b3d9590cd52d650a4598800ce298 (diff) | |
download | bcm5719-llvm-99dda0bab837f003d710252a7b62eda898e48111.tar.gz bcm5719-llvm-99dda0bab837f003d710252a7b62eda898e48111.zip |
[llvm-objcopy] Add --strip-unneeded option
Differential Revision: https://reviews.llvm.org/D46896
llvm-svn: 333267
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/Object.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp index efb3207aa8d..c00477a1980 100644 --- a/llvm/tools/llvm-objcopy/Object.cpp +++ b/llvm/tools/llvm-objcopy/Object.cpp @@ -50,6 +50,7 @@ void SectionBase::removeSectionReferences(const SectionBase *Sec) {} void SectionBase::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) {} void SectionBase::initialize(SectionTableRef SecTable) {} void SectionBase::finalize() {} +void SectionBase::markSymbols() {} template <class ELFT> void ELFWriter<ELFT>::writeShdr(const SectionBase &Sec) { uint8_t *Buf = BufPtr->getBufferStart(); @@ -255,6 +256,11 @@ const Symbol *SymbolTableSection::getSymbolByIndex(uint32_t Index) const { return Symbols[Index].get(); } +Symbol *SymbolTableSection::getSymbolByIndex(uint32_t Index) { + return const_cast<Symbol *>( + static_cast<const SymbolTableSection *>(this)->getSymbolByIndex(Index)); +} + template <class ELFT> void ELFSectionWriter<ELFT>::visit(const SymbolTableSection &Sec) { uint8_t *Buf = Out.getBufferStart(); @@ -352,6 +358,11 @@ void RelocationSection::removeSymbols( "' because it is named in a relocation"); } +void RelocationSection::markSymbols() { + for (const Relocation &Reloc : Relocations) + Reloc.RelocSymbol->Referenced = true; +} + void SectionWriter::visit(const DynamicRelocationSection &Sec) { std::copy(std::begin(Sec.Contents), std::end(Sec.Contents), Out.getBufferStart() + Sec.Offset); @@ -384,6 +395,11 @@ void GroupSection::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) { } } +void GroupSection::markSymbols() { + if (Sym) + Sym->Referenced = true; +} + void Section::initialize(SectionTableRef SecTable) { if (Link != ELF::SHN_UNDEF) LinkSection = |