[lld] r282295 - Warn if we can't find the entry symbol.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 14:04:56 PDT 2016
Author: rafael
Date: Fri Sep 23 16:04:56 2016
New Revision: 282295
URL: http://llvm.org/viewvc/llvm-project?rev=282295&view=rev
Log:
Warn if we can't find the entry symbol.
Fixes pr30465.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/entry.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=282295&r1=282294&r2=282295&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Sep 23 16:04:56 2016
@@ -665,17 +665,22 @@ template <class ELFT> void LinkerDriver:
// Add the start symbol.
// It initializes either Config->Entry or Config->EntryAddr.
// Note that AMDGPU binaries have no entries.
+ bool HasEntryAddr = false;
if (!Config->Entry.empty()) {
// It is either "-e <addr>" or "-e <symbol>".
- Config->Entry.getAsInteger(0, Config->EntryAddr);
+ HasEntryAddr = !Config->Entry.getAsInteger(0, Config->EntryAddr);
} else if (!Config->Shared && !Config->Relocatable &&
Config->EMachine != EM_AMDGPU) {
// -e was not specified. Use the default start symbol name
// if it is resolvable.
Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
}
- if (Symtab.find(Config->Entry))
- Config->EntrySym = Symtab.addUndefined(Config->Entry);
+ if (!HasEntryAddr) {
+ if (Symtab.find(Config->Entry))
+ Config->EntrySym = Symtab.addUndefined(Config->Entry);
+ else
+ warning("entry symbol " + Config->Entry + " not found, assuming 0");
+ }
if (HasError)
return; // There were duplicate symbols or incompatible files
Modified: lld/trunk/test/ELF/entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/entry.s?rev=282295&r1=282294&r2=282295&view=diff
==============================================================================
--- lld/trunk/test/ELF/entry.s (original)
+++ lld/trunk/test/ELF/entry.s Fri Sep 23 16:04:56 2016
@@ -1,5 +1,5 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
-# RUN: ld.lld %t1 -o %t2
+# RUN: ld.lld -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN %s
# RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=NOENTRY %s
# RUN: ld.lld %t1 -o %t2 -e entry
# RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=SYM %s
@@ -12,6 +12,8 @@
# RUN: ld.lld %t1 -o %t2 -e 0777
# RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=OCT %s
+# WARN: entry symbol foobar not found, assuming 0
+
# NOENTRY: Entry: 0x0
# SYM: Entry: 0x11000
# DSO: Entry: 0x1000
More information about the llvm-commits
mailing list