From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25393 invoked by alias); 19 Nov 2008 21:21:10 -0000 Received: (qmail 25316 invoked by uid 22791); 19 Nov 2008 21:21:09 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 19 Nov 2008 21:20:12 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mAJLKBIF020485 for ; Wed, 19 Nov 2008 16:20:11 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mAJLKAh2000775 for ; Wed, 19 Nov 2008 16:20:10 -0500 Received: from mesquite.lan (vpn-14-64.rdu.redhat.com [10.11.14.64]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mAJLK90H007687 for ; Wed, 19 Nov 2008 16:20:10 -0500 Date: Thu, 20 Nov 2008 02:02:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [RFC] Make solib-frv.c work in a non-FDPIC environment Message-ID: <20081119142009.75faf39e@mesquite.lan> In-Reply-To: <20081115161443.GB19656@caradoc.them.org> References: <20081114162103.05241f81@mesquite.lan> <20081115161443.GB19656@caradoc.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00513.txt.bz2 On Sat, 15 Nov 2008 11:14:43 -0500 Daniel Jacobowitz wrote: > On Fri, Nov 14, 2008 at 04:21:03PM -0700, Kevin Buettner wrote: > > + if (nsegs < 0) > > + return NULL; > > + > > /* Allocate space for the complete (external) loadmap. */ > > ext_ldmbuf_size = sizeof (struct ext_elf32_fdpic_loadmap) > > + (nsegs - 1) * sizeof (struct ext_elf32_fdpic_loadseg); > > <= 0? I realize it's probably OK in practice, assuming > ext_elf32_fdpic_loadmap has a trailing [1] array, but allocating less > than the size of the array would be strange. I agree. Here's the version that I committed: * solib-frv.c (fetch_loadmap): Return early when no segments are found. (frv_relocate_main_executable): Return early when both interpreter and executable loadmap addresses are zero. Index: solib-frv.c =================================================================== RCS file: /cvs/src/src/gdb/solib-frv.c,v retrieving revision 1.22 diff -u -p -r1.22 solib-frv.c --- solib-frv.c 26 Aug 2008 17:30:35 -0000 1.22 +++ solib-frv.c 19 Nov 2008 21:15:17 -0000 @@ -124,6 +124,9 @@ fetch_loadmap (CORE_ADDR ldmaddr) nsegs = extract_unsigned_integer (ext_ldmbuf_partial.nsegs, sizeof ext_ldmbuf_partial.nsegs); + if (nsegs <= 0) + return NULL; + /* Allocate space for the complete (external) loadmap. */ ext_ldmbuf_size = sizeof (struct ext_elf32_fdpic_loadmap) + (nsegs - 1) * sizeof (struct ext_elf32_fdpic_loadseg); @@ -860,16 +863,17 @@ static void frv_relocate_main_executable (void) { int status; - CORE_ADDR exec_addr; + CORE_ADDR exec_addr, interp_addr; struct int_elf32_fdpic_loadmap *ldm; struct cleanup *old_chain; struct section_offsets *new_offsets; int changed; struct obj_section *osect; - status = frv_fdpic_loadmap_addresses (target_gdbarch, 0, &exec_addr); + status = frv_fdpic_loadmap_addresses (target_gdbarch, + &interp_addr, &exec_addr); - if (status < 0) + if (status < 0 || (exec_addr == 0 && interp_addr == 0)) { /* Not using FDPIC ABI, so do nothing. */ return;