Skip to content

Commit bf447a5

Browse files
author
George Rimar
committed
[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
1 parent 7b4fce1 commit bf447a5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# RUN: yaml2obj %s > %t1
55
# RUN: not llvm-objcopy -R .data %t1 2>&1 | FileCheck %s
6-
# CHECK: error: Section .data cannot be removed because of symbol 'foo' used by the relocation patching offset 0x1 from section .rela.text.
6+
# CHECK: error: Section .data can't be removed: (.text+0x1) has relocation against symbol 'foo'
77

88
## Check the behavior when we also remove the relocation section.
99
## We have no reference in this case and hence no error should be emitted.

llvm/tools/llvm-objcopy/ELF/Object.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,12 @@ Error RelocationSection::removeSectionReferences(
557557
for (const Relocation &R : Relocations) {
558558
if (!R.RelocSymbol->DefinedIn || !ToRemove(R.RelocSymbol->DefinedIn))
559559
continue;
560-
return createStringError(
561-
llvm::errc::invalid_argument,
562-
"Section %s cannot be removed because of symbol '%s' "
563-
"used by the relocation patching offset 0x%" PRIx64 " from section %s.",
564-
R.RelocSymbol->DefinedIn->Name.data(), R.RelocSymbol->Name.c_str(),
565-
R.Offset, this->Name.data());
560+
return createStringError(llvm::errc::invalid_argument,
561+
"Section %s can't be removed: (%s+0x%" PRIx64
562+
") has relocation against symbol '%s'",
563+
R.RelocSymbol->DefinedIn->Name.data(),
564+
SecToApplyRel->Name.data(), R.Offset,
565+
R.RelocSymbol->Name.c_str());
566566
}
567567

568568
return Error::success();

0 commit comments

Comments
 (0)