diff options
author | Rui Ueyama <ruiu@google.com> | 2016-01-28 22:56:29 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2016-01-28 22:56:29 +0000 |
commit | c2a0d7e351860e5fe3224e5c54805941f3897a8f (patch) | |
tree | 3d22823bb0630e66e70dbbb03f6f8a91cac3e390 | |
parent | 26e65817faf6cf4dae494bfa466523fe3efa3fa8 (diff) | |
download | bcm5719-llvm-c2a0d7e351860e5fe3224e5c54805941f3897a8f.tar.gz bcm5719-llvm-c2a0d7e351860e5fe3224e5c54805941f3897a8f.zip |
ELF: Report more than one undefined symbols if exist.
http://reviews.llvm.org/D16643
llvm-svn: 259107
-rw-r--r-- | lld/ELF/Writer.cpp | 15 | ||||
-rw-r--r-- | lld/test/ELF/undef.s | 4 |
2 files changed, 14 insertions, 5 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index fa0d1db5234..8655856aee9 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -43,7 +43,7 @@ public: private: void copyLocalSymbols(); void addReservedSymbols(); - void createSections(); + bool createSections(); void addPredefinedSections(); template <bool isRela> @@ -156,7 +156,8 @@ template <class ELFT> void Writer<ELFT>::run() { if (!Config->DiscardAll) copyLocalSymbols(); addReservedSymbols(); - createSections(); + if (!createSections()) + return; assignAddresses(); fixAbsoluteSymbols(); openFile(Config->OutputFile); @@ -382,7 +383,7 @@ static void reportUndefined(SymbolTable<ELFT> &Symtab, SymbolBody *Sym) { if (Config->NoInhibitExec) warning(Msg); else - fatal(Msg); + error(Msg); } template <class ELFT> @@ -796,7 +797,7 @@ template <class ELFT> void Writer<ELFT>::addReservedSymbols() { } // Create output section objects and add them to OutputSections. -template <class ELFT> void Writer<ELFT>::createSections() { +template <class ELFT> bool Writer<ELFT>::createSections() { // Add .interp first because some loaders want to see that section // on the first page of the executable file when loaded into memory. if (needsInterpSection()) @@ -887,6 +888,11 @@ template <class ELFT> void Writer<ELFT>::createSections() { if (isOutputDynamic() && includeInDynamicSymtab(*Body)) Out<ELFT>::DynSymTab->addSymbol(Body); } + + // Do not proceed if there was an undefined symbol. + if (HasError) + return false; + addCommonSymbols(CommonSymbols); addCopyRelSymbols(CopyRelSymbols); @@ -915,6 +921,7 @@ template <class ELFT> void Writer<ELFT>::createSections() { for (OutputSectionBase<ELFT> *Sec : OutputSections) if (Sec != Out<ELFT>::DynStrTab) Sec->finalize(); + return true; } // This function add Out<ELFT>::* sections to OutputSections. diff --git a/lld/test/ELF/undef.s b/lld/test/ELF/undef.s index 374c9c884d5..52dabf1c4c1 100644 --- a/lld/test/ELF/undef.s +++ b/lld/test/ELF/undef.s @@ -1,8 +1,10 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s +# CHECK: undefined symbol: bar in {{.*}} # CHECK: undefined symbol: foo in {{.*}} # REQUIRES: x86 - .globl _start; + .globl _start _start: call foo + call bar |