From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27299 invoked by alias); 12 Mar 2006 18:15:42 -0000 Received: (qmail 27283 invoked by uid 22791); 12 Mar 2006 18:15:40 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sun, 12 Mar 2006 18:15:38 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FIV6O-0003xU-0Y; Sun, 12 Mar 2006 13:15:36 -0500 Date: Mon, 13 Mar 2006 04:59:00 -0000 From: Daniel Jacobowitz To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Re: linker debug info editing Message-ID: <20060312181535.GA15023@nevyn.them.org> Mail-Followup-To: binutils@sourceware.org, gdb-patches@sourceware.org References: <20060310124921.GN6777@bubble.grove.modra.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060310124921.GN6777@bubble.grove.modra.org> User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-03/txt/msg00174.txt.bz2 On Fri, Mar 10, 2006 at 11:19:21PM +1030, Alan Modra wrote: > /* This file implements removal of DIEs for discarded link-once sections. > Such DIEs are detected by parsing debug sections to find DIE boundaries, > then examining relocations for each DIE. Any DIE containing a field > with a relocation against a symbol in a discarded section is marked for > removal. A removed DIE in .debug_info results in all of its children > and associated data in .debug_loc and .debug_ranges being removed too. > A removed CIE in .debug_frame results in all FDEs using that CIE > being removed, but no attempt is made to remove usused CIEs (as can > happen when all of a CIE's FDEs are removed). Likewise, other unused > shared info, ie. .debug_abbrev and .debug_str entries, are not removed. > > We assume that > a) debug section relocations are sorted by r_offset, > b) .debug_info location lists (references to .debug_loc) occur > in increasing order of offset into .debug_loc, > c) .debug_info ranges (references to .debug_ranges) occur > in increasing order of offset into .debug_ranges, > d) entries in .debug_loc and .debug_ranges are not shared, > e) FDEs always occur at higher offsets than their associated CIEs > in .debug_frame. > > ld -r using perverse linker scripts can break the first three > assumptions. */ Jim mentioned references to DIEs. I'm also concerned by deleting just the DIEs containing discarded relocations and their children; that's not necessarily a logical place to cut the DIE tree. In general, this will work for you, because the relocations you're interested in are those on DW_AT_high_pc and DW_AT_low_pc; but if the function uses .debug_ranges instead I guess you won't find it. And there's probably some other cases where this is a problem, e.g. if you are cutting member functions or static variables out of a class type. Removing the children can affect the interpretation of the parent. All these complications are a shame; I think it would be useful if the linker could edit DWARF data. But it may be a bit complicated. -- Daniel Jacobowitz CodeSourcery