8295646: Ignore zero pairs in address descriptors read by dwarf parser
Reviewed-by: chagedorn
This commit is contained in:
parent
50d91a31d4
commit
2634eff24f
src/hotspot/share/utilities
@ -763,6 +763,8 @@ bool DwarfFile::DebugAranges::read_set_header(DebugArangesSetHeader& header) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_entry_end = _reader.get_position() + header._unit_length;
|
||||
|
||||
if (!_reader.read_word(&header._version) || header._version != 2) {
|
||||
// DWARF 4 uses version 2 as specified in Appendix F of the DWARF 4 spec.
|
||||
DWARF_LOG_ERROR(".debug_aranges in unsupported DWARF version %" PRIu16, header._version)
|
||||
@ -803,7 +805,7 @@ bool DwarfFile::DebugAranges::read_address_descriptors(const DwarfFile::DebugAra
|
||||
found_matching_set = true;
|
||||
return true;
|
||||
}
|
||||
} while (!is_terminating_entry(descriptor) && _reader.has_bytes_left());
|
||||
} while (!is_terminating_entry(header, descriptor) && _reader.has_bytes_left());
|
||||
|
||||
// Set does not match offset_in_library. Continue with next.
|
||||
return true;
|
||||
@ -819,8 +821,12 @@ bool DwarfFile::DebugAranges::does_match_offset(const uint32_t offset_in_library
|
||||
&& offset_in_library < descriptor.beginning_address + descriptor.range_length;
|
||||
}
|
||||
|
||||
bool DwarfFile::DebugAranges::is_terminating_entry(const AddressDescriptor& descriptor) {
|
||||
return descriptor.beginning_address == 0 && descriptor.range_length == 0;
|
||||
bool DwarfFile::DebugAranges::is_terminating_entry(const DwarfFile::DebugAranges::DebugArangesSetHeader& header,
|
||||
const AddressDescriptor& descriptor) {
|
||||
bool is_terminating = _reader.get_position() >= _entry_end;
|
||||
assert(!is_terminating || (descriptor.beginning_address == 0 && descriptor.range_length == 0),
|
||||
"a terminating entry needs a pair of zero");
|
||||
return is_terminating;
|
||||
}
|
||||
|
||||
// Find the .debug_line offset for the line number program by reading from the .debug_abbrev and .debug_info section.
|
||||
|
@ -485,15 +485,20 @@ class DwarfFile : public ElfFile {
|
||||
MarkedDwarfFileReader _reader;
|
||||
uint32_t _section_start_address;
|
||||
|
||||
// a calculated end position
|
||||
long _entry_end;
|
||||
|
||||
bool read_section_header();
|
||||
bool read_set_header(DebugArangesSetHeader& header);
|
||||
bool read_address_descriptors(const DwarfFile::DebugAranges::DebugArangesSetHeader& header,
|
||||
uint32_t offset_in_library, bool& found_matching_set);
|
||||
bool read_address_descriptor(AddressDescriptor& descriptor);
|
||||
static bool does_match_offset(uint32_t offset_in_library, const AddressDescriptor& descriptor) ;
|
||||
static bool is_terminating_entry(const AddressDescriptor& descriptor);
|
||||
bool is_terminating_entry(const DwarfFile::DebugAranges::DebugArangesSetHeader& header,
|
||||
const AddressDescriptor& descriptor);
|
||||
public:
|
||||
DebugAranges(DwarfFile* dwarf_file) : _dwarf_file(dwarf_file), _reader(dwarf_file->fd()), _section_start_address(0) {}
|
||||
DebugAranges(DwarfFile* dwarf_file) : _dwarf_file(dwarf_file), _reader(dwarf_file->fd()),
|
||||
_section_start_address(0), _entry_end(0) {}
|
||||
bool find_compilation_unit_offset(uint32_t offset_in_library, uint32_t* compilation_unit_offset);
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user