[lld] r238717 - COFF: Fix /include. Included symbols are GC-roots.
Rui Ueyama
ruiu at google.com
Sun May 31 20:42:54 PDT 2015
Author: ruiu
Date: Sun May 31 22:42:54 2015
New Revision: 238717
URL: http://llvm.org/viewvc/llvm-project?rev=238717&view=rev
Log:
COFF: Fix /include. Included symbols are GC-roots.
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/test/COFF/include.test
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=238717&r1=238716&r2=238717&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Sun May 31 22:42:54 2015
@@ -356,6 +356,10 @@ bool LinkerDriver::link(int Argc, const
if (Symtab.reportRemainingUndefines())
return false;
+ // /include option takes precedence over garbage collection.
+ for (auto *Arg : Args->filtered(OPT_incl))
+ Symtab.find(Arg->getValue())->markLive();
+
// Windows specific -- if no /subsystem is given, we need to infer
// that from entry point name.
if (Config->Subsystem == IMAGE_SUBSYSTEM_UNKNOWN) {
Modified: lld/trunk/test/COFF/include.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/include.test?rev=238717&r1=238716&r2=238717&view=diff
==============================================================================
--- lld/trunk/test/COFF/include.test (original)
+++ lld/trunk/test/COFF/include.test Sun May 31 22:42:54 2015
@@ -1,7 +1,67 @@
-# RUN: yaml2obj < %p/Inputs/ret42.yaml > %t.obj
+# RUN: yaml2obj < %s > %t.obj
-# RUN: lld -flavor link2 /out:%t.exe %t.obj
-# RUN: not lld -flavor link2 /out:%t.exe %t.obj /include:xyz >& %t.log
-# RUN: FileCheck %s < %t.log
+# RUN: lld -flavor link2 /out:%t.exe %t.obj /verbose >& %t.log
+### FileCheck doesn't like empty input, so write something.
+# RUN: echo dummy >> %t.log
+# RUN: FileCheck -check-prefix=CHECK1 %s < %t.log
-CHECK: undefined symbol: xyz
+# RUN: lld -flavor link2 /out:%t.exe %t.obj /verbose /include:unused >& %t.log
+# RUN: echo dummy >> %t.log
+# RUN: FileCheck -check-prefix=CHECK2 %s < %t.log
+
+# CHECK1: Discarded unused
+# CHECK2-NOT: Discarded unused
+
+---
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: []
+sections:
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: B82A000000C3
+ - Name: '.text$mn'
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: B82A000000C3
+symbols:
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_ANY
+ - Name: '.text$mn'
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 6
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+ Selection: IMAGE_COMDAT_SELECT_ANY
+ - Name: mainCRTStartup
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: unused
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_FUNCTION
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
More information about the llvm-commits
mailing list