From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11080 invoked by alias); 26 Feb 2003 17:14:31 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11064 invoked from network); 26 Feb 2003 17:14:30 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by 172.16.49.205 with SMTP; 26 Feb 2003 17:14:30 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id 91DE759D360 for ; Wed, 26 Feb 2003 18:14:29 +0100 (CET) Received: from suse.cz (naga.suse.cz [10.20.1.16]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id h1QHET401502 for ; Wed, 26 Feb 2003 18:14:29 +0100 X-Authentication-Warning: chimera.suse.cz: Host naga.suse.cz [10.20.1.16] claimed to be suse.cz Message-ID: <3E5CF5F5.10300@suse.cz> Date: Wed, 26 Feb 2003 17:14:00 -0000 From: Michal Ludvig Organization: SuSE CR User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: GDB Patches Subject: [RFA] Dwarf2CFI fix Content-Type: multipart/mixed; boundary="------------050508030205000209090709" X-SW-Source: 2003-02/txt/msg00713.txt.bz2 This is a multi-part message in MIME format. --------------050508030205000209090709 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 475 Hi all, my code in dwarf2cfi.c assumed that CIE and FDE entries in .eh_frame are always in the chain CIE, FDE, FDE, ..., CIE, FDE, ... where every FDE refers to the precedent CIE. Unfortunately this is not alway the case. Linker (?) sometimes optimizes things in a way that the assumption isn't true anymore. This patch addresses the problem. OK to commit? Head and 5.3? Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * (+420) 296.545.373 * http://www.suse.cz --------------050508030205000209090709 Content-Type: text/plain; name="cfi-ciefdeorder-2-export.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cfi-ciefdeorder-2-export.diff" Content-length: 2587 2003-02-26 Michal Ludvig * dwarf2cfi.c (parse_frame_info): It's not true that FDEs always refer to the last CIE. We must deal with such a situation. * dwarf2cfi.h ( diff -upr gdb-upto-08/dwarf2cfi.c gdb/dwarf2cfi.c --- gdb-upto-08/dwarf2cfi.c 2003-02-26 10:20:02.000000000 +0100 +++ gdb/dwarf2cfi.c 2003-02-26 17:17:30.000000000 +0100 @@ -50,6 +50,10 @@ struct cie_unit char *data; unsigned int data_length; + /* This field is 1 for CIE from .eh_frame + and 0 for one from .debug_frame. */ + int eh_frame; + struct objfile *objfile; /* Next in chain. */ @@ -1502,6 +1502,7 @@ parse_frame_info (struct objfile *objfil char *aug; cie->objfile = objfile; + cie->eh_frame = (eh_frame > 0); cie->next = cie_chunks; cie_chunks = cie; @@ -1586,26 +1587,31 @@ parse_frame_info (struct objfile *objfil /* We assume that debug_frame is in order CIE,FDE,CIE,FDE,FDE,... and thus the CIE for this FDE - should be stored in last_cie pointer. If not, we'll - try to find it by the older way. */ - if (last_cie) + should be stored in last_cie pointer. + However this assumption is not always true, because + the linker does some magic and adds ghost CIEs under + some circumstances. Thus we need to do some safety + checks. If last_cie isn't valid, we'll try to find + the correct one using the older way. */ + if (last_cie && last_cie->objfile == objfile && + last_cie->eh_frame == (eh_frame > 0) && + ((eh_frame && + last_cie->offset == (unit_offset + bytes_read - cie_id)) || + (!eh_frame && (cie->offset == cie_id)))) cie = last_cie; else { - warning ("CFI: last_cie == NULL. " - "Perhaps a malformed %s section in '%s'...?\n", - curr_section_name, objfile->name); - cie = cie_chunks; while (cie) { if (cie->objfile == objfile) { - if (eh_frame && - (cie->offset == - (unit_offset + bytes_read - cie_id))) + if (eh_frame && cie->eh_frame && + cie->offset == + (unit_offset + bytes_read - cie_id)) break; - if (!eh_frame && (cie->offset == cie_id)) + if (!eh_frame && !cie->eh_frame && + cie->offset == cie_id) break; } @@ -1614,6 +1620,7 @@ parse_frame_info (struct objfile *objfil if (!cie) error ("CFI: can't find CIE pointer [in module %s]", bfd_get_filename (abfd)); + last_cie = cie; } init_loc = read_encoded_pointer (abfd, &start, --------------050508030205000209090709--