From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14330 invoked by alias); 7 Dec 2012 07:10:59 -0000 Received: (qmail 14321 invoked by uid 22791); 7 Dec 2012 07:10:56 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO,TW_BJ X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Dec 2012 07:10:51 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 19B4F2E46B; Fri, 7 Dec 2012 02:10:50 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id iRvBtljtv5tx; Fri, 7 Dec 2012 02:10:50 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 6D5312E19E; Fri, 7 Dec 2012 02:10:49 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 39561C3745; Fri, 7 Dec 2012 11:10:35 +0400 (RET) Date: Fri, 07 Dec 2012 07:10:00 -0000 From: Joel Brobecker To: Pierre Muller Cc: 'asmwarrior' , 'Eli Zaretskii' , gdb-patches@sourceware.org Subject: Re: [RFC-v5] Fix .text section offset for windows DLL (was Calling __stdcall functions in the inferior) Message-ID: <20121207071035.GG31477@adacore.com> References: <20121024194517.GK3555@adacore.com> <011901cdb2ab$48076b90$d81642b0$@muller@ics-cnrs.unistra.fr> <20121105171121.GA2972@adacore.com> <50991f5f.8382440a.1100.ffff82abSMTPIN_ADDED@mx.google.com> <509ABA17.30507@redhat.com> <000301cdbd96$f5cd9f10$e168dd30$@muller@ics-cnrs.unistra.fr> <20121122173019.GF9964@adacore.com> <15690.5992342674$1353883881@news.gmane.org> <87624si9ur.fsf@fleche.redhat.com> <001501cdccaf$ad85e9b0$0891bd10$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001501cdccaf$ad85e9b0$0891bd10$@muller@ics-cnrs.unistra.fr> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2012-12/txt/msg00131.txt.bz2 > 2012-11-25 Pierre Muller > > * coff-pe-read.h (pe_text_section_offset): Declare new function. > * coff-pe-read.c (debug_coff_pe_read): New static variable. > (struct read_pe_section_data): Add section_name field. > (IMAGE_SCN_CNT_CODE): New macro, if not already defined. > (IMAGE_SCN_CNT_INITIALIZED_DATA): Ditto. > (IMAGE_SCN_CNT_UNINITIALIZED_DATA): Ditto. > (get_pe_section_index): New function. > (struct pe_sections_info): New type. > (get_section_vmas): Use new struct pe_sections_info. > (add_pe_exported_sym): Handle unnamed exported function. > (add_pe_forwarded_sym): New function. > (read_pe_truncate_name): Truncate at last dot. > (pe_as16): New function. > (read_pe_exported_syms): Use ordinal of function to > retrieve correct RVA address of function and handle > forwarded symbol. > (pe_text_section_offset): New function. > (show_debug_coff_pe_read): New function. > (_initialize_coff_pe_read): New function adding > 'set/show debug coff_pe_read' commands. > > * windows-tdep.c (windows_xfer_shared_library): Use > pe_text_section_offset function instead of possibly wrong > 0x1000 constant for .text sextion offset. Looks good - OK to commit after the following minor corrections have been applied. For the record, I have tested this patch on x86-windows against AdaCore's GDB testsuite, no regression. Thank you! > +/* Get the index of the named section in our own full arrayi. Small typo at the end if "array". > +get_pe_section_index (const char *section_name, > + struct read_pe_section_data *sections, > + int nb_sections) > +{ > + int i; > + for (i = 0; i < nb_sections; i++) Missing empty line after variable declarations... > + DLL_NAME is the internal name of the DLL file, > + OBJFILE is the objfile struct of DLL_NAME. */ > + > + > +static int > +add_pe_forwarded_sym (const char *sym_name, const char *forward_dll_name, Can you delete the second empty line? > + char * last_point = strrchr (dll_name, '.'); No space between '*' and 'last_point'. > + otherix++; > + section_data = xrealloc (section_data, otherix > + * sizeof (struct read_pe_section_data)); > + name = xstrdup (sec_name); > + section_data[otherix - 1].section_name = name; > + make_cleanup (xfree, name); > + section_data[otherix - 1].rva_start = vaddr; > + section_data[otherix - 1].rva_end = vaddr + vsize; > + section_data[otherix - 1].vma_offset = 0; > + if (characteristics & IMAGE_SCN_CNT_CODE) > + section_data[otherix - 1].ms_type = mst_text; > + else if (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA) > + section_data[otherix - 1].ms_type = mst_data; > + else if (characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA) > + section_data[otherix - 1].ms_type = mst_bss; > + else > + section_data[otherix - 1].ms_type = mst_unknown; A possible suggestion: It seems simpler to increment otherix at the end rather than at the beginning, and thus have: section_data = xrealloc (section_data, (otherix + 1) [...]); [...] section_data[otherix].rva_end = vaddr + vsize; section_data[otherix].vma_offset = 0; [...] otherix++; > + /* First handle forward cases. */ > + if ((func_rva >= export_rva) > + && (func_rva < export_rva + export_size)) You don't need the extra parentheses... -- Joel