[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
This commit is contained in:
Fangrui Song 2019-06-19 13:51:29 +00:00
parent 405037c4e6
commit 102b1efd53
2 changed files with 5 additions and 3 deletions

View File

@ -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);

View File

@ -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