diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-09-23 21:04:56 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-09-23 21:04:56 +0000 |
commit | 251e240adcc8fd81a17d7ce0ef12f0b4308f2aa9 (patch) | |
tree | 1eabb8a3389f985b9e6f6844bf881faf4d1b6a5b | |
parent | ac9fbf9085f65b3730415f436c912a7e2b046644 (diff) | |
download | bcm5719-llvm-251e240adcc8fd81a17d7ce0ef12f0b4308f2aa9.tar.gz bcm5719-llvm-251e240adcc8fd81a17d7ce0ef12f0b4308f2aa9.zip |
Warn if we can't find the entry symbol.
Fixes pr30465.
llvm-svn: 282295
-rw-r--r-- | lld/ELF/Driver.cpp | 11 | ||||
-rw-r--r-- | lld/test/ELF/entry.s | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 9f13ca66750..b27b33e49d8 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -665,17 +665,22 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { // 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 diff --git a/lld/test/ELF/entry.s b/lld/test/ELF/entry.s index 9dc355288cd..aef71c62f9a 100644 --- a/lld/test/ELF/entry.s +++ b/lld/test/ELF/entry.s @@ -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 |