On 02/05/2014 09:36 AM, Josh Stone wrote: > On 02/05/2014 03:44 AM, Mark Wielaard wrote: >> On Tue, 2014-02-04 at 18:24 -0800, Josh Stone wrote: >>> So now I'm not sure anything needs to change. At least dwarf_formsdata >>> should stay as-is for gcc. >> >> Are you sure? I think your original analysis is correct that >> dwarf_formsdata () is wrong and really should sign-extend. > > No, see above; GCC wrote signed index 199 into a data1:199, so it would > be wrong to sign-extend this. We're at the mercy of the producer.
Here's gdb precedent for the status quo, not sign-extending, in the comment right before dwarf2_const_value_data in gdb/dwarf2read.c: /* Given an attr with a DW_FORM_dataN value in host byte order, zero-extend it as appropriate for the symbol's type. The DWARF standard (v4) is not entirely clear about the meaning of using DW_FORM_dataN for a constant with a signed type, where the type is wider than the data. The conclusion of a discussion on the DWARF list was that this is unspecified. We choose to always zero-extend because that is the interpretation long in use by GCC. */ current source: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/dwarf2read.c;h=54c538af5fb8df8e569ebc3d9194997607b8898c;hb=HEAD#l17774 original commit: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=053315c2134b7832b351c599fa3fa11abf6ca4e7;hp=3ce3b1ba3153a2fc9265ba78cc25acaa7db127ba
