diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index b4f06d5afaf8..85bb7f700fb2 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -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::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; } } diff --git a/lld/test/ELF/invalid/invalid-relocation-x64.s b/lld/test/ELF/invalid/invalid-relocation-x64.s index 4934874bf167..3abd636dcef2 100644 --- a/lld/test/ELF/invalid/invalid-relocation-x64.s +++ b/lld/test/ELF/invalid/invalid-relocation-x64.s @@ -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)