HomePhabricator

[llvm-dwarfdump] - Stop printing the bogus empty section name on invalid dwarf.

Authored by grimar on Dec 3 2018, 2:33 AM.

Description

[llvm-dwarfdump] - Stop printing the bogus empty section name on invalid dwarf.

When there is no .debug_addr section for some reason,
llvm-dwarfdump would print the bogus empty section name when dumping ranges
in .debug_info:

DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000004

[0x0000000000000000, 0x0000000000000001) ""
[0x0000000000000000, 0x0000000000000002) "")

That happens because of the code which uses 0 (zero) as a section index as a default value.
The code should use -1ULL instead because technically 0 is a valid zero section index
in ELF and -1ULL is a special constant used that means "no section available".

This is mostly a fix for the overall correctness/safety of the code,
but a test case is provided too.

Differential revision: https://reviews.llvm.org/D55113

llvm-svn: 348115