From 102b1efd5325de188b06b0725a673c902f351dad Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 19 Jun 2019 13:51:29 +0000 Subject: [PATCH] [llvm-dwarfdump] --gdb-index: fix uninitialized TuListOffset The test only checks the existence of the `Types CU list` line. Unfortunately I can't make a better test because {gcc,clang} -fuse-ld={lld,gold} --gdb-index do not give me a non-empty types CU list. Reviewed By: ikudrin Differential Revision: https://reviews.llvm.org/D63537 llvm-svn: 363800 --- llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp | 6 +++--- llvm/test/DebugInfo/dwarfdump-dump-gdbindex.test | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp index 6b5357f23f6c..f5f975578082 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -120,7 +120,7 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) { return false; CuListOffset = Data.getU32(&Offset); - uint32_t CuTypesOffset = Data.getU32(&Offset); + TuListOffset = Data.getU32(&Offset); AddressAreaOffset = Data.getU32(&Offset); SymbolTableOffset = Data.getU32(&Offset); ConstantPoolOffset = Data.getU32(&Offset); @@ -128,7 +128,7 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) { if (Offset != CuListOffset) return false; - uint32_t CuListSize = (CuTypesOffset - CuListOffset) / 16; + uint32_t CuListSize = (TuListOffset - CuListOffset) / 16; CuList.reserve(CuListSize); for (uint32_t i = 0; i < CuListSize; ++i) { uint64_t CuOffset = Data.getU64(&Offset); @@ -138,7 +138,7 @@ bool DWARFGdbIndex::parseImpl(DataExtractor Data) { // CU Types are no longer needed as DWARF skeleton type units never made it // into the standard. - uint32_t TuListSize = (AddressAreaOffset - CuTypesOffset) / 24; + uint32_t TuListSize = (AddressAreaOffset - TuListOffset) / 24; TuList.resize(TuListSize); for (uint32_t I = 0; I < TuListSize; ++I) { uint64_t CuOffset = Data.getU64(&Offset); diff --git a/llvm/test/DebugInfo/dwarfdump-dump-gdbindex.test b/llvm/test/DebugInfo/dwarfdump-dump-gdbindex.test index 2ff13eb4cf03..d81f490d7d22 100644 --- a/llvm/test/DebugInfo/dwarfdump-dump-gdbindex.test +++ b/llvm/test/DebugInfo/dwarfdump-dump-gdbindex.test @@ -17,6 +17,8 @@ RUN: llvm-dwarfdump -gdb-index %p/Inputs/dwarfdump-gdbindex-v7.elf-x86-64 | File ; CHECK-NEXT: 0: Offset = 0x0, Length = 0x34 ; CHECK-NEXT: 1: Offset = 0x34, Length = 0x34 +; CHECK: Types CU list offset = 0x38, has 0 entries: + ; CHECK: Address area offset = 0x38, has 2 entries: ; CHECK-NEXT: Low/High address = [0x4000e8, 0x4000f3) (Size: 0xb), CU id = 0 ; CHECK-NEXT: Low/High address = [0x4000f3, 0x4000fe) (Size: 0xb), CU id = 1