mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 05:56:05 +00:00
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 llvm-svn: 350828
This commit is contained in:
parent
461725b585
commit
3ca494b2ee
@ -288,14 +288,17 @@ Defined *InputSectionBase::getEnclosingFunction(uint64_t Offset) {
|
||||
// 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::getLocation(uint64_t Offset) {
|
||||
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.
|
||||
|
@ -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
|
||||
|
@ -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",@progbits,1
|
||||
|
@ -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",@progbits
|
||||
foo:
|
||||
|
Loading…
x
Reference in New Issue
Block a user