[lld] r259107 - ELF: Report more than one undefined symbols if exist.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 28 14:56:29 PST 2016
Author: ruiu
Date: Thu Jan 28 16:56:29 2016
New Revision: 259107
URL: http://llvm.org/viewvc/llvm-project?rev=259107&view=rev
Log:
ELF: Report more than one undefined symbols if exist.
http://reviews.llvm.org/D16643
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/undef.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259107&r1=259106&r2=259107&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Jan 28 16:56:29 2016
@@ -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>:
if (!Config->DiscardAll)
copyLocalSymbols();
addReservedSymbols();
- createSections();
+ if (!createSections())
+ return;
assignAddresses();
fixAbsoluteSymbols();
openFile(Config->OutputFile);
@@ -382,7 +383,7 @@ static void reportUndefined(SymbolTable<
if (Config->NoInhibitExec)
warning(Msg);
else
- fatal(Msg);
+ error(Msg);
}
template <class ELFT>
@@ -796,7 +797,7 @@ template <class ELFT> void Writer<ELFT>:
}
// 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>:
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>:
for (OutputSectionBase<ELFT> *Sec : OutputSections)
if (Sec != Out<ELFT>::DynStrTab)
Sec->finalize();
+ return true;
}
// This function add Out<ELFT>::* sections to OutputSections.
Modified: lld/trunk/test/ELF/undef.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/undef.s?rev=259107&r1=259106&r2=259107&view=diff
==============================================================================
--- lld/trunk/test/ELF/undef.s (original)
+++ lld/trunk/test/ELF/undef.s Thu Jan 28 16:56:29 2016
@@ -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
More information about the llvm-commits
mailing list