public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Mark Wielaard <mark@klomp.org>
Cc: dwz@sourceware.org
Subject: Re: [PATCH] Handle DW_FORM_implicit_const
Date: Mon, 18 Jan 2021 09:12:59 +0100	[thread overview]
Message-ID: <20210118081259.GS1034503@tucnak> (raw)
In-Reply-To: <20210117222400.22763-1-mark@klomp.org>

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


      reply	other threads:[~2021-01-18  8:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17 22:24 Mark Wielaard
2021-01-18  8:12 ` Jakub Jelinek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210118081259.GS1034503@tucnak \
    --to=jakub@redhat.com \
    --cc=dwz@sourceware.org \
    --cc=mark@klomp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).