StringRef entrySym = _ctx->allocate(_ctx->decorateSymbol(getEntry()));
_undefinedAtoms._atoms.push_back(
new (_alloc) SimpleUndefinedAtom(*this, entrySym));
+ _ctx->setHasEntry(true);
+ _ctx->setEntrySymbolName(entrySym);
if (_ctx->deadStrip())
_ctx->addDeadStripRoot(entrySym);
}
// Find the virtual address of the entry point symbol if any. PECOFF spec
// says that entry point for dll images is optional, in which case it must
// be set to 0.
- if (_ctx.entrySymbolName().empty() && _ctx.isDll()) {
- peHeader->setAddressOfEntryPoint(0);
- } else {
+ if (_ctx.hasEntry()) {
uint64_t entryPointAddress =
dyn_cast<AtomChunk>(section)
- ->getAtomVirtualAddress(_ctx.entrySymbolName());
+ ->getAtomVirtualAddress(_ctx.getEntrySymbolName());
if (entryPointAddress != 0)
peHeader->setAddressOfEntryPoint(entryPointAddress);
+ } else {
+ peHeader->setAddressOfEntryPoint(0);
}
}
if (section->getSectionName() == ".data")
SimpleType: IMAGE_SYM_TYPE_NULL
ComplexType: IMAGE_SYM_DTYPE_NULL
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+
+ - Name: _bar
+ Value: 4
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
...
# RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log
WWINMAIN: _wWinMainCRTStartup
+
+# RUN: lld -flavor link /out:%t.exe /alternatename:_main=_foo \
+# RUN: /alternatename:_mainCRTStartup=_bar -- %t.obj
+# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=MAINADDR %s
+
+MAINADDR: AddressOfEntryPoint: 0x1004