[PATCH] D58709: [llvm-objdump] - Improve the error message for "removing a section that is used by relocation" case.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 28 00:21:16 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL355074: [llvm-objdump] - Improve the error message for "removing a section that is used… (authored by grimar, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D58709?vs=188511&id=188682#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58709/new/

https://reviews.llvm.org/D58709

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


Index: llvm/trunk/test/tools/llvm-objcopy/ELF/strip-section-err.test
===================================================================
--- llvm/trunk/test/tools/llvm-objcopy/ELF/strip-section-err.test
+++ llvm/trunk/test/tools/llvm-objcopy/ELF/strip-section-err.test
@@ -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: llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp
===================================================================
--- llvm/trunk/tools/llvm-objcopy/ELF/Object.cpp
+++ llvm/trunk/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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58709.188682.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190228/c183a68a/attachment.bin>


More information about the llvm-commits mailing list