diff options
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 = |