]> granicus.if.org Git - llvm/commitdiff
[llvm-objdump] - Improve the error message for "removing a section that is used by...
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 28 Feb 2019 08:21:50 +0000 (08:21 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 28 Feb 2019 08:21:50 +0000 (08:21 +0000)
This refines/improves the error message introduced in D58625

Differential revision: https://reviews.llvm.org/D58709

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355074 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-objcopy/ELF/strip-section-err.test
tools/llvm-objcopy/ELF/Object.cpp

index f95185aba62131b8ac56151803136b1bfbec9560..9bcea100bb99847a8c97aee570f020a53b704a47 100644 (file)
@@ -3,7 +3,7 @@
 
 # RUN: yaml2obj %s > %t1
 # RUN: not llvm-objcopy -R .data %t1 2>&1 | FileCheck %s
-# CHECK: error: Section .data cannot be removed because of symbol 'foo' used by the relocation patching offset 0x1 from section .rela.text.
+# CHECK: error: Section .data can't be removed: (.text+0x1) has relocation against symbol 'foo'
 
 ## Check the behavior when we also remove the relocation section.
 ## We have no reference in this case and hence no error should be emitted.
index a3ddfbec35d9023a89c5792026507352a6416caf..e2944ae3e24f8ab2f44b0044b97445e77d61e086 100644 (file)
@@ -557,12 +557,12 @@ Error RelocationSection::removeSectionReferences(
   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();