[lld] r350828 - Modify InputSectionBase::getLocation to add section and offset to every loc.
Sean Fertile via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 10 07:08:06 PST 2019
Author: sfertile
Date: Thu Jan 10 07:08:06 2019
New Revision: 350828
URL: http://llvm.org/viewvc/llvm-project?rev=350828&view=rev
Log:
Modify InputSectionBase::getLocation to add section and offset to every loc.
The section and offset can be very helpful in diagnosing certian errors.
For example on a relocation overflow or misalignment diagnostic:
test.c:(function foo): relocation R_PPC64_ADDR16_DS out of range: ...
The function foo can have many R_PPC64_ADDR16_DS relocations. Adding the offset
and section will identify exactly which relocation is causing the failure.
Differential Revision: https://reviews.llvm.org/D56453
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/ppc64-split-stack-adjust-overflow.s
lld/trunk/test/ELF/x86-64-reloc-error2.s
lld/trunk/test/ELF/x86-64-reloc-range-debug-loc.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=350828&r1=350827&r2=350828&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Jan 10 07:08:06 2019
@@ -288,14 +288,17 @@ Defined *InputSectionBase::getEnclosingF
// Returns a source location string. Used to construct an error message.
template <class ELFT>
std::string InputSectionBase::getLocation(uint64_t Offset) {
+ std::string SecAndOffset = (Name + "+0x" + utohexstr(Offset)).str();
+
// We don't have file for synthetic sections.
if (getFile<ELFT>() == nullptr)
- return (Config->OutputFile + ":(" + Name + "+0x" + utohexstr(Offset) + ")")
+ return (Config->OutputFile + ":(" + SecAndOffset + ")")
.str();
// First check if we can get desired values from debugging information.
if (Optional<DILineInfo> Info = getFile<ELFT>()->getDILineInfo(this, Offset))
- return Info->FileName + ":" + std::to_string(Info->Line);
+ return Info->FileName + ":" + std::to_string(Info->Line) + ":(" +
+ SecAndOffset + ")";
// File->SourceFile contains STT_FILE symbol that contains a
// source file name. If it's missing, we use an object file name.
@@ -304,10 +307,10 @@ std::string InputSectionBase::getLocatio
SrcFile = toString(File);
if (Defined *D = getEnclosingFunction<ELFT>(Offset))
- return SrcFile + ":(function " + toString(*D) + ")";
+ return SrcFile + ":(function " + toString(*D) + ": " + SecAndOffset + ")";
// If there's no symbol, print out the offset in the section.
- return (SrcFile + ":(" + Name + "+0x" + utohexstr(Offset) + ")").str();
+ return (SrcFile + ":(" + SecAndOffset + ")");
}
// This function is intended to be used for constructing an error message.
Modified: lld/trunk/test/ELF/ppc64-split-stack-adjust-overflow.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ppc64-split-stack-adjust-overflow.s?rev=350828&r1=350827&r2=350828&view=diff
==============================================================================
--- lld/trunk/test/ELF/ppc64-split-stack-adjust-overflow.s (original)
+++ lld/trunk/test/ELF/ppc64-split-stack-adjust-overflow.s Thu Jan 10 07:08:06 2019
@@ -20,7 +20,7 @@
# RUN: ld.lld %t1.o %t2.o -o %t --defsym __morestack=0x10010000 -split-stack-adjust-size 4096
# RUN: llvm-objdump -d %t | FileCheck %s
-# OVERFLOW: error: {{.*}}.o:(function caller): split-stack prologue adjustment overflows
+# OVERFLOW: error: {{.*}}.o:(function caller: .text+0x8): split-stack prologue adjustment overflows
.p2align 2
.global caller
Modified: lld/trunk/test/ELF/x86-64-reloc-error2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-error2.s?rev=350828&r1=350827&r2=350828&view=diff
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-error2.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-error2.s Thu Jan 10 07:08:06 2019
@@ -4,7 +4,7 @@
## Check we are able to find a function symbol that encloses
## a given location when reporting error messages.
-# CHECK: {{.*}}.o:(function func): relocation R_X86_64_32S out of range: -281474974609408 is not in [-2147483648, 2147483647]
+# CHECK: {{.*}}.o:(function func: .text.func+0x3): relocation R_X86_64_32S out of range: -281474974609408 is not in [-2147483648, 2147483647]
# This mergeable section will be garbage collected. We had a crash issue in that case. Test it.
.section .rodata.str1,"aMS", at progbits,1
Modified: lld/trunk/test/ELF/x86-64-reloc-range-debug-loc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-range-debug-loc.s?rev=350828&r1=350827&r2=350828&view=diff
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-range-debug-loc.s (original)
+++ lld/trunk/test/ELF/x86-64-reloc-range-debug-loc.s Thu Jan 10 07:08:06 2019
@@ -5,7 +5,7 @@
## Check we are able to report file and location from debug information
## when reporting such kind of errors.
-# CHECK: error: test.s:3: relocation R_X86_64_32 out of range: 68719476736 is not in [0, 4294967295]
+# CHECK: error: test.s:3:(.text+0x1): relocation R_X86_64_32 out of range: 68719476736 is not in [0, 4294967295]
.section .text,"ax", at progbits
foo:
More information about the llvm-commits
mailing list