From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31437 invoked by alias); 13 Dec 2012 15:03:40 -0000 Received: (qmail 31410 invoked by uid 22791); 13 Dec 2012 15:03:38 -0000 X-SWARE-Spam-Status: No, hits=-7.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Dec 2012 15:03:26 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBDF3NCN014912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Dec 2012 10:03:23 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBDF3MUe023821; Thu, 13 Dec 2012 10:03:23 -0500 Message-ID: <50C9EE3A.20601@redhat.com> Date: Thu, 13 Dec 2012 15:03:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Pierre Muller CC: "'GDB Patches'" Subject: Re: [RFC-v5] Fix .text section offset for windows DLL (was Calling __stdcall functions in the inferior) 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> <20121207071035.GG31477@adacore.com> <50C20A66.70002@gmail.com> <29545.4593528577$1354894901@news.gmane.org> <50C21696.7040006@gmail.com> <50c21914.a750420a.2ec3.ffffe4ffSMTPIN_ADDED_BROKEN@mx.google.com> <50C222D5.4000802@redhat.com> <50C22C20.8090906@redhat.com> <008101cdd920$907e7580$b17b6080$@muller@ics-cnrs.unistra.fr> <50C9B6E0.1050709@redhat.com> <00a201cdd931$b0ee13f0$12ca3bd0$@muller@ics-cnrs.unistra.fr> <50C9E742.1030207@redhat.com> <001201cdd941$f9d83450$ed889cf0$@muller@ics-cnrs.unistra.fr> In-Reply-To: <001201cdd941$f9d83450$ed889cf0$@muller@ics-cnrs.unistra.fr> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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/msg00448.txt.bz2 On 12/13/2012 02:56 PM, Pierre Muller wrote: > Maybe removing the memset before and replacing it by a > sec_name[SCNNMLEN] = '\0'; > after the call to bfd_bread > would make it even more clear that you > always get a nicely zero terminated string... That works too. I'm applying this then. 2012-12-13 Pedro Alves * coff-pe-read.c: Include coff/internal.h. (read_pe_exported_syms): Use SCNNMLEN instead of hardcoded 8. Null terminate buffer explicitly instead of memset the whole buffer. --- gdb/coff-pe-read.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 10bba78..9ebff12 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -34,6 +34,7 @@ #include "symfile.h" #include "objfiles.h" #include "common/common-utils.h" +#include "coff/internal.h" #include @@ -464,12 +465,12 @@ read_pe_exported_syms (struct objfile *objfile) unsigned long vsize = pe_get32 (dll, secptr1 + 8); unsigned long vaddr = pe_get32 (dll, secptr1 + 12); unsigned long characteristics = pe_get32 (dll, secptr1 + 36); - char sec_name[9]; + char sec_name[SCNNMLEN + 1]; int sectix; - memset (sec_name, 0, sizeof (sec_name)); bfd_seek (dll, (file_ptr) secptr1 + 0, SEEK_SET); - bfd_bread (sec_name, (bfd_size_type) 8, dll); + bfd_bread (sec_name, (bfd_size_type) SCNNMLEN, dll); + sec_name[SCNNMLEN] = '\0'; sectix = read_pe_section_index (sec_name);