From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: FYI: DW_FORM_ref_addr -vs- DWARF 3
Date: Thu, 04 Mar 2010 22:00:00 -0000 [thread overview]
Message-ID: <m3r5nzych3.fsf@fleche.redhat.com> (raw)
I'm checking this in. I will probably push it into 7.1 as well; let me
know what you think of this.
DWARF 3 changed DW_FORM_ref_addr to use an offset-sized value instead of
an address-sized value. GDB does not cope with this, which can cause
crashes. For a real-life example:
https://bugzilla.redhat.com/show_bug.cgi?id=552619
I found this in the archives, after writing my patch:
http://sourceware.org/ml/gdb-patches/2006-06/msg00286.html
I guess it was never reviewed? I dunno. Anyway, I prefer my patch.
Built and regression tested on x86-64 (compile farm).
I also verified it before- and after- on the test program I have.
Tom
2010-03-04 Tom Tromey <tromey@redhat.com>
* dwarf2read.c (skip_one_die) <DW_FORM_ref_addr>: Use offset size
in DWARF 3 and later.
(read_attribute_value) <DW_FORM_ref_addr>: Likewise.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a05c946..b2558f0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2881,8 +2881,15 @@ skip_one_die (gdb_byte *buffer, gdb_byte *info_ptr,
skip_attribute:
switch (form)
{
- case DW_FORM_addr:
case DW_FORM_ref_addr:
+ /* In DWARF 2, DW_FORM_ref_addr is address sized; in DWARF 3
+ and later it is offset sized. */
+ if (cu->header.version == 2)
+ info_ptr += cu->header.addr_size;
+ else
+ info_ptr += cu->header.offset_size;
+ break;
+ case DW_FORM_addr:
info_ptr += cu->header.addr_size;
break;
case DW_FORM_data1:
@@ -7016,8 +7023,14 @@ read_attribute_value (struct attribute *attr, unsigned form,
attr->form = form;
switch (form)
{
- case DW_FORM_addr:
case DW_FORM_ref_addr:
+ if (cu->header.version == 2)
+ DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
+ else
+ DW_ADDR (attr) = read_offset (abfd, info_ptr, &cu->header, &bytes_read);
+ info_ptr += bytes_read;
+ break;
+ case DW_FORM_addr:
DW_ADDR (attr) = read_address (abfd, info_ptr, cu, &bytes_read);
info_ptr += bytes_read;
break;
next reply other threads:[~2010-03-04 22:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-04 22:00 Tom Tromey [this message]
2010-03-05 4:58 ` Joel Brobecker
2010-03-05 16:02 ` Tom Tromey
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=m3r5nzych3.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.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