From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111819 invoked by alias); 12 Dec 2017 05:58:02 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 111792 invoked by uid 89); 12 Dec 2017 05:58:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=wkd, ABB, uh, cic X-Spam-Status: No, score=-25.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: out3-smtp.messagingengine.com Received: from out3-smtp.messagingengine.com (HELO out3-smtp.messagingengine.com) (66.111.4.27) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Dec 2017 05:57:59 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 07DC820A70 for ; Tue, 12 Dec 2017 00:57:58 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 12 Dec 2017 00:57:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretsauce.net; h=content-type:date:from:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Q+UDy+A1LObOr6gzg Pg5cYXUFj/hzjXTX4v0P58maD0=; b=X4BmbABjP/wl7gyrpoErdtGBRF8U9O9e/ nNKKz2Pyta84xvhjc+U6gU5Qm4cqmVq4xXC5PVk2k/FbQ7dkMVMwcg0mdceCHuOv 1scYX0m/mav0SBZoBDsOVb5ObrHUvS+Dz+QPRLJQcV/D9l4AnB0c7z9j39v2NgQr Hgbg84oyOv9EOhjzG0UB35nvkIk6LYtYRIxZYwxgf1WDzZOTIG3yWZnl9rgiJT79 OxjDaNgwkqhx2Yt31qqynCwPwCSKqokIk2F/dvknX34biELvqE+rhwh8Au+qWyJR Xj7S/zb3uUzZlCaaoBSGRIOAKchmSE5J5Q/SULkkLkyISXXAxYi1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=Q+UDy+A1LObOr6gzgPg5cYXUFj/hzjXTX4v0P58maD0=; b=HItTaAyP 7l31KWiNQVhNp6Dq+hQUy3ixILiOhljUmES9UlyKsu2qxMZsLRNfXG374yzYTCb/ Uyhkyy2US17resZktOxJRSXMC+bX/0UVMfLcuat374QGu+RHNN7hzjXnPpP34OXL 6C2nwbe2e+RThioLlyWXcaUNutXTe8fW3+c27MSB1MSveNoBgfhMUGSta3ZhmAKT edeI9jQcthYhuWxneGHcWYSQY0OJqFYoKYEnBcENlyTeSTLmgTfcSSNy8CCxxoR6 o751jtW3ckPtNUR0eSxgrPWenTVqHXImodGasUz+Og2a8KrWpwitap64nOPf1D7/ KFiVvwf1Q+i3Yg== X-ME-Sender: Received: from scrawny (50-1-153-150.dsl.dynamic.fusionbroadband.com [50.1.153.150]) by mail.messagingengine.com (Postfix) with ESMTPA id 79E7B24217 for ; Tue, 12 Dec 2017 00:57:57 -0500 (EST) Received: from dima by scrawny with local (Exim 4.89) (envelope-from ) id 1eOdZk-0008Uj-A2 for elfutils-devel@sourceware.org; Mon, 11 Dec 2017 21:57:56 -0800 User-agent: mu4e 0.9.19; emacs 25.2.2 From: Dima Kogan To: elfutils-devel@sourceware.org Subject: [PATCH] Fix 22546: dwarf_aggregate_size() works with multi-dimensional arrays Date: Tue, 12 Dec 2017 05:58:00 -0000 Message-ID: <87r2s04hej.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-IsSubscribed: yes X-SW-Source: 2017-q4/txt/msg00103.txt.bz2 --=-=-= Content-Type: text/plain Content-length: 67 This fixes https://sourceware.org/bugzilla/show_bug.cgi?id=22546 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-libdw-dwarf_aggregate_size-works-with-multi-dimensio.patch Content-length: 7938 >From 5f65148409fa08613f21280c5aea026d8b78366f Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Fri, 8 Dec 2017 01:45:10 -0800 Subject: [PATCH] libdw: dwarf_aggregate_size() works with multi-dimensional arrays If we have a multidimensional array of dimensions (a,b,c) the number of elements should be a*b*c, but prior to this patch dwarf_aggregate_size() would report a+b+c instead. This patch fixes the bug and adds a test that demonstrates the bug (the test fails without the functional part of this patch). Fixes: https://sourceware.org/bugzilla/show_bug.cgi?id=22546 Signed-off-by: Dima Kogan --- libdw/ChangeLog | 5 +++++ libdw/dwarf_aggregate_size.c | 43 ++++++++++++++++++++++--------------------- tests/ChangeLog | 6 ++++++ tests/run-aggregate-size.sh | 2 ++ tests/run-peel-type.sh | 1 + tests/testfile-sizes3.o.bz2 | Bin 1147 -> 1208 bytes 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 43752440..2a6d7118 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2017-12-11 Dima Kogan + + * dwarf_aggregate_size.c (array_size): Handle multi-dimensional + arrays properly. + 2017-11-03 Mark Wielaard * dwarf_getlocation.c (__libdw_intern_expression): Handle diff --git a/libdw/dwarf_aggregate_size.c b/libdw/dwarf_aggregate_size.c index 838468dd..3010c0aa 100644 --- a/libdw/dwarf_aggregate_size.c +++ b/libdw/dwarf_aggregate_size.c @@ -63,7 +63,7 @@ array_size (Dwarf_Die *die, Dwarf_Word *size, return -1; bool any = false; - Dwarf_Word total = 0; + Dwarf_Word count_total = 1; do { Dwarf_Word count; @@ -134,34 +134,35 @@ array_size (Dwarf_Die *die, Dwarf_Word *size, continue; } - /* This is a subrange_type or enumeration_type and we've set COUNT. - Now determine the stride for this array dimension. */ - Dwarf_Word stride = eltsize; - if (INTUSE(dwarf_attr_integrate) (&child, DW_AT_byte_stride, - attr_mem) != NULL) - { - if (INTUSE(dwarf_formudata) (attr_mem, &stride) != 0) - return -1; - } - else if (INTUSE(dwarf_attr_integrate) (&child, DW_AT_bit_stride, - attr_mem) != NULL) - { - if (INTUSE(dwarf_formudata) (attr_mem, &stride) != 0) - return -1; - if (stride % 8) /* XXX maybe compute in bits? */ - return -1; - stride /= 8; - } + count_total *= count; any = true; - total += stride * count; } while (INTUSE(dwarf_siblingof) (&child, &child) == 0); if (!any) return -1; - *size = total; + /* This is a subrange_type or enumeration_type and we've set COUNT. + Now determine the stride for this array. */ + Dwarf_Word stride = eltsize; + if (INTUSE(dwarf_attr_integrate) (die, DW_AT_byte_stride, + attr_mem) != NULL) + { + if (INTUSE(dwarf_formudata) (attr_mem, &stride) != 0) + return -1; + } + else if (INTUSE(dwarf_attr_integrate) (die, DW_AT_bit_stride, + attr_mem) != NULL) + { + if (INTUSE(dwarf_formudata) (attr_mem, &stride) != 0) + return -1; + if (stride % 8) /* XXX maybe compute in bits? */ + return -1; + stride /= 8; + } + + *size = count_total * stride; return 0; } diff --git a/tests/ChangeLog b/tests/ChangeLog index fe633594..e16a3d04 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2017-12-11 Dima Kogan + + * run-aggregate-size.sh: Added check for multi-dimensional arrays. + * run-peel-type.sh: Likewise. + * testfile-sizes3.o.bz2: Likewise. + 2017-12-07 Mark Wielaard * run-readelf-variant.sh: New test. diff --git a/tests/run-aggregate-size.sh b/tests/run-aggregate-size.sh index 42b0742b..6d8aa240 100755 --- a/tests/run-aggregate-size.sh +++ b/tests/run-aggregate-size.sh @@ -54,6 +54,7 @@ # volatile int ia[32]; # const volatile void * const volatile restrict va[64]; # struct s sa[8]; +# double d3d[3][4][5]; # # typedef const int foo; # typedef volatile foo bar; @@ -98,6 +99,7 @@ ca size 16 ia size 128 va size 512 sa size 128 +d3d size 480 f size 4 b size 4 EOF diff --git a/tests/run-peel-type.sh b/tests/run-peel-type.sh index 7fd96e84..668e3161 100755 --- a/tests/run-peel-type.sh +++ b/tests/run-peel-type.sh @@ -55,6 +55,7 @@ ca raw type array_type ia raw type array_type va raw type array_type sa raw type array_type +d3d raw type array_type f raw type base_type b raw type base_type EOF diff --git a/tests/testfile-sizes3.o.bz2 b/tests/testfile-sizes3.o.bz2 index 7fa6a8a529676bc8324d383c8d11f86c66ef453c..863338269bab61fb385344c489d48d1466915b61 100644 GIT binary patch literal 1208 zcmV;p1V{TqT4*^jL0KkKS#6BOfdB+#|L_0*|Nrmj|NqbJ$0`5s-*CW0grxvV07V4= z#YuEo&;$O8fgmQKVWLd}XliXV4Jo|{$vjM$h||>3lRynJ4@5STKx7&K(@dIZ^*v4M zO&SQACR0r@JyX%5c}+CX000Jn00000000004FExt044!3GGxF2m=ggpFiZdd005a7 z34shC5M;m!fJ{u8FaRb5z)VaN00000CPo5aLkIyPA|TR1Jk->A4Npn6GJ1y8(7_rs z(V!328aANF8ZsJa^wA6v=#2sCEv>fvAEl-1JsnyijCVVn;F96iw5rqPe7fD8oTY%# zzkuFvwU@36G3K_Qb9Sag|zst|i=R^b=#SNyh%ugP6%%MroDY)>eBF2GVY8z>^ zA#zxcHJ~$H7_haaFxpbV8FL9XCW(Qu5ipQT9FWH50EP%nnyiM8k?@$e86)x5;K|ab zjRE)de=To@@M38Tdc;E#&wkd|ogxudAm_AcG^Zpl&8cWfutQ+j8P2|N;UJ?)WMH{j zkdUguXf=;74rRSb@MjvmMs8TC%hb};SB$d}XTE5h+iFFPJxFCbzy&paR@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