From 7d96d46cb7076104293cdf4ff88a502f2061b690 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 6 Sep 2017 16:23:15 +0000 Subject: Revert "[llvm-objcopy] Add support for relocations" This reverts r312643 because it's failing on llvm-i686-linux-RA. llvm-svn: 312645 --- llvm/tools/llvm-objcopy/Object.cpp | 86 -------------------------------------- 1 file changed, 86 deletions(-) (limited to 'llvm/tools/llvm-objcopy/Object.cpp') diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp index ada62aa713b..7738171d4e8 100644 --- a/llvm/tools/llvm-objcopy/Object.cpp +++ b/llvm/tools/llvm-objcopy/Object.cpp @@ -154,39 +154,6 @@ void SymbolTableSectionImpl::writeSection( } } -template void RelocationSection::finalize() { - this->Link = Symbols->Index; - this->Info = SecToApplyRel->Index; -} - -template -void setAddend(Elf_Rel_Impl &Rel, uint64_t Addend) {} - -template -void setAddend(Elf_Rel_Impl &Rela, uint64_t Addend) { - Rela.r_addend = Addend; -} - -template -template -void RelocationSection::writeRel(T *Buf) const { - for (const auto &Reloc : Relocations) { - Buf->r_offset = Reloc.Offset; - setAddend(*Buf, Reloc.Addend); - Buf->setSymbolAndType(Reloc.Symbol->Index, Reloc.Type, false); - ++Buf; - } -} - -template -void RelocationSection::writeSection(llvm::FileOutputBuffer &Out) const { - uint8_t *Buf = Out.getBufferStart() + Offset; - if (Type == SHT_REL) - writeRel(reinterpret_cast(Buf)); - else - writeRel(reinterpret_cast(Buf)); -} - // Returns true IFF a section is wholly inside the range of a segment static bool sectionWithinSegment(const SectionBase &Section, const Segment &Segment) { @@ -263,36 +230,12 @@ void Object::initSymbolTable(const llvm::object::ELFFile &ElfFile, } } -template -static void getAddend(uint64_t &ToSet, const Elf_Rel_Impl &Rel) {} - -template -static void getAddend(uint64_t &ToSet, const Elf_Rel_Impl &Rela) { - ToSet = Rela.r_addend; -} - -template -void initRelocations(RelocationSection *Relocs, - SymbolTableSection *SymbolTable, T RelRange) { - for (const auto &Rel : RelRange) { - Relocation ToAdd; - ToAdd.Offset = Rel.r_offset; - getAddend(ToAdd.Addend, Rel); - ToAdd.Type = Rel.getType(false); - ToAdd.Symbol = SymbolTable->getSymbolByIndex(Rel.getSymbol(false)); - Relocs->addRelocation(ToAdd); - } -} - template std::unique_ptr Object::makeSection(const llvm::object::ELFFile &ElfFile, const Elf_Shdr &Shdr) { ArrayRef Data; switch (Shdr.sh_type) { - case SHT_REL: - case SHT_RELA: - return llvm::make_unique>(); case SHT_STRTAB: return llvm::make_unique(); case SHT_SYMTAB: { @@ -336,35 +279,6 @@ void Object::readSectionHeaders(const ELFFile &ElfFile) { // details about symbol tables. if (SymbolTable) initSymbolTable(ElfFile, SymbolTable); - - // Now that all sections and symbols have been added we can add - // relocations that reference symbols and set the link and info fields for - // relocation sections. - for (auto &Section : Sections) { - if (auto RelSec = dyn_cast>(Section.get())) { - if (RelSec->Link - 1 >= Sections.size() || RelSec->Link == 0) { - error("Link field value " + Twine(RelSec->Link) + " in section " + - RelSec->Name + " is invalid"); - } - if (RelSec->Info - 1 >= Sections.size() || RelSec->Info == 0) { - error("Info field value " + Twine(RelSec->Link) + " in section " + - RelSec->Name + " is invalid"); - } - auto SymTab = - dyn_cast(Sections[RelSec->Link - 1].get()); - if (SymTab == nullptr) { - error("Link field of relocation section " + RelSec->Name + - " is not a symbol table"); - } - RelSec->setSymTab(SymTab); - RelSec->setSection(Sections[RelSec->Info - 1].get()); - auto Shdr = unwrapOrError(ElfFile.sections()).begin() + RelSec->Index; - if (RelSec->Type == SHT_REL) - initRelocations(RelSec, SymTab, unwrapOrError(ElfFile.rels(Shdr))); - else - initRelocations(RelSec, SymTab, unwrapOrError(ElfFile.relas(Shdr))); - } - } } template Object::Object(const ELFObjectFile &Obj) { -- cgit v1.2.3