]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libdw: dwarf_formsdata should return a signed value
authorPetr Machata <pmachata@gmail.com>
Sun, 14 Jan 2018 02:22:05 +0000 (03:22 +0100)
committerMark Wielaard <mark@klomp.org>
Sun, 14 Jan 2018 16:28:43 +0000 (17:28 +0100)
commit1e2c886bb2e1e48dfc592f356ecad7da0a032f0a
tree815b0b8f59d2b51db89871246d6fd17bcbbdac55
parentc09d611f823c8a6ddb8513fd1113b1ced61baf6c
libdw: dwarf_formsdata should return a signed value

The function dwarf_formsdata is used for decoding signed values, but
except for the variable-length DW_FORM_sdata, it uses unsigned
primitives to decode the value. This is not a problem for 64-bit values,
but the smaller values come decoded wrong. Fix by changing to signed
primitives for decoding the fixed-length forms.

Add a test case that uses dwarf_aggregate_size to determine an array
size whose lower bound is -1, encoded using DW_FORM_data1, and upper
bound 255 with DW_FORM_data2. When the -1 is decoded wrongly, it comes
back as 255, and the array size is 1. The correct array size should be
257.

Signed-off-by: Petr Machata <pmachata@gmail.com>
libdw/ChangeLog
libdw/dwarf_formsdata.c
tests/ChangeLog
tests/Makefile.am
tests/run-aggregate-size.sh
tests/testfile-sizes4.o.bz2 [new file with mode: 0644]
tests/testfile-sizes4.s [new file with mode: 0644]