forked from OSchip/llvm-project
[MC] Report locations for .symver errors
This commit is contained in:
parent
f314bcffa3
commit
553d4d08d2
|
@ -211,7 +211,12 @@ private:
|
|||
handleFixup(const MCAsmLayout &Layout, MCFragment &F, const MCFixup &Fixup);
|
||||
|
||||
public:
|
||||
std::vector<std::pair<StringRef, const MCSymbol *>> Symvers;
|
||||
struct Symver {
|
||||
StringRef Name;
|
||||
const MCSymbol *Sym;
|
||||
SMLoc Loc;
|
||||
};
|
||||
std::vector<Symver> Symvers;
|
||||
|
||||
/// Construct a new assembler instance.
|
||||
//
|
||||
|
|
|
@ -1258,9 +1258,9 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
|
|||
const MCAsmLayout &Layout) {
|
||||
// The presence of symbol versions causes undefined symbols and
|
||||
// versions declared with @@@ to be renamed.
|
||||
for (const std::pair<StringRef, const MCSymbol *> &P : Asm.Symvers) {
|
||||
StringRef AliasName = P.first;
|
||||
const auto &Symbol = cast<MCSymbolELF>(*P.second);
|
||||
for (const MCAssembler::Symver &S : Asm.Symvers) {
|
||||
StringRef AliasName = S.Name;
|
||||
const auto &Symbol = cast<MCSymbolELF>(*S.Sym);
|
||||
size_t Pos = AliasName.find('@');
|
||||
assert(Pos != StringRef::npos);
|
||||
|
||||
|
@ -1286,18 +1286,16 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
|
|||
if (!Symbol.isUndefined() && !Rest.startswith("@@@"))
|
||||
continue;
|
||||
|
||||
// FIXME: Get source locations for these errors or diagnose them earlier.
|
||||
if (Symbol.isUndefined() && Rest.startswith("@@") &&
|
||||
!Rest.startswith("@@@")) {
|
||||
Asm.getContext().reportError(SMLoc(), "versioned symbol " + AliasName +
|
||||
" must be defined");
|
||||
Asm.getContext().reportError(S.Loc, "default version symbol " +
|
||||
AliasName + " must be defined");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Renames.count(&Symbol) && Renames[&Symbol] != Alias) {
|
||||
Asm.getContext().reportError(
|
||||
SMLoc(), llvm::Twine("multiple symbol versions defined for ") +
|
||||
Symbol.getName());
|
||||
Asm.getContext().reportError(S.Loc, Twine("multiple versions for ") +
|
||||
Symbol.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -342,7 +342,8 @@ void MCELFStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
|||
|
||||
void MCELFStreamer::emitELFSymverDirective(StringRef AliasName,
|
||||
const MCSymbol *Aliasee) {
|
||||
getAssembler().Symvers.push_back({AliasName, Aliasee});
|
||||
getAssembler().Symvers.push_back(
|
||||
MCAssembler::Symver{AliasName, Aliasee, getStartTokLoc()});
|
||||
}
|
||||
|
||||
void MCELFStreamer::emitLocalCommonSymbol(MCSymbol *S, uint64_t Size,
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
// 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: error: versioned symbol foo@@bar must be defined
|
||||
|
||||
.symver undefined, foo@@bar
|
||||
.long undefined
|
|
@ -1,6 +0,0 @@
|
|||
// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK: error: multiple symbol versions defined for foo
|
||||
|
||||
.symver foo, foo@1
|
||||
.symver foo, foo@2
|
|
@ -1,6 +0,0 @@
|
|||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - 2>&1 | FileCheck %s
|
||||
|
||||
// CHECK-NOT: Multiple symbol versions defined for foo
|
||||
|
||||
.symver foo, foo@1
|
||||
.symver foo, foo@1
|
|
@ -0,0 +1,12 @@
|
|||
# RUN: not llvm-mc -filetype=obj -triple=x86_64 %s -o /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
|
||||
|
||||
# CHECK: {{.*}}.s:[[#@LINE+2]]:1: error: multiple versions for multi
|
||||
.symver multi, multi@1
|
||||
.symver multi, multi@2
|
||||
|
||||
.symver equiv, equiv@1
|
||||
.symver equiv, equiv@1
|
||||
|
||||
# CHECK: {{.*}}.s:[[#@LINE+1]]:1: error: default version symbol undefined@@v1 must be defined
|
||||
.symver undefined_2, undefined@@v1
|
||||
.long undefined_2
|
Loading…
Reference in New Issue