[DebugInfo] add SectionedAddress to DebugInfo interfaces.
That patch is the fix for https://bugs.llvm.org/show_bug.cgi?id=40703
"wrong line number info for obj file compiled with -ffunction-sections"
bug. The problem happened with only .o files. If object file contains
several .text sections then line number information showed incorrectly.
The reason for this is that DwarfLineTable could not detect section which
corresponds to specified address(because address is the local to the
section). And as the result it could not select proper sequence in the
line table. The fix is to pass SectionIndex with the address. So that it
would be possible to differentiate addresses from various sections. With
this fix llvm-objdump shows correct line numbers for disassembled code.
Differential review: https://reviews.llvm.org/D58194
llvm-svn: 354972
diff --git a/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp b/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp
index 9775c5b..a57958d 100644
--- a/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp
+++ b/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp
@@ -113,8 +113,8 @@
// Expose this method publicly for testing.
void parseSectionContents(ArrayRef<uint8_t> SectionBytes,
- uint64_t SectionAddress) {
- FileAnalysis::parseSectionContents(SectionBytes, SectionAddress);
+ object::SectionedAddress Address) {
+ FileAnalysis::parseSectionContents(SectionBytes, Address);
}
Error initialiseDisassemblyMembers() {
@@ -156,8 +156,9 @@
0x0f, 0x0b, // 2: ud2
0xff, 0x10, // 4: callq *(%rax)
},
- 0xDEADBEEF);
- const auto Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);
+ {0xDEADBEEF, 0x0});
+ const auto Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));
@@ -182,8 +183,9 @@
0xff, 0x10, // 2: callq *(%rax)
0x0f, 0x0b, // 4: ud2
},
- 0xDEADBEEF);
- const auto Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);
+ {0xDEADBEEF, 0x0});
+ const auto Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));
@@ -211,8 +213,9 @@
0x75, 0xf9, // 7: jne 2 [-7]
0x0f, 0x0b, // 9: ud2
},
- 0xDEADBEEF);
- const auto Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);
+ {0xDEADBEEF, 0x0});
+ const auto Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(2));
@@ -249,8 +252,9 @@
0x75, 0xfb, // 5: jne 2 [-5]
0x0f, 0x0b, // 7: ud2
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(2));
@@ -284,16 +288,17 @@
0x90, // 0: nop
0x75, 0xfe, // 1: jne 1 [-2]
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());
- Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 1);
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 1, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());
- Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADC0DE);
+ Result = GraphBuilder::buildFlowGraph(Analysis, {0xDEADC0DE, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());
}
@@ -306,8 +311,9 @@
0xeb, 0xfe, // 0: jmp 0 [-2]
0xff, 0x10, // 2: callq *(%rax)
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());
EXPECT_THAT(Result.OrphanedNodes, ElementsAre(0xDEADBEEF + 2));
EXPECT_THAT(Result.IntermediateNodes, IsEmpty());
@@ -321,8 +327,9 @@
0x75, 0xfe, // 0: jne 0 [-2]
0xff, 0x10, // 2: callq *(%rax)
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));
EXPECT_THAT(
@@ -344,8 +351,9 @@
0xeb, 0xfc, // 2: jmp 0 [-4]
0xff, 0x10, // 4: callq *(%rax)
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(1));
EXPECT_THAT(
@@ -368,8 +376,9 @@
0xeb, 0xfc, // 2: jmp 0 [-4]
0xff, 0x10, // 4: callq *(%rax)
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 4);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 4, 0x0});
EXPECT_THAT(Result.OrphanedNodes, ElementsAre(0xDEADBEEF + 4));
EXPECT_THAT(Result.ConditionalBranchNodes, IsEmpty());
}
@@ -387,12 +396,13 @@
0xff, 0x10, // 6: callq *(%rax)
0x0f, 0x0b, // 8: ud2
},
- 0xDEADBEEF);
+ {0xDEADBEEF, 0x0});
uint64_t PrevSearchLengthForConditionalBranch =
SearchLengthForConditionalBranch;
SearchLengthForConditionalBranch = 2;
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 6);
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 6, 0x0});
EXPECT_THAT(Result.OrphanedNodes, SizeIs(1));
EXPECT_THAT(Result.OrphanedNodes,
Each(HasPath(Result, ElementsAre(0xDEADBEEF + 4, 0xDEADBEEF + 5,
@@ -416,11 +426,12 @@
0x90, // 7: nop
0x0f, 0x0b, // 8: ud2
},
- 0xDEADBEEF);
+ {0xDEADBEEF, 0x0});
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;
SearchLengthForUndef = 2;
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 2);
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 2, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(
Result.ConditionalBranchNodes,
@@ -450,8 +461,9 @@
0x75, 0xfb, // 5: jne 2 [-5]
0x0f, 0x0b, // 7: ud2
},
- 0xDEADBEEF);
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0xDEADBEEF + 3);
+ {0xDEADBEEF, 0x0});
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0xDEADBEEF + 3, 0x0});
EXPECT_THAT(Result.OrphanedNodes, IsEmpty());
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(2));
EXPECT_THAT(
@@ -529,11 +541,12 @@
0x90, // 21: nop
0x0f, 0x0b, // 22: ud2
},
- 0x1000);
+ {0x1000, 0x0});
uint64_t PrevSearchLengthForUndef = SearchLengthForUndef;
SearchLengthForUndef = 5;
- GraphResult Result = GraphBuilder::buildFlowGraph(Analysis, 0x1000 + 9);
+ GraphResult Result =
+ GraphBuilder::buildFlowGraph(Analysis, {0x1000 + 9, 0x0});
EXPECT_THAT(Result.OrphanedNodes, SizeIs(1));
EXPECT_THAT(Result.ConditionalBranchNodes, SizeIs(3));