@@ -77,7 +77,9 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
7777 case DW_FORM_strp:
7878 case DW_FORM_line_strp:
7979 case DW_FORM_sec_offset:
80- m_value.uval = data.GetMaxU64 (offset_ptr, 4 );
80+ assert (m_unit);
81+ ref_addr_size = m_unit->GetFormParams ().getDwarfOffsetByteSize ();
82+ m_value.uval = data.GetMaxU64 (offset_ptr, ref_addr_size);
8183 break ;
8284 case DW_FORM_addrx1:
8385 case DW_FORM_strx1:
@@ -119,10 +121,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
119121 break ;
120122 case DW_FORM_ref_addr:
121123 assert (m_unit);
122- if (m_unit->GetVersion () <= 2 )
123- ref_addr_size = m_unit->GetAddressByteSize ();
124- else
125- ref_addr_size = 4 ;
124+ ref_addr_size = m_unit->GetFormParams ().getRefAddrByteSize ();
126125 m_value.uval = data.GetMaxU64 (offset_ptr, ref_addr_size);
127126 break ;
128127 case DW_FORM_indirect:
@@ -165,7 +164,7 @@ static FormSize g_form_sizes[] = {
165164 {1 , 1 }, // 0x0b DW_FORM_data1
166165 {1 , 1 }, // 0x0c DW_FORM_flag
167166 {0 , 0 }, // 0x0d DW_FORM_sdata
168- {1 , 4 }, // 0x0e DW_FORM_strp
167+ {0 , 0 }, // 0x0e DW_FORM_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
169168 {0 , 0 }, // 0x0f DW_FORM_udata
170169 {0 , 0 }, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
171170 // for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
@@ -175,15 +174,15 @@ static FormSize g_form_sizes[] = {
175174 {1 , 8 }, // 0x14 DW_FORM_ref8
176175 {0 , 0 }, // 0x15 DW_FORM_ref_udata
177176 {0 , 0 }, // 0x16 DW_FORM_indirect
178- {1 , 4 }, // 0x17 DW_FORM_sec_offset
177+ {0 , 0 }, // 0x17 DW_FORM_sec_offset (4 bytes for DWARF32,8 bytes for DWARF64)
179178 {0 , 0 }, // 0x18 DW_FORM_exprloc
180179 {1 , 0 }, // 0x19 DW_FORM_flag_present
181180 {0 , 0 }, // 0x1a DW_FORM_strx (ULEB128)
182181 {0 , 0 }, // 0x1b DW_FORM_addrx (ULEB128)
183182 {1 , 4 }, // 0x1c DW_FORM_ref_sup4
184183 {0 , 0 }, // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for DWARF64)
185184 {1 , 16 }, // 0x1e DW_FORM_data16
186- {1 , 4 }, // 0x1f DW_FORM_line_strp
185+ {0 , 0 }, // 0x1f DW_FORM_line_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
187186 {1 , 8 }, // 0x20 DW_FORM_ref_sig8
188187};
189188
@@ -246,13 +245,9 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
246245 return true ;
247246
248247 case DW_FORM_ref_addr:
249- ref_addr_size = 4 ;
250248 assert (unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
251249 // get this wrong
252- if (unit->GetVersion () <= 2 )
253- ref_addr_size = unit->GetAddressByteSize ();
254- else
255- ref_addr_size = 4 ;
250+ ref_addr_size = unit->GetFormParams ().getRefAddrByteSize ();
256251 *offset_ptr += ref_addr_size;
257252 return true ;
258253
@@ -288,7 +283,9 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
288283 case DW_FORM_sec_offset:
289284 case DW_FORM_strp:
290285 case DW_FORM_line_strp:
291- *offset_ptr += 4 ;
286+ assert (unit);
287+ ref_addr_size = unit->GetFormParams ().getDwarfOffsetByteSize ();
288+ *offset_ptr += ref_addr_size;
292289 return true ;
293290
294291 // 4 byte values
0 commit comments