From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130330 invoked by alias); 10 Mar 2019 18:22:17 -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 130227 invoked by uid 89); 10 Mar 2019 18:22:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:sk:2019031, H*i:sk:2019031, H*f:sk:2019031, fulfilled 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, 10 Mar 2019 18:22:15 +0000 Received: from zbook-opensuse.wgnetz.xx ([95.114.8.183]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MDhny-1hHvCM2eVi-00H5K6; Sun, 10 Mar 2019 19:22:12 +0100 From: Christian Eggers To: binutils@sourceware.org Cc: Christian Eggers Subject: [PATCH 7/7] [gas] dwarf2: Align relocation within .debug_line section Date: Sun, 10 Mar 2019 18:22:00 -0000 Message-Id: <20190310182158.23705-8-ceggers@gmx.de> In-Reply-To: <20190310182158.23705-1-ceggers@gmx.de> References: <20190310182158.23705-1-ceggers@gmx.de> X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00060.txt.bz2 All relocations must be aligned to OCTETS_PER_BYTE. As dwarf debug information is organized in octets, some relocations may not be aligned to "bytes" quantities. In most dwarf sections this requirement is already fulfilled, only relocations for symbol address within the .debug_line section can be misaligned. In order to align these relocations to a multiple of OCTETS_PER_BYTE, "nop" statements are inserted at a appropriate location. This change should not affect existing targets as all targets currently using DWARF2 have 8 bit per byte. Signed-off-by: Christian Eggers --- gas/ChangeLog | 4 ++++ gas/dwarf2dbg.c | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index c6a857b93c..217c4024fb 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +2019-03-10 Christian Eggers + + * dwarf2dbg.c (out_set_addr): Align relocation within .debug_line section. + 2019-03-10 Christian Eggers * dwarf2dbg.c (out_debug_line): Pad size of .debug_line section. diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 9e68233ad3..7e912d7896 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -1108,16 +1108,31 @@ get_frag_fix (fragS *frag, segT seg) /* Set an absolute address (may result in a relocation entry). */ +static void +out_inc_line_addr (int line_delta, addressT addr_delta); + static void out_set_addr (symbolS *sym) { expressionS exp; + addressT expr_addr, expr_addr_aligned; memset (&exp, 0, sizeof exp); - out_opcode (DW_LNS_extended_op); - out_uleb128 (sizeof_address + 1); - out_opcode (DW_LNE_set_address); + /* The expression at the bottom must be aligned to OCTETS_PER_BYTE. The + statements after the for loop will contribute 3 more octets. */ + expr_addr = frag_now_fix_octets () + 3; + expr_addr_aligned = (expr_addr + OCTETS_PER_BYTE - 1) & + ~(OCTETS_PER_BYTE - 1); + for ( ; expr_addr != expr_addr_aligned; expr_addr++) + { + out_inc_line_addr (0, 0); /* NOP */ + } + + out_opcode (DW_LNS_extended_op); /* 1 octet */ + out_uleb128 (sizeof_address + 1); /* 1 octet */ + + out_opcode (DW_LNE_set_address); /* 1 octet */ exp.X_op = O_symbol; exp.X_add_symbol = sym; exp.X_add_number = 0; -- 2.16.4