[PATCH] [PECOFF] Add the entry symbol and /include symbols to dead strip root set.
Rui Ueyama
ruiu at google.com
Mon Aug 26 22:09:13 PDT 2013
Hi shankarke,
As we discussed in r189307, these symbols need to be added to dead strip
root set.
http://llvm-reviews.chandlerc.com/D1527
Files:
lib/Driver/WinLinkDriver.cpp
test/pecoff/base-reloc.test
test/pecoff/baseaddr.test
test/pecoff/comdat.test
test/pecoff/dynamicbase.test
Index: lib/Driver/WinLinkDriver.cpp
===================================================================
--- lib/Driver/WinLinkDriver.cpp
+++ lib/Driver/WinLinkDriver.cpp
@@ -436,6 +436,15 @@
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.
Index: test/pecoff/base-reloc.test
===================================================================
--- test/pecoff/base-reloc.test
+++ test/pecoff/base-reloc.test
@@ -19,12 +19,12 @@
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
Index: test/pecoff/baseaddr.test
===================================================================
--- test/pecoff/baseaddr.test
+++ test/pecoff/baseaddr.test
@@ -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
Index: test/pecoff/comdat.test
===================================================================
--- test/pecoff/comdat.test
+++ test/pecoff/comdat.test
@@ -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.
Index: test/pecoff/dynamicbase.test
===================================================================
--- test/pecoff/dynamicbase.test
+++ test/pecoff/dynamicbase.test
@@ -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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1527.1.patch
Type: text/x-patch
Size: 4492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130826/90707399/attachment.bin>
More information about the llvm-commits
mailing list