public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "gprocida at google dot com" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug libdw/28220] New: dwarf_location_attr returns high-bit junk from .debug_addr when fetching 32-bit addresses
Date: Wed, 11 Aug 2021 12:00:35 +0000	[thread overview]
Message-ID: <bug-28220-10460@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=28220

            Bug ID: 28220
           Summary: dwarf_location_attr returns high-bit junk from
                    .debug_addr when fetching 32-bit addresses
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libdw
          Assignee: unassigned at sourceware dot org
          Reporter: gprocida at google dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

In libdw, there are snippets of code of the form:

dwarf_formaddr.c:
  71   if (address_size == 4)
  72     *addr = read_4ubyte_unaligned (dbg, datap);
  73   else
  74     *addr = read_8ubyte_unaligned (dbg, datap);

However, when I use the public interfaces in order to read locations, it goes
wrong when for Clang-built 32-bit objects with DWARF 5 debug information, with
extra junk in the upper 32 bits.

The attachment contains a full example. It's possible that I'm using the API
incorrectly. This is the debug output for the problematic case:

clang 5 32
bias=0
bias=0
dwarf=0x55f103cf8a10 elf=0x55f103cf5610
 version=5 unit_type=1 cu_die.addr=0x7fc3032e0078 cu_die.cu=0x55f103cf8e98
cu_die.abbrev=0 sub_die.addr=0 sub_die.cu=0 sub_die.abbrev=0
 unit_id=0 address_size=4 offset_size=4
  dwarf_string_attr(die, 1b)
 comp_dir=/usr/local/google/home/gprocida/dev/libabigail/b195152239
   child.addr=0x7fc3032e008a child.cu=0x55f103cf8e98 child.abbrev=0
    dwarf_string_attr(die, 3)
    dwarf_bool_attr(die, 3f)
    dwarf_location_attr(die, 2)
    attribute code=0x2 form=0x18 (expected=18)
     expr=0x55f103cf8ff8 exprlen=1
     op.atom=a1 op.number=0 op.number2=0 op.offset=0
     result code=0x11 form=0x1 (expected=1)
     address=0x1000400010000
   variable name=x name2=x external=1 location=1000400010000
   child.addr=0x7fc3032e0095 child.cu=0x55f103cf8e98 child.abbrev=0
   child.addr=0x7fc3032e0099 child.cu=0x55f103cf8e98 child.abbrev=0
    dwarf_string_attr(die, 3)
    dwarf_bool_attr(die, 3f)
    dwarf_location_attr(die, 2)
    attribute code=0x2 form=0x18 (expected=18)
     expr=0x55f103cf9048 exprlen=1
     op.atom=a1 op.number=1 op.number2=0 op.offset=0
     result code=0x11 form=0x1 (expected=1)
     address=0x6265440000010004
   variable name=y name2=y external=1 location=6265440000010004

Note that variable x's address includes variable y's address as the upper 32
bits and that variable y has junk in the upper 32 bits.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2021-08-11 12:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 12:00 gprocida at google dot com [this message]
2021-08-11 12:01 ` [Bug libdw/28220] " gprocida at google dot com
2021-08-11 12:06 ` gprocida at google dot com
2021-08-26 17:12 ` mark at klomp dot org
2021-08-26 22:47 ` gprocida at google dot com
2021-09-08 16:01 ` mark at klomp dot org
2021-09-08 20:15 ` mark at klomp dot org
2021-09-12 19:45 ` mark at klomp dot org

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=bug-28220-10460@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=elfutils-devel@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).