From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130614 invoked by alias); 10 Mar 2019 18:22:18 -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 130452 invoked by uid 89); 10 Mar 2019 18:22:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 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, meet 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 0Mdren-1hPmzx26xB-00PdsX; Sun, 10 Mar 2019 19:22:12 +0100 From: Christian Eggers To: binutils@sourceware.org Cc: Christian Eggers Subject: [PATCH 6/7] [gas] dwarf2: Pad size of .debug_line section. Date: Sun, 10 Mar 2019 18:22:00 -0000 Message-Id: <20190310182158.23705-7-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/msg00061.txt.bz2 As all dwarf debug information is organized in octets, the size of all dwarf sections must be aligned to OCTETS_PER_BYTE. Most DWARF sections meet this requirement, only the .debug_line section can reach an arbitrary octet size. In order to align the size to a multiple of OCTETS_PER_BYTE, the section is padded with "nop" statements at the end. 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 | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index 2d7dabc299..c6a857b93c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +2019-03-10 Christian Eggers + + * dwarf2dbg.c (out_debug_line): Pad size of .debug_line section. + 2019-03-10 Christian Eggers * dwarf2dbg.c: Use octets for .debug_string pointers. diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index d469138576..9e68233ad3 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -1787,6 +1787,7 @@ out_debug_line (segT line_seg) symbolS *line_end; struct line_seg *s; int sizeof_offset; + addressT section_end, section_end_aligned; memset (&exp, 0, sizeof exp); sizeof_offset = out_header (line_seg, &exp); @@ -1848,6 +1849,19 @@ out_debug_line (segT line_seg) in the DWARF Line Number header. */ subseg_set (subseg_get (".debug_line_end", FALSE), 0); + /* Pad size of .debug_line section to a multiple of OCTETS_PER_BYTE. Simply + sizing the section in md_section_align() is not sufficient, also the size + field in the .debug_line header must be a multiple of OCTETS_PER_BYTE. Not + doing so will introduce gaps within the .debug_line sections after linking. + */ + section_end = frag_now_fix_octets (); + section_end_aligned = (section_end + OCTETS_PER_BYTE - 1) & + ~(OCTETS_PER_BYTE - 1); + for ( ; section_end != section_end_aligned; section_end++) + { + out_inc_line_addr (0, 0); /* NOP */ + } + symbol_set_value_now_octets (line_end); } -- 2.16.4