diff options
| author | Rui Ueyama <ruiu@google.com> | 2013-08-27 05:15:20 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2013-08-27 05:15:20 +0000 |
| commit | 488d41e6ef15db0d646b8d770eb3ab11cf47f23f (patch) | |
| tree | 76a5f8302abbf1b607e684a8b39db063b58415d6 | |
| parent | 510938e5283ac05b0b9fa52e0bd39695ca0f6531 (diff) | |
| download | bcm5719-llvm-488d41e6ef15db0d646b8d770eb3ab11cf47f23f.tar.gz bcm5719-llvm-488d41e6ef15db0d646b8d770eb3ab11cf47f23f.zip | |
[PECOFF] Add the entry symbol and /include symbols to dead strip root set.
Differential Revision: http://llvm-reviews.chandlerc.com/D1527
llvm-svn: 189318
| -rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 9 | ||||
| -rw-r--r-- | lld/test/pecoff/base-reloc.test | 8 | ||||
| -rw-r--r-- | lld/test/pecoff/baseaddr.test | 4 | ||||
| -rw-r--r-- | lld/test/pecoff/comdat.test | 2 | ||||
| -rw-r--r-- | lld/test/pecoff/dynamicbase.test | 17 |
5 files changed, 25 insertions, 15 deletions
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 1a0602c5848..a49c8c9944b 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -436,6 +436,15 @@ bool WinLinkDriver::parse(int argc, const char *argv[], 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. diff --git a/lld/test/pecoff/base-reloc.test b/lld/test/pecoff/base-reloc.test index e9214f057e4..0b9d399c5d2 100644 --- a/lld/test/pecoff/base-reloc.test +++ b/lld/test/pecoff/base-reloc.test @@ -19,12 +19,12 @@ BASEREL-SECTION-NEXT: 3000 00100000 0c000000 07300c30 00000000 .........0.0... 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 diff --git a/lld/test/pecoff/baseaddr.test b/lld/test/pecoff/baseaddr.test index f1baa3627ea..a5dea32bdbb 100644 --- a/lld/test/pecoff/baseaddr.test +++ b/lld/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 diff --git a/lld/test/pecoff/comdat.test b/lld/test/pecoff/comdat.test index 20729514dfe..733317408a9 100644 --- a/lld/test/pecoff/comdat.test +++ b/lld/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. diff --git a/lld/test/pecoff/dynamicbase.test b/lld/test/pecoff/dynamicbase.test index c185b77c9c9..52eaae75ff0 100644 --- a/lld/test/pecoff/dynamicbase.test +++ b/lld/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 |

