This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] readelf: Handle signedness of DW_FORM_implicit_const and DW_AT_const_value.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]