[PATCH] D28903: [ELF] - Do not crash when assign common symbol's values in script
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 01:56:39 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL292594: [ELF] - Do not crash when assign common symbol's values in script (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D28903?vs=84968&id=85108#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28903
Files:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/SyntheticSections.h
lld/trunk/test/ELF/linkerscript/common-assign.s
Index: lld/trunk/test/ELF/linkerscript/common-assign.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/common-assign.s
+++ lld/trunk/test/ELF/linkerscript/common-assign.s
@@ -0,0 +1,48 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; pfoo = foo; pbar = bar; }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-readobj -symbols %t1 | FileCheck %s
+
+# CHECK: Symbol {
+# CHECK: Name: bar
+# CHECK-NEXT: Value: 0x134
+# CHECK-NEXT: Size: 4
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Object
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: foo
+# CHECK-NEXT: Value: 0x138
+# CHECK-NEXT: Size: 4
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: Object
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: pfoo
+# CHECK-NEXT: Value: 0x138
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT: Name: pbar
+# CHECK-NEXT: Value: 0x134
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Global
+# CHECK-NEXT: Type: None
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: .bss
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+
+.comm foo,4,4
+.comm bar,4,4
+movl $1, foo(%rip)
+movl $2, bar(%rip)
Index: lld/trunk/ELF/SyntheticSections.h
===================================================================
--- lld/trunk/ELF/SyntheticSections.h
+++ lld/trunk/ELF/SyntheticSections.h
@@ -372,15 +372,15 @@
ArrayRef<SymbolTableEntry> getSymbols() const { return Symbols; }
+ static const OutputSectionBase *getOutputSection(SymbolBody *Sym);
+
unsigned NumLocals = 0;
StringTableSection<ELFT> &StrTabSec;
private:
void writeLocalSymbols(uint8_t *&Buf);
void writeGlobalSymbols(uint8_t *Buf);
- const OutputSectionBase *getOutputSection(SymbolBody *Sym);
-
// A vector of symbols and their string table offsets.
std::vector<SymbolTableEntry> Symbols;
};
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -918,12 +918,7 @@
return CurOutSec ? CurOutSec : (*OutputSections)[0];
}
- if (auto *DR = dyn_cast_or_null<DefinedRegular<ELFT>>(Sym))
- return DR->Section ? DR->Section->OutSec : nullptr;
- if (auto *DS = dyn_cast_or_null<DefinedSynthetic>(Sym))
- return DS->Section;
-
- return nullptr;
+ return SymbolTableSection<ELFT>::getOutputSection(Sym);
}
// Returns indices of ELF headers containing specific section, identified
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28903.85108.patch
Type: text/x-patch
Size: 2949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170120/eaf04d86/attachment.bin>
More information about the llvm-commits
mailing list