aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorMoshe Berman <mosheberman@users.noreply.github.com>2023-02-17 17:18:14 +0000
committerJames Henderson <james.henderson@sony.com>2023-02-17 17:59:20 +0000
commitbc6e10c9efca78cda350b6705de27728d142c0b0 (patch)
tree9a3639c4d62273a6d25cd2b5b177983c16a2acb7 /llvm/lib
parent998ad085e865f2e5acc589d6bee0e3379042da2e (diff)
downloadllvm-bc6e10c9efca78cda350b6705de27728d142c0b0.zip
llvm-bc6e10c9efca78cda350b6705de27728d142c0b0.tar.gz
llvm-bc6e10c9efca78cda350b6705de27728d142c0b0.tar.bz2
[ELF][llvm-objcopy] Reject duplicate SHT_SYMTAB sections
The gABI prohibits multiple SH_SYMTAB sections. As a result, llvm-objcopy was crashing in SymbolTableSection::removeSymbols(). This patch fixes the issue by emitting an error if multiple SH_SYMTAB sections are encountered when building an ELF object. Fixes: https://github.com/llvm/llvm-project/issues/60448 Differential Revision: https://reviews.llvm.org/D143508
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ObjCopy/ELF/ELFObject.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index ea6dada..25bfa1a 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -1704,6 +1704,10 @@ Expected<SectionBase &> ELFBuilder<ELFT>::makeSection(const Elf_Shdr &Shdr) {
else
return Data.takeError();
case SHT_SYMTAB: {
+ // Multiple SHT_SYMTAB sections are forbidden by the ELF gABI.
+ if (Obj.SymbolTable != nullptr)
+ return createStringError(llvm::errc::invalid_argument,
+ "found multiple SHT_SYMTAB sections");
auto &SymTab = Obj.addSection<SymbolTableSection>();
Obj.SymbolTable = &SymTab;
return SymTab;