This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: [PATCH] libdw: dwarf_formsdata should return a signed value
- From: Mark Wielaard <mark at klomp dot org>
- To: Petr Machata <pmachata at gmail dot com>
- Cc: elfutils-devel at sourceware dot org
- Date: Sun, 14 Jan 2018 17:28:29 +0100
- Subject: Re: [PATCH] libdw: dwarf_formsdata should return a signed value
- Authentication-results: sourceware.org; auth=none
- References: <d4b8049cf28a1fafcc2ce5b7b5abab7d3908591c.1515894988.git.pmachata@gmail.com>
Hi Petr,
On Sun, Jan 14, 2018 at 03:22:05AM +0100, Petr Machata wrote:
> 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.
Thanks for the patch and testcase. The change is obviously correct.
I wonder why we never noticed before. Applied to master including adding
the new test files to EXTRA_DIST to make sure they get into the dist
tar ball.
Cheers,
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 831532b2..758f20e6 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-14 Petr Machata <pmachata@gmail.com>
+
+ * testfile-sizes4.o.bz2: New test file.
+ * testfile-sizes4.s: New test source.
+ * run-aggregate-size.sh: Check testfile-sizes4.o v size 257.
+
2017-12-23 Mark Wielaard <mark@klomp.org>
* backtrace-subr.sh (check_native_core): Use a lock file and try
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 64cb5bd9..1fce4474 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -333,7 +333,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-deleted.sh run-linkmap-cut.sh linkmap-cut-lib.so.bz2 \
linkmap-cut.bz2 linkmap-cut.core.bz2 \
run-aggregate-size.sh testfile-sizes1.o.bz2 testfile-sizes2.o.bz2 \
- testfile-sizes3.o.bz2 run-peel-type.sh \
+ testfile-sizes3.o.bz2 testfile-sizes4.o.bz2 testfile-sizes4.s \
+ run-peel-type.sh \
run-readelf-A.sh testfileppc32attrs.o.bz2 \
testfilesparc64attrs.o.bz2 testfileppc64attrs.o.bz2 \
testfile-debug-types.bz2 \