[llvm-objdump] - Improve the error message for "removing a section that is used by relocation" case.
This refines/improves the error message introduced in D58625
Differential revision: https://reviews.llvm.org/D58709
llvm-svn: 355074
diff --git a/llvm/tools/llvm-objcopy/ELF/Object.cpp b/llvm/tools/llvm-objcopy/ELF/Object.cpp
index a3ddfbe..e2944ae 100644
--- a/llvm/tools/llvm-objcopy/ELF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/Object.cpp
@@ -557,12 +557,12 @@
for (const Relocation &R : Relocations) {
if (!R.RelocSymbol->DefinedIn || !ToRemove(R.RelocSymbol->DefinedIn))
continue;
- return createStringError(
- llvm::errc::invalid_argument,
- "Section %s cannot be removed because of symbol '%s' "
- "used by the relocation patching offset 0x%" PRIx64 " from section %s.",
- R.RelocSymbol->DefinedIn->Name.data(), R.RelocSymbol->Name.c_str(),
- R.Offset, this->Name.data());
+ return createStringError(llvm::errc::invalid_argument,
+ "Section %s can't be removed: (%s+0x%" PRIx64
+ ") has relocation against symbol '%s'",
+ R.RelocSymbol->DefinedIn->Name.data(),
+ SecToApplyRel->Name.data(), R.Offset,
+ R.RelocSymbol->Name.c_str());
}
return Error::success();