[PATCH] D143508: [ELF][llvm-objcopy] Reject duplicate SHT_SYMTAB sections.
Moshe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 20:32:17 PST 2023
MosheBerman updated this revision to Diff 497535.
MosheBerman added a comment.
Thanks for the review @jhenderson, and I hope you're feeling better. I incorporated all of the feedback:
- Renamed test file to match feedback.
- Cleaned up the error output and updated test.
Also, I see what you mean about context. I think that I included the whole file this time, using `git show HEAD -U999999 | bcopy` and pasting into the web UI.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143508/new/
https://reviews.llvm.org/D143508
Files:
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/test/tools/llvm-objcopy/ELF/multiple-symtab.test
Index: llvm/test/tools/llvm-objcopy/ELF/multiple-symtab.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/ELF/multiple-symtab.test
@@ -0,0 +1,17 @@
+## According to the ELF gABI, "Currently, an object file may have only one
+## section of each type [SHT_SYMTAB and SHT_DYNSYM], but this restriction may be relaxed in the future.".
+# RUN: yaml2obj %s -o %t
+# RUN: not llvm-objcopy %t /dev/null 2>&1 | FileCheck %s
+
+# CHECK: error: found multiple SHT_SYMTAB sections.
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+Sections:
+ - Name: .symtab
+ Type: SHT_SYMTAB
+ - Name: .symtab2
+ Type: SHT_SYMTAB
Index: llvm/lib/ObjCopy/ELF/ELFObject.cpp
===================================================================
--- llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -1704,6 +1704,10 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143508.497535.patch
Type: text/x-patch
Size: 1350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230215/bbe3d5df/attachment.bin>
More information about the llvm-commits
mailing list