diff options
author | Igor Kudrin <ikudrin@accesssoftek.com> | 2020-05-29 19:28:37 +0700 |
---|---|---|
committer | Igor Kudrin <ikudrin@accesssoftek.com> | 2020-05-29 20:24:53 +0700 |
commit | 5b875bf59b068f3db91c750b24030a7b2bd164aa (patch) | |
tree | 95732ce165972d518cffb7353a9b0ec43c3e4c28 /llvm/tools/llvm-objcopy/ELF/Object.cpp | |
parent | a9313282cd5413ed498dceb763ebba12ea5bdecd (diff) | |
download | llvm-5b875bf59b068f3db91c750b24030a7b2bd164aa.zip llvm-5b875bf59b068f3db91c750b24030a7b2bd164aa.tar.gz llvm-5b875bf59b068f3db91c750b24030a7b2bd164aa.tar.bz2 |
[llvm-objcopy][ELF] Fix removing a group member.
When a group member is removed, the corresponding record in the
SHT_GROUP section has to be deleted.
This fixes PR46064.
Differential Revision: https://reviews.llvm.org/D80568
Diffstat (limited to 'llvm/tools/llvm-objcopy/ELF/Object.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/ELF/Object.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp index 2ceb479..8bb4bbb 100644 --- a/llvm/tools/llvm-objcopy/ELF/Object.cpp +++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp @@ -112,7 +112,9 @@ void ELFSectionSizer<ELFT>::visit(RelocationSection &Sec) { template <class ELFT> void ELFSectionSizer<ELFT>::visit(GnuDebugLinkSection &Sec) {} -template <class ELFT> void ELFSectionSizer<ELFT>::visit(GroupSection &Sec) {} +template <class ELFT> void ELFSectionSizer<ELFT>::visit(GroupSection &Sec) { + Sec.Size = sizeof(Elf_Word) + Sec.GroupMembers.size() * sizeof(Elf_Word); +} template <class ELFT> void ELFSectionSizer<ELFT>::visit(SectionIndexSection &Sec) {} @@ -968,6 +970,12 @@ void GroupSection::finalize() { this->Link = SymTab->Index; } +Error GroupSection::removeSectionReferences( + bool AllowBrokenLinks, function_ref<bool(const SectionBase *)> ToRemove) { + llvm::erase_if(GroupMembers, ToRemove); + return Error::success(); +} + Error GroupSection::removeSymbols(function_ref<bool(const Symbol &)> ToRemove) { if (ToRemove(*Sym)) return createStringError(llvm::errc::invalid_argument, |