Skip to content

Commit 71693ac

Browse files
committed
[LLD] [MinGW] Interpret an empty -entry option as no entry point
This fixes #93309, and seems to match how GNU ld handles this case. Also treat a missing -entry argument as no entry point; this also is what GNU ld does in this case.
1 parent fe9aef0 commit 71693ac

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lld/MinGW/Driver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,12 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
223223
StringRef s = a->getValue();
224224
if (args.getLastArgValue(OPT_m) == "i386pe" && s.starts_with("_"))
225225
add("-entry:" + s.substr(1));
226-
else
226+
else if (!s.empty())
227227
add("-entry:" + s);
228+
else
229+
add("-noentry");
230+
} else {
231+
add("-noentry");
228232
}
229233

230234
if (args.hasArg(OPT_major_os_version, OPT_minor_os_version,

lld/test/MinGW/driver.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ RUN: ld.lld -### foo.o -m i386pep --entry bar 2>&1 | FileCheck -check-prefix=ENT
6060
RUN: ld.lld -### foo.o -m i386pep -entry=bar 2>&1 | FileCheck -check-prefix=ENTRY %s
6161
RUN: ld.lld -### foo.o -m i386pep --entry=bar 2>&1 | FileCheck -check-prefix=ENTRY %s
6262
ENTRY: -entry:bar
63+
RUN: ld.lld -### foo.o -m i386pep -e bar -entry= 2>&1 | FileCheck -check-prefix=NOENTRY --implicit-check-not=-entry %s
64+
RUN: ld.lld -### foo.o -m i386pep 2>&1 | FileCheck -check-prefix=NOENTRY %s
65+
NOENTRY: -noentry
6366

6467
RUN: ld.lld -### foo.o -m i386pep -mllvm bar -mllvm baz 2>&1 | FileCheck -check-prefix=MLLVM %s
6568
MLLVM: -mllvm:bar -mllvm:baz

0 commit comments

Comments
 (0)