[lld] r218706 - [PECOFF] Fix /entry option.
Rui Ueyama
ruiu at google.com
Tue Sep 30 14:39:49 PDT 2014
Author: ruiu
Date: Tue Sep 30 16:39:49 2014
New Revision: 218706
URL: http://llvm.org/viewvc/llvm-project?rev=218706&view=rev
Log:
[PECOFF] Fix /entry option.
This is yet another edge case of ambiguous name resolution.
When a symbol is specified with /entry:SYM, SYM may be resolved
to the C++ mangled function name (?SYM@@YAXXZ).
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
lld/trunk/test/pecoff/Inputs/entry.obj.yaml
lld/trunk/test/pecoff/entry.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h?rev=218706&r1=218705&r2=218706&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h Tue Sep 30 16:39:49 2014
@@ -298,7 +298,7 @@ private:
_firstTime = false;
if (_ctx->hasEntry()) {
- StringRef entrySym = _ctx->allocate(_ctx->decorateSymbol(getEntry()));
+ StringRef entrySym = _ctx->allocate(getEntry());
_undefinedAtoms._atoms.push_back(
new (_alloc) SimpleUndefinedAtom(*this, entrySym));
_ctx->setHasEntry(true);
@@ -313,9 +313,16 @@ private:
// subsystem if it's unknown.
std::string getEntry() const {
StringRef opt = _ctx->getEntrySymbolName();
- if (!opt.empty())
- return opt;
+ if (!opt.empty()) {
+ std::string mangled;
+ if (findDecoratedSymbol(_ctx, _syms.get(), opt, mangled))
+ return mangled;
+ return _ctx->decorateSymbol(opt);
+ }
+ return _ctx->decorateSymbol(getDefaultEntry());
+ }
+ std::string getDefaultEntry() const {
const std::string wWinMainCRTStartup = "wWinMainCRTStartup";
const std::string WinMainCRTStartup = "WinMainCRTStartup";
const std::string wmainCRTStartup = "wmainCRTStartup";
Modified: lld/trunk/test/pecoff/Inputs/entry.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/entry.obj.yaml?rev=218706&r1=218705&r2=218706&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/entry.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/entry.obj.yaml Tue Sep 30 16:39:49 2014
@@ -30,4 +30,11 @@ symbols:
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+
+ - Name: "?baz@@YAXXZ"
+ Value: 4
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
...
Modified: lld/trunk/test/pecoff/entry.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/entry.test?rev=218706&r1=218705&r2=218706&view=diff
==============================================================================
--- lld/trunk/test/pecoff/entry.test (original)
+++ lld/trunk/test/pecoff/entry.test Tue Sep 30 16:39:49 2014
@@ -31,3 +31,8 @@ WWINMAIN: _wWinMainCRTStartup
# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=MAINADDR %s
MAINADDR: AddressOfEntryPoint: 0x1004
+
+# RUN: lld -flavor link /out:%t.exe /subsystem:console /entry:baz -- %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=MANGLE %s
+
+MANGLE: AddressOfEntryPoint: 0x1004
More information about the llvm-commits
mailing list