Make error messages more consistent with other messages.

llvm-svn: 293095
This commit is contained in:
Rui Ueyama 2017-01-25 21:27:59 +00:00
parent 2467df6e4f
commit 965bed8b82
2 changed files with 10 additions and 8 deletions

View File

@ -45,7 +45,10 @@ using namespace llvm::support::endian;
using namespace llvm::ELF;
std::string lld::toString(uint32_t Type) {
return getELFRelocationTypeName(elf::Config->EMachine, Type);
StringRef S = getELFRelocationTypeName(elf::Config->EMachine, Type);
if (S == "Unknown")
return ("Unknown (" + Twine(Type) + ")").str();
return S;
}
namespace lld {
@ -390,8 +393,7 @@ RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
case R_386_NONE:
return R_HINT;
default:
error("do not know how to handle relocation '" + toString(Type) + "' (" +
Twine(Type) + ")");
error("unknown relocation type: " + toString(Type));
return R_HINT;
}
}
@ -672,8 +674,7 @@ RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
case R_X86_64_NONE:
return R_HINT;
default:
error("do not know how to handle relocation '" + toString(Type) + "' (" +
Twine(Type) + ")");
error("unknown relocation type: " + toString(Type));
return R_HINT;
}
}
@ -1626,7 +1627,8 @@ RelExpr AMDGPUTargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
case R_AMDGPU_GOTPCREL32_HI:
return R_GOT_PC;
default:
fatal("do not know how to handle relocation " + Twine(Type));
error("unknown relocation type: " + toString(Type));
return R_HINT;
}
}

View File

@ -26,5 +26,5 @@ Sections:
Type: R_X86_64_NONE
# RUN: not ld.lld %p/Inputs/invalid-relocation-x64.elf -o %t2 2>&1 | FileCheck %s
# CHECK: do not know how to handle relocation 'Unknown' (152)
# CHECK: do not know how to handle relocation 'Unknown' (153)
# CHECK: unknown relocation type: Unknown (152)
# CHECK: unknown relocation type: Unknown (153)