From 84915dc50779e001497825ce62c8f1caa53577c6 Mon Sep 17 00:00:00 2001 From: dim Date: Sat, 16 Feb 2019 19:49:12 +0000 Subject: [PATCH] MFC r344112: Pull in r353907 from upstream llvm trunk (by Reid Kleckner): [MC] Make symbol version errors non-fatal We stil don't have a source location, which is pretty lame, but at least we won't tell the user to file a clang bug report anymore. Fixes PR40712 This will make errors for symbols with @@ versions that are not defined non-fatal. For example: void f(void) { __asm__(".symver foo,bar@@baz"); } will now result in: error: versioned symbol bar@@baz must be defined instead of clang crashing with a diagnostic report. PR: 234671 Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=40712 --- contrib/llvm/lib/MC/ELFObjectWriter.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/contrib/llvm/lib/MC/ELFObjectWriter.cpp b/contrib/llvm/lib/MC/ELFObjectWriter.cpp index db531f75c87..b23333e4756 100644 --- a/contrib/llvm/lib/MC/ELFObjectWriter.cpp +++ b/contrib/llvm/lib/MC/ELFObjectWriter.cpp @@ -1258,14 +1258,20 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm, if (!Symbol.isUndefined() && !Rest.startswith("@@@")) continue; - // FIXME: produce a better error message. + // FIXME: Get source locations for these errors or diagnose them earlier. if (Symbol.isUndefined() && Rest.startswith("@@") && - !Rest.startswith("@@@")) - report_fatal_error("A @@ version cannot be undefined"); + !Rest.startswith("@@@")) { + Asm.getContext().reportError(SMLoc(), "versioned symbol " + AliasName + + " must be defined"); + continue; + } - if (Renames.count(&Symbol) && Renames[&Symbol] != Alias) - report_fatal_error(llvm::Twine("Multiple symbol versions defined for ") + - Symbol.getName()); + if (Renames.count(&Symbol) && Renames[&Symbol] != Alias) { + Asm.getContext().reportError( + SMLoc(), llvm::Twine("multiple symbol versions defined for ") + + Symbol.getName()); + continue; + } Renames.insert(std::make_pair(&Symbol, Alias)); } -- 2.45.0