[lld] r189318 - [PECOFF] Add the entry symbol and /include symbols to dead strip root set.
Rui Ueyama
ruiu at google.com
Mon Aug 26 22:15:20 PDT 2013
Author: ruiu
Date: Tue Aug 27 00:15:20 2013
New Revision: 189318
URL: http://llvm.org/viewvc/llvm-project?rev=189318&view=rev
Log:
[PECOFF] Add the entry symbol and /include symbols to dead strip root set.
Differential Revision: http://llvm-reviews.chandlerc.com/D1527
Modified:
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/test/pecoff/base-reloc.test
lld/trunk/test/pecoff/baseaddr.test
lld/trunk/test/pecoff/comdat.test
lld/trunk/test/pecoff/dynamicbase.test
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=189318&r1=189317&r2=189318&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Aug 27 00:15:20 2013
@@ -436,6 +436,15 @@ bool WinLinkDriver::parse(int argc, cons
return true;
}
+ // If dead-stripping is enabled, we need to add the entry symbol and
+ // symbols given by /include to the dead strip root set, so that it
+ // won't be removed from the output.
+ if (ctx.deadStrip()) {
+ ctx.addDeadStripRoot(ctx.entrySymbolName());
+ for (const StringRef symbolName : ctx.initialUndefinedSymbols())
+ ctx.addDeadStripRoot(symbolName);
+ }
+
// Arguments after "--" are interpreted as filenames even if they
// start with a hypen or a slash. This is not compatible with link.exe
// but useful for us to test lld on Unix.
Modified: lld/trunk/test/pecoff/base-reloc.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/base-reloc.test?rev=189318&r1=189317&r2=189318&view=diff
==============================================================================
--- lld/trunk/test/pecoff/base-reloc.test (original)
+++ lld/trunk/test/pecoff/base-reloc.test Tue Aug 27 00:15:20 2013
@@ -19,12 +19,12 @@ BASEREL-SECTION-NEXT: 3000 00100000 0c0
NOBASEREL-SECTION-NOT: Contents of section .reloc:
-# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
-# RUN: && llvm-readobj -file-headers %t1 \
+# RUN: lld -flavor link /out:%t1 /subsystem:console /force /opt:noref \
+# RUN: -- %t.obj && llvm-readobj -file-headers %t1 \
# RUN: | FileCheck %s --check-prefix=BASEREL-HEADER
#
-# RUN: lld -flavor link /out:%t1 /subsystem:console /force /fixed -- %t.obj \
-# RUN: && llvm-readobj -file-headers %t1 \
+# RUN: lld -flavor link /out:%t1 /subsystem:console /force /opt:noref /fixed \
+# RUN: -- %t.obj && llvm-readobj -file-headers %t1 \
# RUN: | FileCheck %s --check-prefix=NOBASEREL-HEADER
BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_STRIPPED
Modified: lld/trunk/test/pecoff/baseaddr.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/baseaddr.test?rev=189318&r1=189317&r2=189318&view=diff
==============================================================================
--- lld/trunk/test/pecoff/baseaddr.test (original)
+++ lld/trunk/test/pecoff/baseaddr.test Tue Aug 27 00:15:20 2013
@@ -1,9 +1,9 @@
# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
#
-# RUN: lld -flavor link /out:%t1 -- %t.obj \
+# RUN: lld -flavor link /out:%t1 /opt:noref -- %t.obj \
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=DEFAULT %s
#
-# RUN: lld -flavor link /out:%t1 /base:8388608 -- %t.obj \
+# RUN: lld -flavor link /out:%t1 /opt:noref /base:8388608 -- %t.obj \
# RUN: && llvm-readobj -file-headers %t1 | FileCheck -check-prefix=BASE %s
DEFAULT: ImageBase: 0x400000
Modified: lld/trunk/test/pecoff/comdat.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/comdat.test?rev=189318&r1=189317&r2=189318&view=diff
==============================================================================
--- lld/trunk/test/pecoff/comdat.test (original)
+++ lld/trunk/test/pecoff/comdat.test Tue Aug 27 00:15:20 2013
@@ -1,7 +1,7 @@
# RUN: yaml2obj %p/Inputs/comdat.obj.yaml > %t1.obj
# RUN: yaml2obj %p/Inputs/comdat.obj.yaml > %t2.obj
#
-# RUN: lld -flavor link /out:%t3.exe /subsystem:console /force \
+# RUN: lld -flavor link /out:%t3.exe /subsystem:console /opt:noref /force \
# RUN: -- %t1.obj %t2.obj 2>&1 > %t.log
#
# FileCheck complains if the input files is empty, so add a dummy line.
Modified: lld/trunk/test/pecoff/dynamicbase.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/dynamicbase.test?rev=189318&r1=189317&r2=189318&view=diff
==============================================================================
--- lld/trunk/test/pecoff/dynamicbase.test (original)
+++ lld/trunk/test/pecoff/dynamicbase.test Tue Aug 27 00:15:20 2013
@@ -1,19 +1,20 @@
# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t.obj
#
-# RUN: lld -flavor link /out:%t1 /subsystem:console /force -- %t.obj \
-# RUN: && llvm-readobj -file-headers %t1 \
+# RUN: lld -flavor link /out:%t1 /subsystem:console /opt:noref /force \
+# RUN: -- %t.obj && llvm-readobj -file-headers %t1 \
# RUN: | FileCheck %s --check-prefix=DYNAMICBASE
#
-# RUN: lld -flavor link /out:%t1 /subsystem:console /force /dynamicbase:no \
-# RUN: -- %t.obj && llvm-readobj -file-headers %t1 \
+# RUN: lld -flavor link /out:%t1 /subsystem:console /opt:noref /force \
+# RUN: /dynamicbase:no -- %t.obj && llvm-readobj -file-headers %t1 \
# RUN: | FileCheck %s --check-prefix=NODYNAMICBASE
#
-# RUN: lld -flavor link /out:%t1 /subsystem:console /force /fixed -- %t.obj \
-# RUN: && llvm-readobj -file-headers %t1 \
+# RUN: lld -flavor link /out:%t1 /subsystem:console /opt:noref /force \
+# RUN: /fixed -- %t.obj && llvm-readobj -file-headers %t1 \
# RUN: | FileCheck %s --check-prefix=NODYNAMICBASE
#
-# RUN: not lld -flavor link /out:%t1 /subsystem:console /force /fixed \
-# RUN: /dynamicbase -- %t.obj 2>&1 | FileCheck %s --check-prefix=DYNAMIC-AND-FIXED
+# RUN: not lld -flavor link /out:%t1 /subsystem:console /opt:noref /force \
+# RUN: /fixed /dynamicbase -- %t.obj 2>&1 \
+# RUN: | FileCheck %s --check-prefix=DYNAMIC-AND-FIXED
DYNAMICBASE: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
More information about the llvm-commits
mailing list