summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2018-09-04 22:28:49 +0000
committerJordan Rupprecht <rupprecht@google.com>2018-09-04 22:28:49 +0000
commitec277a827815015e516ea08d79bbd4c64259c3d1 (patch)
tree5a7b0b395611a8c7d89b446909b62f4f9aa81bbe /llvm/tools
parent034423377cf8ef69ff248b69b4487b0b7b00ab81 (diff)
downloadbcm5719-llvm-ec277a827815015e516ea08d79bbd4c64259c3d1.tar.gz
bcm5719-llvm-ec277a827815015e516ea08d79bbd4c64259c3d1.zip
[llvm-strip] Allow copying relocation sections without symbol tables.
Summary: Fixes the error "Link field value 0 in section .rela.plt is invalid" when copying/stripping certain binaries. Minimal repro: ``` $ cat /tmp/a.c int main() { return 0; } $ clang -static /tmp/a.c -o /tmp/a $ llvm-strip /tmp/a -o /tmp/b llvm-strip: error: Link field value 0 in section .rela.plt is invalid. ``` Reviewers: jakehehrlich, alexshap Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51493 llvm-svn: 341419
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-objcopy/Object.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objcopy/Object.cpp b/llvm/tools/llvm-objcopy/Object.cpp
index 12fd80228bf..2ff24ce9a25 100644
--- a/llvm/tools/llvm-objcopy/Object.cpp
+++ b/llvm/tools/llvm-objcopy/Object.cpp
@@ -375,11 +375,13 @@ void RelocSectionWithSymtabBase<SymTabType>::removeSectionReferences(
template <class SymTabType>
void RelocSectionWithSymtabBase<SymTabType>::initialize(
SectionTableRef SecTable) {
- setSymTab(SecTable.getSectionOfType<SymTabType>(
- Link,
- "Link field value " + Twine(Link) + " in section " + Name + " is invalid",
- "Link field value " + Twine(Link) + " in section " + Name +
- " is not a symbol table"));
+ if (Link != SHN_UNDEF)
+ setSymTab(SecTable.getSectionOfType<SymTabType>(
+ Link,
+ "Link field value " + Twine(Link) + " in section " + Name +
+ " is invalid",
+ "Link field value " + Twine(Link) + " in section " + Name +
+ " is not a symbol table"));
if (Info != SHN_UNDEF)
setSection(SecTable.getSection(Info, "Info field value " + Twine(Info) +
@@ -391,7 +393,8 @@ void RelocSectionWithSymtabBase<SymTabType>::initialize(
template <class SymTabType>
void RelocSectionWithSymtabBase<SymTabType>::finalize() {
- this->Link = Symbols->Index;
+ this->Link = Symbols ? Symbols->Index : 0;
+
if (SecToApplyRel != nullptr)
this->Info = SecToApplyRel->Index;
}
OpenPOWER on IntegriCloud