From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8321 invoked by alias); 13 Dec 2012 16:54:58 -0000 Received: (qmail 8181 invoked by uid 22791); 13 Dec 2012 16:54:55 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.157) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Dec 2012 16:54:51 +0000 Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qBDGskji023615 ; Thu, 13 Dec 2012 17:54:46 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms15.u-strasbg.fr [130.79.204.115]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qBDGskcS023290 ; Thu, 13 Dec 2012 17:54:46 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qBDGsjl7003900 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Thu, 13 Dec 2012 17:54:45 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Pedro Alves'" Cc: "'GDB Patches'" References: <20121024194517.GK3555@adacore.com> <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> <50C9EE3A.20601@redhat.com> <50CA0582.5070107@redhat.com> In-Reply-To: <50CA0582.5070107@redhat.com> Subject: RE: [RFC-v5] Fix .text section offset for windows DLL (was Calling __stdcall functions in the inferior) Date: Thu, 13 Dec 2012 16:54:00 -0000 Message-ID: <000c01cdd952$8f5a7c30$ae0f7490$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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/msg00455.txt.bz2 > -----Message d'origine----- > De : gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Pedro Alves > Envoy=C3=A9 : jeudi 13 d=C3=A9cembre 2012 17:43 > =C3=80 : Pedro Alves > Cc : Pierre Muller; 'GDB Patches' > Objet : Re: [RFC-v5] Fix .text section offset for windows DLL (was Calling > __stdcall functions in the inferior) >=20 > Oh, the problem was really there, but I got confused pointing > at where it is :-). It's in pe_text_section_offset itself: >=20 > /* Get the rva and size of the export section. */ > for (i =3D 0; i < nsections; i++) > { > char sname[8]; > unsigned long secptr1 =3D secptr + 40 * i; > unsigned long vaddr =3D pe_get32 (abfd, secptr1 + 12); >=20 > bfd_seek (abfd, (file_ptr) secptr1, SEEK_SET); > bfd_bread (sname, (bfd_size_type) 8, abfd); > if (strcmp (sname, ".text") =3D=3D 0) > return vaddr; > } >=20 > So sname should be 9 bytes, and be null terminated after the bfd_bread he= re > too. You are right once more... Strange, because I really thought I copied it from the other=20 function... > Want to give it a go? OK, we were probably lucky because most DLL's have their .text section as first section, so that we never get = to=20 8 char long names... ChangeLog entry: 2012-12-13 Pierre Muller * coff-pe-read.c (pe_text_section_offset): Increase size of sname local variable and zero terminate it to avoid possible problems in strcmp. Index: coff-pe-read.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/coff-pe-read.c,v retrieving revision 1.21 diff -u -r1.21 coff-pe-read.c --- coff-pe-read.c 13 Dec 2012 15:11:36 -0000 1.21 +++ coff-pe-read.c 13 Dec 2012 16:49:13 -0000 @@ -672,12 +672,13 @@ pe_text_section_offset (struct bfd *abfd /* Get the rva and size of the export section. */ for (i =3D 0; i < nsections; i++) { - char sname[8]; + char sname[SCNNMLEN + 1]; unsigned long secptr1 =3D secptr + 40 * i; unsigned long vaddr =3D pe_get32 (abfd, secptr1 + 12); bfd_seek (abfd, (file_ptr) secptr1, SEEK_SET); - bfd_bread (sname, (bfd_size_type) 8, abfd); + bfd_bread (sname, (bfd_size_type) SCNNMLEN, abfd); + sname[SCNNMLEN] =3D '\0'; if (strcmp (sname, ".text") =3D=3D 0) return vaddr; }