From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8CEC838515C1; Wed, 26 Jan 2022 16:49:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CEC838515C1 From: "tbuyukliev at vmware dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/104238] dwarf DW_AT_const_value causes overflow in readelf Date: Wed, 26 Jan 2022 16:49:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tbuyukliev at vmware dot com X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Jan 2022 16:49:33 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104238 --- Comment #4 from Todor Buyukliev --- > When gcc is emitting the DW_AT_const_value, it doesn't know if it is sign= ed or unsigned, CONST_INT it uses is always signed. good, so this is as designed. > That sleb128 value is certainly not too large, it fits into 64-bit signed= value it fits, because it was truncated to fit the 64-bit variable readelf uses internally. the bytes in memory are 8080808080808080807f, so in the decoded form bits 6= 4 to 70 inclusive (counting from 1) are 1. the leb128 encoding doesn't have a way to say how many bits the value has, = and this means that it's as wide as the highest non-zero bit, 70 in this case (counting from 1).=