Dwarf5 fixes [2 of 5]: Handle .debug_str_offsets properly.

Second of 5 small patches to fix various breakpad issues found
while testing dump_syms on DWARF v5 in ChromeOS.

This patch adds code to properly find & parse the
DW_AT_str_offsets_base attribute, and use it to handle strings
of the forms DW_FORM_strx, DW_FORM_strx1..DW_FORM_strx4 This is the
largest of the DWARF5 fixes.  It also includes a unittest to test
using a string offset.

Change-Id: I5d1def862d9d91cae4b2853578441e04ea85449d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2634547
Reviewed-by: Sterling Augustine <saugustine@google.com>
This commit is contained in:
Caroline Tice 2021-01-16 15:44:26 -08:00 committed by Sterling Augustine
parent f4115fad24
commit ac9712d9b4
5 changed files with 284 additions and 3 deletions

View file

@ -181,7 +181,8 @@ struct DwarfCUToModule::CUContext {
high_pc(0),
ranges_form(dwarf2reader::DW_FORM_sec_offset),
ranges_data(0),
ranges_base(0) { }
ranges_base(0),
str_offsets_base(0) { }
~CUContext() {
for (vector<Module::Function*>::iterator it = functions.begin();
@ -224,6 +225,9 @@ struct DwarfCUToModule::CUContext {
// form DW_FORM_addrxX is relative to this offset.
uint64_t addr_base;
// Offset into this CU's contribution to .debug_str_offsets.
uint64_t str_offsets_base;
// Collect all the data from the CU that a RangeListReader needs to read a
// range.
bool AssembleRangeListInfo(
@ -909,6 +913,9 @@ void DwarfCUToModule::ProcessAttributeUnsigned(enum DwarfAttribute attr,
case dwarf2reader::DW_AT_GNU_addr_base:
cu_context_->addr_base = data;
break;
case dwarf2reader::DW_AT_str_offsets_base:
cu_context_->str_offsets_base = data;
break;
default:
break;