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

Pedro Alves
2012-12-13T16:43:02Z

Oh, the problem was really there, but I got confused pointing
at where it is :-). It's in pe_text_section_offset itself:

/* Get the rva and size of the export section. */
for (i = 0; i < nsections; i++)
{
char sname[8];
unsigned long secptr1 = secptr + 40 * i;
unsigned long vaddr = pe_get32 (abfd, secptr1 + 12);

bfd_seek (abfd, (file_ptr) secptr1, SEEK_SET);
bfd_bread (sname, (bfd_size_type) 8, abfd);
if (strcmp (sname, ".text") == 0)
return vaddr;
}

So sname should be 9 bytes, and be null terminated after the bfd_bread here too.
Want to give it a go?

--
Pedro Alves