diff options
author | Alexander Shaposhnikov <shal1t712@gmail.com> | 2018-04-20 20:46:04 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <shal1t712@gmail.com> | 2018-04-20 20:46:04 +0000 |
commit | 52db4335b3a121333f8954ee27d0f09c1596a46b (patch) | |
tree | e565202e934ff617d526bd282354f1800e2ae2f5 /llvm/tools/llvm-objcopy/Object.cpp | |
parent | 334c379e32b8fcc7f73ffaba3baf88a5be29a269 (diff) | |
download | bcm5719-llvm-52db4335b3a121333f8954ee27d0f09c1596a46b.tar.gz bcm5719-llvm-52db4335b3a121333f8954ee27d0f09c1596a46b.zip |
[llvm-objcopy] Fix sh_link
This diff fixes sh_link for various types of sections
(i.e. for SHT_ARM_EXIDX, SHT_HASH). In particular, this change enables us
to use llvm-objcopy with clang -gsplit-dwarf for the target android-arm.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D45851
llvm-svn: 330478
Diffstat (limited to 'llvm/tools/llvm-objcopy/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/Object.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp index e4c268d115c..c7ce2309ffb 100644 --- a/llvm/tools/llvm-objcopy/Object.cpp +++ b/llvm/tools/llvm-objcopy/Object.cpp @@ -353,9 +353,9 @@ void DynamicRelocationSection::accept(SectionVisitor &Visitor) const { Visitor.visit(*this); } -void SectionWithStrTab::removeSectionReferences(const SectionBase *Sec) { - if (StrTab == Sec) { - error("String table " + StrTab->Name + +void Section::removeSectionReferences(const SectionBase *Sec) { + if (LinkSection == Sec) { + error("Section " + LinkSection->Name + " cannot be removed because it is " "referenced by the section " + this->Name); @@ -367,23 +367,18 @@ void GroupSection::finalize() { this->Link = SymTab->Index; } -bool SectionWithStrTab::classof(const SectionBase *S) { - return isa<DynamicSymbolTableSection>(S) || isa<DynamicSection>(S); +void Section::initialize(SectionTableRef SecTable) { + if (Link != ELF::SHN_UNDEF) + LinkSection = + SecTable.getSection(Link, "Link field value " + Twine(Link) + + " in section " + Name + " is invalid"); } -void SectionWithStrTab::initialize(SectionTableRef SecTable) { - auto StrTab = - SecTable.getSection(Link, "Link field value " + Twine(Link) + - " in section " + Name + " is invalid"); - if (StrTab->Type != SHT_STRTAB) { - error("Link field value " + Twine(Link) + " in section " + Name + - " is not a string table"); - } - setStrTab(StrTab); +void Section::finalize() { + if (LinkSection) + this->Link = LinkSection->Index; } -void SectionWithStrTab::finalize() { this->Link = StrTab->Index; } - void GnuDebugLinkSection::init(StringRef File, StringRef Data) { FileName = sys::path::filename(File); // The format for the .gnu_debuglink starts with the file name and is |