Skip to content

Commit

Permalink
Merging r353907:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
r353907 | rnk | 2019-02-13 02:39:32 +0100 (Wed, 13 Feb 2019) | 6 lines

[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
------------------------------------------------------------------------

llvm-svn: 354257
  • Loading branch information
zmodem committed Feb 18, 2019
1 parent 81bd9db commit 6051407
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions llvm/lib/MC/ELFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,14 +1275,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));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/ELF/invalid-symver.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t 2> %t.out
// RUN: FileCheck --input-file=%t.out %s

// CHECK: A @@ version cannot be undefined
// CHECK: error: versioned symbol foo@@bar must be defined

.symver undefined, foo@@bar
.long undefined
2 changes: 1 addition & 1 deletion llvm/test/MC/ELF/multiple-different-symver.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t 2>&1 | FileCheck %s

// CHECK: Multiple symbol versions defined for foo
// CHECK: error: multiple symbol versions defined for foo

.symver foo, foo@1
.symver foo, foo@2

0 comments on commit 6051407

Please sign in to comment.