[ELF][llvm-objcopy] Reject duplicate SHT_SYMTAB sections
authorMoshe Berman <mosheberman@users.noreply.github.com>
Fri, 17 Feb 2023 17:18:14 +0000 (17:18 +0000)
committerJames Henderson <james.henderson@sony.com>
Fri, 17 Feb 2023 17:59:20 +0000 (17:59 +0000)
commitbc6e10c9efca78cda350b6705de27728d142c0b0
tree9a3639c4d62273a6d25cd2b5b177983c16a2acb7
parent998ad085e865f2e5acc589d6bee0e3379042da2e
[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
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/test/tools/llvm-objcopy/ELF/multiple-symtab.test [new file with mode: 0644]