[PATCH] Handle DW_FORM_implicit_const

Jakub Jelinek jakub@redhat.com
Mon Jan 18 08:12:59 GMT 2021


On Sun, Jan 17, 2021 at 11:24:00PM +0100, Mark Wielaard wrote:
> This handles DW_FORM_implicit_const. This form keeps the actual data
> value in the abbrev. This makes things tricky because we have to decide
> where to keep (a reference to) the value and when to update the value
> if necessary.
> 
> To not bloat each abbrev_attr struct we add an int64 *values to the
> abbrev_tag struct which points to an array of values at the end. We
> only allocate values up to the highest implicit_const form (if any)
> when we know those upfront. In compute_abbrevs and recompute_abbrevs
> we have to allocate a maximum number of values (just like we have to
> allocate the maximum number of attributes). But when cloning those
> we reduce the number of values (and attributes) to the minimum needed.
> To keep the values field up to date always call pool_clone_abbrev
> when copying an abbrev.
> 
> When a DW_AT_decl_file or DW_AT_call_file attribute references a
> file number using DW_FORM_implicit_const we need to be careful when
> updating the value for a new file table. The abbrev can be used by
> more than one DIE, but the value only needs to be updated once. We
> use the fact that file references are positive, but an implicit_const
> is signed. When updating we negate the new file number and don't update
> a negative file number. Negative file numbers are made positive again when
> calculating the new abbrev sizes in compute_abbrevs.
> 
> 	* dwz.c (write_sleb128): New macro.
> 	(struct abbrev_tag): Add values pointer field.
> 	(pool_clone_abbrev): New function.
> 	(abbrev_eq2): Handle DW_FORM_implicit_const by also comparing
> 	the value.
> 	(compute_abbrev_hash): Likewise.
> 	(read_abbrev): Read DW_FORM_implicit_const. Keep track of
> 	highest_implicit_value_ndx. Allocate values.
> 	(get_AT): Return pointer to value for DW_FORM_implicit_const.
> 	(get_AT_int): Return value of DW_FORM_implicit_const.
> 	(checksum_die): Get value for DW_AT_decl_file or DW_AT_call_file
> 	from DW_FORM_implicit_const, skip for others.
> 	(checksum_ref_die): Likewise.
> 	(die_eq_1): Likewise.
> 	(mark_refs): Handle DW_FORM_implicit_const.
> 	(read_debug_info): Handle DW_FORM_implicit_const, set cu_lang
> 	for compile/partial units.
> 	(size_of_sleb128): New function.
> 	(build_abbrevs_for_die): Handle DW_FORM_implicit_const value.
> 	Use pool_clone_abbrev.
> 	(abbrev_cmp): Also compare DW_FORM_implicit_const values.
> 	(compute_abbrevs): Use pool_clone_abbrev. Switch any negative
> 	file implicit_const values back before calculating size.
> 	(write_abbrev): Also write DW_FORM_implicit_const value.
> 	(write_die): Handle DW_FORM_implicit_const, but don't change
> 	form/value for DW_AT_decl_file and DW_AT_call_file.
> 	(recompute_abbrevs): Alloc space for max_nattr values, set
> 	abbrev_tag values field.

Ok, thanks.

	Jakub



More information about the Dwz mailing list