From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com
Subject: [committed] Factor out write_unit_die
Date: Wed, 01 Jan 2020 00:00:00 -0000 [thread overview]
Message-ID: <20200213141045.GA13453@delia> (raw)
Hi,
Factor out new function write_unit_die out of function write_die.
Committed to trunk.
Thanks,
- Tom
Factor out write_unit_die
2020-02-11 Tom de Vries <tdevries@suse.de>
* dwz.c (write_unit_die): New function, factor out of ...
(write_die): ... here.
---
dwz.c | 107 +++++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 60 insertions(+), 47 deletions(-)
diff --git a/dwz.c b/dwz.c
index bffbaa1..8562b7b 100644
--- a/dwz.c
+++ b/dwz.c
@@ -10774,6 +10774,65 @@ adjust_exprloc (dw_cu_ref cu, dw_die_ref die, dw_cu_ref refcu,
}
}
+/* Write DW_TAG_unit_* DIE (with ORIGIN being the corresponding original DIE) to
+ memory starting at PTR, return pointer after the DIE. */
+static unsigned char *
+write_unit_die (unsigned char *ptr, dw_die_ref die, dw_die_ref origin)
+{
+ struct abbrev_tag *t = die->u.p2.die_new_abbrev;
+
+ if (t->nattr == 0)
+ return ptr;
+
+ if (t->attr[0].attr == DW_AT_stmt_list)
+ {
+ enum dwarf_form form;
+ unsigned char *p = get_AT (origin, DW_AT_stmt_list, &form);
+ assert (p && (form == DW_FORM_sec_offset
+ || form == DW_FORM_data4));
+ if (wr_multifile)
+ write_32 (ptr, multi_line_off);
+ else if (op_multifile)
+ write_32 (ptr, 0);
+ else
+ {
+ memcpy (ptr, p, 4);
+ ptr += 4;
+ }
+ }
+ if (t->attr[t->nattr - 1].attr == DW_AT_comp_dir)
+ {
+ enum dwarf_form form;
+ unsigned char *p = get_AT (origin, DW_AT_comp_dir, &form);
+ assert (p);
+ assert (form == t->attr[t->nattr - 1].form
+ || (form == DW_FORM_strp
+ && t->attr[t->nattr - 1].form
+ == DW_FORM_GNU_strp_alt));
+ if (form == DW_FORM_strp)
+ {
+ if (unlikely (wr_multifile || op_multifile || fi_multifile))
+ {
+ unsigned int strp = lookup_strp_offset (read_32 (p));
+ write_32 (ptr, strp);
+ }
+ else
+ {
+ memcpy (ptr, p, 4);
+ ptr += 4;
+ }
+ }
+ else
+ {
+ size_t len = strlen ((char *) p) + 1;
+ memcpy (ptr, p, len);
+ ptr += len;
+ }
+ }
+
+ return ptr;
+}
+
/* Write DIE (with REF being the corresponding original DIE) to
memory starting at PTR, return pointer after the DIE. */
static unsigned char *
@@ -11164,53 +11223,7 @@ write_die (unsigned char *ptr, dw_cu_ref cu, dw_die_ref die,
{
case DW_TAG_partial_unit:
case DW_TAG_compile_unit:
- if (t->nattr == 0)
- break;
- if (t->attr[0].attr == DW_AT_stmt_list)
- {
- enum dwarf_form form;
- unsigned char *p = get_AT (origin, DW_AT_stmt_list, &form);
- assert (p && (form == DW_FORM_sec_offset
- || form == DW_FORM_data4));
- if (wr_multifile)
- write_32 (ptr, multi_line_off);
- else if (op_multifile)
- write_32 (ptr, 0);
- else
- {
- memcpy (ptr, p, 4);
- ptr += 4;
- }
- }
- if (t->attr[t->nattr - 1].attr == DW_AT_comp_dir)
- {
- enum dwarf_form form;
- unsigned char *p = get_AT (origin, DW_AT_comp_dir, &form);
- assert (p);
- assert (form == t->attr[t->nattr - 1].form
- || (form == DW_FORM_strp
- && t->attr[t->nattr - 1].form
- == DW_FORM_GNU_strp_alt));
- if (form == DW_FORM_strp)
- {
- if (unlikely (wr_multifile || op_multifile || fi_multifile))
- {
- unsigned int strp = lookup_strp_offset (read_32 (p));
- write_32 (ptr, strp);
- }
- else
- {
- memcpy (ptr, p, 4);
- ptr += 4;
- }
- }
- else
- {
- size_t len = strlen ((char *) p) + 1;
- memcpy (ptr, p, len);
- ptr += len;
- }
- }
+ ptr = write_unit_die (ptr, die, origin);
break;
case DW_TAG_namespace:
case DW_TAG_module:
reply other threads:[~2020-02-13 14:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200213141045.GA13453@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
/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).