summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorOliver Stannard <oliver.stannard@arm.com>2015-11-17 10:00:43 +0000
committerOliver Stannard <oliver.stannard@arm.com>2015-11-17 10:00:43 +0000
commit9be59af3abe0b3bbee54e46720a75c96723da6cb (patch)
treed7b87d3a7144c56e73294288efcbd24109e3426e /llvm/lib/MC/ELFObjectWriter.cpp
parent07b43d39a8ef5be442210c5ca21c780c19db0683 (diff)
downloadbcm5719-llvm-9be59af3abe0b3bbee54e46720a75c96723da6cb.tar.gz
bcm5719-llvm-9be59af3abe0b3bbee54e46720a75c96723da6cb.zip
[Assembler] Make fatal assembler errors non-fatal
Currently, if the assembler encounters an error after parsing (such as an out-of-range fixup), it reports this as a fatal error, and so stops after the first error. However, for most of these there is an obvious way to recover after emitting the error, such as emitting the fixup with a value of zero. This means that we can report on all of the errors in a file, not just the first one. MCContext::reportError records the fact that an error was encountered, so we won't actually emit an object file with the incorrect contents. Differential Revision: http://reviews.llvm.org/D14717 llvm-svn: 253328
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 230d3d775b1..df7a606a717 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -630,28 +630,36 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
// In general, ELF has no relocations for -B. It can only represent (A + C)
// or (A + C - R). If B = R + K and the relocation is not pcrel, we can
// replace B to implement it: (A - R - K + C)
- if (IsPCRel)
- Asm.getContext().reportFatalError(
+ if (IsPCRel) {
+ Asm.getContext().reportError(
Fixup.getLoc(),
"No relocation available to represent this relative expression");
+ return;
+ }
const auto &SymB = cast<MCSymbolELF>(RefB->getSymbol());
- if (SymB.isUndefined())
- Asm.getContext().reportFatalError(
+ if (SymB.isUndefined()) {
+ Asm.getContext().reportError(
Fixup.getLoc(),
Twine("symbol '") + SymB.getName() +
"' can not be undefined in a subtraction expression");
+ return;
+ }
assert(!SymB.isAbsolute() && "Should have been folded");
const MCSection &SecB = SymB.getSection();
- if (&SecB != &FixupSection)
- Asm.getContext().reportFatalError(
+ if (&SecB != &FixupSection) {
+ Asm.getContext().reportError(
Fixup.getLoc(), "Cannot represent a difference across sections");
+ return;
+ }
- if (::isWeak(SymB))
- Asm.getContext().reportFatalError(
+ if (::isWeak(SymB)) {
+ Asm.getContext().reportError(
Fixup.getLoc(), "Cannot represent a subtraction with a weak symbol");
+ return;
+ }
uint64_t SymBOffset = Layout.getSymbolOffset(SymB);
uint64_t K = SymBOffset - FixupOffset;
@@ -784,8 +792,10 @@ void ELFObjectWriter::computeSymbolTable(
Renames.count(&Symbol)))
continue;
- if (Symbol.isTemporary() && Symbol.isUndefined())
- Ctx.reportFatalError(SMLoc(), "Undefined temporary");
+ if (Symbol.isTemporary() && Symbol.isUndefined()) {
+ Ctx.reportError(SMLoc(), "Undefined temporary symbol");
+ continue;
+ }
ELFSymbolData MSD;
MSD.Symbol = cast<MCSymbolELF>(&Symbol);
OpenPOWER on IntegriCloud