[PATCH] D48092: [COFF] Fix crash when emitting symbol tables with GC
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 14:23:56 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334548: [COFF] Fix crash when emitting symbol tables with GC (authored by smeenai, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D48092
Files:
lld/trunk/COFF/Writer.cpp
lld/trunk/test/COFF/symtab-gc.s
Index: lld/trunk/test/COFF/symtab-gc.s
===================================================================
--- lld/trunk/test/COFF/symtab-gc.s
+++ lld/trunk/test/COFF/symtab-gc.s
@@ -0,0 +1,27 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %tobject.obj %S/Inputs/object.s
+# RUN: lld-link -dll -entry:f -out:%t.dll -implib:%t.lib %tobject.obj
+# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %tmain.obj %s
+# RUN: lld-link -entry:main -out:%t.exe -opt:ref -debug:dwarf %tmain.obj %t.lib
+# RUN: llvm-readobj -coff-imports %t.exe | FileCheck %s
+
+# CHECK-NOT: Symbol: f
+
+ .def main;
+ .scl 2;
+ .type 32;
+ .endef
+ .section .text,"xr",one_only,main
+ .globl main
+main:
+ retq
+
+ .def stripped;
+ .scl 3;
+ .type 32;
+ .endef
+ .section .text,"xr",one_only,stripped
+stripped:
+ callq __imp_f
+ retq
Index: lld/trunk/COFF/Writer.cpp
===================================================================
--- lld/trunk/COFF/Writer.cpp
+++ lld/trunk/COFF/Writer.cpp
@@ -614,7 +614,10 @@
default: {
// Don't write symbols that won't be written to the output to the symbol
// table.
- OutputSection *OS = Def->getChunk()->getOutputSection();
+ Chunk *C = Def->getChunk();
+ if (!C)
+ return None;
+ OutputSection *OS = C->getOutputSection();
if (!OS)
return None;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48092.151031.patch
Type: text/x-patch
Size: 1355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180612/6fbb2806/attachment.bin>
More information about the llvm-commits
mailing list