RE: [RFC-v5] Fix .text section offset for windows DLL (was Calling __stdcall functions in the inferior)

Pierre Muller
2012-12-13T15:08:57Z

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pierre Muller
> Envoyé : jeudi 13 décembre 2012 15:56
> À : 'Pedro Alves'; 'GDB Patches'
> Objet : RE: [RFC-v5] Fix .text section offset for windows DLL (was Calling
> __stdcall functions in the inferior)
>
>
>
> > -----Message d'origine-----
> > De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> > owner@sourceware.org] De la part de Pedro Alves
> > Envoyé : jeudi 13 décembre 2012 15:34
> > À : Pierre Muller; GDB Patches
> > Objet : Re: [RFC-v5] Fix .text section offset for windows DLL (was Calling
> > __stdcall functions in the inferior)
> >
> > On 12/13/2012 12:59 PM, Pierre Muller wrote:
> > >> > There was also the point that section names in PE headers are stored
> in
> > 8
> > >> > character arrays, and are not necessarily zero-terminated --
> > >> > get_pe_section_index
> > >> > does strcmp without accounting for this (grep for SCNNMLEN in bfd).
> > > the section_name are copied using xstrdup from sec_name
> > > char array of length 9, (indexes 0 to 8)
> > > which is reset using memset for each section.
> > > only the indexes 0to 7 are possibly modified by the bfd_bread call,
> > > so that sec_name[8] always should remain a valid termination of the
> > string, no?
> >
> > I see now, thanks. I think this would make the code a tiny bit clearer.
> > WDYT?
>
> Yes, you are right...
>
> 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...

I tried it out, compliation fails because the macro is not set.
You would still need to set that macro,
which is defined in ../include/coff/internal.h
or include that header at start of coff-pe-read.c...

Pierre