[PATCH] D25513: [ELF] - Do not crash on duplicate STT_SECTION symbol.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 15 00:58:19 PST 2016
grimar updated this revision to Diff 77957.
grimar added a comment.
Rebased after latest changes, it is much simpler now.
https://reviews.llvm.org/D25513
Files:
ELF/SymbolTable.cpp
test/ELF/invalid/report-duplicates.test
Index: test/ELF/invalid/report-duplicates.test
===================================================================
--- test/ELF/invalid/report-duplicates.test
+++ test/ELF/invalid/report-duplicates.test
@@ -0,0 +1,28 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: not ld.lld %t.o -o %tout 2>&1 | FileCheck %s
+# CHECK: duplicate symbol '' in {{.*}}.o and {{.*}}.o
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x0000000000000010
+ Content: "00000000"
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ AddressAlign: 0x0000000000000008
+ Info: .text
+ Relocations:
+Symbols:
+ Global:
+ - Type: STT_SECTION
+ Section: .rela.text
+ - Type: STT_SECTION
+ Section: .rela.text
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -379,11 +379,11 @@
template <class ELFT>
static void reportDuplicate(SymbolBody *Existing,
- InputSectionBase<ELFT> *ErrSec,
+ InputSectionBase<ELFT> *ErrSec, InputFile *File,
typename ELFT::uint ErrOffset) {
DefinedRegular<ELFT> *D = dyn_cast<DefinedRegular<ELFT>>(Existing);
if (!D || !D->Section || !ErrSec) {
- reportDuplicate(Existing, ErrSec ? ErrSec->getFile() : nullptr);
+ reportDuplicate(Existing, File);
return;
}
@@ -418,7 +418,7 @@
replaceBody<DefinedRegular<ELFT>>(S, Name, StOther, Type, Value, Size,
Section, File);
else if (Cmp == 0)
- reportDuplicate(S->body(), Section, Value);
+ reportDuplicate(S->body(), Section, File, Value);
return S;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25513.77957.patch
Type: text/x-patch
Size: 2019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/f4e9a1c9/attachment.bin>
More information about the llvm-commits
mailing list