diff options
| author | Alexey Lapshin <a.v.lapshin@mail.ru> | 2019-02-27 13:17:36 +0000 |
|---|---|---|
| committer | Alexey Lapshin <a.v.lapshin@mail.ru> | 2019-02-27 13:17:36 +0000 |
| commit | 77fc1f6049a7414ec193c9ff8226eeb5662a5878 (patch) | |
| tree | b2bffed96e676b25942dbe39194e0f08a153f638 /llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp | |
| parent | ef920358277603c69f4f548d2e5c40842972dd71 (diff) | |
| download | bcm5719-llvm-77fc1f6049a7414ec193c9ff8226eeb5662a5878.tar.gz bcm5719-llvm-77fc1f6049a7414ec193c9ff8226eeb5662a5878.zip | |
[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
Diffstat (limited to 'llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp')
| -rw-r--r-- | llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp b/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp index 9775c5bd8ec..a57958d60e6 100644 --- a/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp +++ b/llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp @@ -113,8 +113,8 @@ public: // 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphTestSinglePathFallthroughUd2) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphTestSinglePathJumpUd2) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphTestDualPathDualUd2) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphTestDualPathSingleUd2) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphFailures) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphNoXrefs) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphConditionalInfiniteLoop) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphUnconditionalInfiniteLoop) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphNoFlowsToIndirection) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphLengthExceededUpwards) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphLengthExceededDownwards) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphWithRepeatedWork) { 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 @@ TEST_F(BasicGraphBuilderTest, BuildFlowGraphComplexExample) { 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)); |

