From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9894 invoked by alias); 23 Feb 2020 18:35:22 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 9883 invoked by uid 89); 23 Feb 2020 18:35:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.18) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Feb 2020 18:35:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1582482916; bh=q22m4W+z3mUy70Nbal61cF546+0IGgbSJ8lTXHCtdCk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jzaqWRcZXekFKQ/5OaebJdb0d74gkLy5UHrZQcvrB3JfqLFLzf1HLxUpP+uDHpQdt lT7W7OdUswGOkDxfwPIgCBA1jywt5iCAHTttASFR06YdVkKsZEpvp53/5fLo/jdDT3 BBkA4svQ3pxNqE2341ESiIkzjYN9PQeLW2S0zEgI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from zbook-opensuse.wgnetz.xx ([77.2.49.177]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Ma24s-1itoal3vyW-00VyeG; Sun, 23 Feb 2020 19:35:15 +0100 From: Christian Eggers To: Alan Modra Cc: binutils@sourceware.org Subject: Re: [PATCH v3 0/2] Fix several mix up between octets and bytes in ELF program headers Date: Sun, 23 Feb 2020 18:35:00 -0000 Message-ID: <15367374.l5TCXVdO3P@zbook-opensuse.wgnetz.xx> In-Reply-To: <20200220012952.GW5570@bubble.grove.modra.org> References: <20564877.7Tol0G4XMo@zbook-opensuse.wgnetz.xx> <5653117.1aehKcCLEe@zbook-opensuse.wgnetz.xx> <20200220012952.GW5570@bubble.grove.modra.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00519.txt.bz2 And now the debug information: Currently, expressions within the debug sections are resolved either to oct= ets or to bytes (depending on SEC_ELF_OCTETS of the symbol in the expression). This happens within GAS, so these expression will not appear as external symbols nor relocations. Example 1: TC_DWARF2_EMIT_OFFSET (section_symbol (info_seg), sizeof_offset); resolves to octets as info_seg belongs to the .debug_info section which has SEC_ELF_OCTETS set Example 2: /* DW_AT_high_pc */ ... exp.X_add_symbol =3D all_segs->text_end; resolves to bytes as the .text section has no SEC_ELF_OCTETS set The proposed change is that expressions / fixes with symbols of a non SEC_ELF_OCTETS section... - resolve to octets if the expression appears in a SEC_ELF_OCTETS section - resolve to bytes if the expression appears inside another section So the result of a fix must be multiplied with octets_per_byte if the symbol value is bytes (e.g. !(S_IS_OCTETS (fixP->fx_addsy))) and the section of the fix has SEC_ELF_OCTETS set. Possibly this could be done in fixup_segment() when calling md_apply_fix(). As an alternative approach, the conversion from bytes to octets could be "manually" triggered by setting a new flag inside expressionS / fixS, which can be checked in fixup_segment(). - out_debug_line(): + process_entries(): Needs 3 conversions + out_set_addr(): No changes + emit_expr() - out_debug_ranges(): No changes + emit_expr() - out_debug_aranges(): No changes + emit_expr() - out_debug_abbrev(): No changes - out_debug_str(): No changes (already octets) - out_debug_info(): No changes + emit_expr() Conclusion: In order to change debug information from bytes to octets, it should be sufficient to perform a conversion for the generated debug line info. Additionally, fixes applied within SEC_ELF_OCTETS sections may need conversion to octets if the symbol value resolved to bytes. If I could get some feedback for the proposed changes to r_offset, r_added, st_value and debug_info, I would implement the changes soon. I hope that together with my previous patches, the octets/bytes topic can be closed the= n. Regards Christian