public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Subject: Re: [PATCH] readelf: Handle signedness of DW_FORM_implicit_const and DW_AT_const_value.
Date: Fri, 15 Jun 2018 22:17:00 -0000	[thread overview]
Message-ID: <20180615221735.GA4102@wildebeest.org> (raw)
In-Reply-To: <1528894303-31189-1-git-send-email-mark@klomp.org>

On Wed, Jun 13, 2018 at 02:51:43PM +0200, Mark Wielaard wrote:
> We only handles DW_FORM_sdata as a signed form, but DW_FORM_implicit_const
> is also signed by default. For DW_AT_const_value we can do a little better.
> GCC encodes some const_values with signed forms, even though the type
> is unsigned. Lookup the (base) type of the DIE and display the const value
> as their (signed) type/size (if we can determine that).
> 
> Add a new testcase run-readelf-const-values.sh that shows that.
> With the new testcase the const values would come out as follows:
> 
>   name                 (string) "i"
>   const_value          (implicit_const) 18446744073709551615
>   name                 (string) "j"
>   const_value          (implicit_const) 18446744073709551615
> 
>   name                 (string) "sc"
>   const_value          (sdata) -2
>   name                 (string) "uc"
>   const_value          (sdata) -2
>   name                 (string) "ss"
>   const_value          (sdata) -16
>   name                 (string) "us"
>   const_value          (sdata) -16
>   name                 (string) "si"
>   const_value          (sdata) -3
>   name                 (string) "ui"
>   const_value          (sdata) -94967296
>   name                 (string) "sl"
>   const_value          (sdata) -1
>   name                 (string) "ul"
>   const_value          (sdata) -1
> 
> With this patch they show up as:
> 
>   name                 (string) "i"
>   const_value          (implicit_const) -1
>   name                 (string) "j"
>   const_value          (implicit_const) -1
> 
>   name                 (string) "sc"
>   const_value          (sdata) -2
>   name                 (string) "uc"
>   const_value          (sdata) 254 (-2)
>   name                 (string) "ss"
>   const_value          (sdata) -16
>   name                 (string) "us"
>   const_value          (sdata) 65520 (-16)
>   name                 (string) "si"
>   const_value          (sdata) -3
>   name                 (string) "ui"
>   const_value          (sdata) 4200000000 (-94967296)
>   name                 (string) "sl"
>   const_value          (sdata) -1
>   name                 (string) "ul"
>   const_value          (sdata) 18446744073709551615 (-1)
> 
> (for signed/unsigned int char, short and long)

Pushed to master.

      reply	other threads:[~2018-06-15 22:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13 12:51 Mark Wielaard
2018-06-15 22:17 ` Mark Wielaard [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=20180615221735.GA4102@wildebeest.org \
    --to=mark@klomp.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).