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

asmwarrior
2012-12-09T13:19:04Z

On 2012-12-9 20:45, Pierre Muller wrote:
> Hi Yuanhui,
>
>
>> -----Message d'origine-----
>> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
>> owner@sourceware.org] De la part de asmwarrior
>> EnvoyÃ© : dimanche 9 dÃ©cembre 2012 03:48
>> Ã€ : Pierre Muller
>> Cc : 'Joel Brobecker'; 'Eli Zaretskii'; gdb-patches@sourceware.org
>> Objet : Re: [RFC-v5] Fix .text section offset for windows DLL (was Calling
>> __stdcall functions in the inferior)
>>
>> On 2012-12-9 2:00, Pierre Muller wrote:
>>> This memory corruption is rather odd...
>>> it seems that the rva_end of index=2 seems to contains the same data
>>> as the section_name for index 4...
>>> This array is really created only inside read_pe_exported_syms
>>> so that it would be worth trying to add a breakpoint at that function,
>>> and step over it for ntdll.dll to understand when the data gets
>> corrupted...
>>> Would it be possible for you to upload the codeblocks executable that
>> triggers
>>> the problem somewhere so I could
>>> check if I get the same errors and debug further?
>>>
>>> I have no idea what is going on...
>>>
>>>
>>> Pierre Muller
>>>
>> Hi, Pierre:
>>
>> I think you can test the official Codeblocks release 12.11.
>>
>> 1, you can download the release from: http://www.codeblocks.org/downloads/26
>> select this one: codeblocks-12.11-setup.exe
>> Note: the binaries in this release contain debug information (build with -g
>> options)
>
> Strange because I did install program that you are refereeing to above,
> but the installed codeblock.exe files doesn't contain any debug information,
> see elow:
>
> C:\Program Files (x86)\CodeBlocks\debug>dir codeblocks.exe
> Le volume dans le lecteur C s'appelle OS
> Le numÃ©ro de sÃ©rie du volume est 4801-E7AF
>
> RÃ©pertoire de C:\Program Files (x86)\CodeBlocks\debug
>
> 28/11/2012 20:08 1 253 390 codeblocks.exe
> 1 fichier(s) 1 253 390 octets
> 0 RÃ©p(s) 2 344 669 184 octets libres
>
> C:\Program Files (x86)\CodeBlocks\debug>gdbcvs codeblocks.exe
> GNU gdb (GDB) 7.5.50.20121106-cvs
> Copyright (C) 2012 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-mingw32".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Reading symbols from C:\Program Files (x86)\CodeBlocks\debug\codeblocks.exe...(no debugging symbols found)...done.
> (gdb) q
>
> C:\Program Files (x86)\CodeBlocks\debug>objdump -h codeblocks.exe
>
> codeblocks.exe: file format pei-i386
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 000b550c 00401000 00401000 00000400 2**4
> CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
> 1 .data 00000100 004b7000 004b7000 000b5a00 2**2
> CONTENTS, ALLOC, LOAD, DATA
> 2 .rdata 0001bb30 004b8000 004b8000 000b5c00 2**5
> CONTENTS, ALLOC, LOAD, READONLY, DATA
> 3 .eh_frame 00000438 004d4000 004d4000 000d1800 2**2
> CONTENTS, ALLOC, LOAD, READONLY, DATA
> 4 .bss 000086dc 004d5000 004d5000 00000000 2**5
> ALLOC
> 5 .edata 00000985 004de000 004de000 000d1e00 2**2
> CONTENTS, ALLOC, LOAD, READONLY, DATA
> 6 .idata 00014120 004df000 004df000 000d2800 2**2
> CONTENTS, ALLOC, LOAD, DATA
> 7 .CRT 00000018 004f4000 004f4000 000e6a00 2**2
> CONTENTS, ALLOC, LOAD, DATA
> 8 .tls 00000020 004f5000 004f5000 000e6c00 2**2
> CONTENTS, ALLOC, LOAD, DATA
> 9 .rsrc 0003bc0c 004f6000 004f6000 000e6e00 2**2
> CONTENTS, ALLOC, LOAD, DATA
> 10 .reloc 0000f2c8 00532000 00532000 00122c00 2**2
> CONTENTS, ALLOC, LOAD, READONLY, DATA
>
> C:\Program Files (x86)\CodeBlocks\debug>
>
> Are you sure it's the file from codeblocks-12.11-setup.exe
> that you are analyzing?
Sorry, I may be wrong, but look at this post in C::B forum:
http://forums.codeblocks.org/index.php/topic,17200.msg117936.html#msg117936
One of the C::B developer said that the debug information is not stripped in the exe/dll files.
But whether the codeblocks.exe contains the debug information or not, it did crash gdb when I run the
command:
file:

file d:/software/cb/codeblocks/codeblocks.exe
> STOP right here!
>
> You get a warning about memory corruption before the crash!
> So you need to find out why you get this.
Here, in my system, I have two codeblocks.exe, one is under my svn_trunk folder(build myself), which cause my gdb crash when I enter "r" command.
The other one is from the "codeblocks-12.11-setup.exe", which cause gdb crash when I run the "file xxxxx" command.
I'm not sure they refer to the same issue.
> The best would be to start GDB from gdb_stable using
> start command and place an access watchpoint on the location
> that is given (if the address is the same for different runs...)
> awatch *0x2de4228
> should allow to get more information.
> It might not work right after start command,
> because the corresponding memory block might
> not yet be accessible by the program,
> in that case try to add a breakpoint
> at read_pe_exported_syms function,
> and try to insert the watchpoint at each stop at that breakpoint.
>
> This way, we might finally understand which allocated memory
> is accessed after being freed.
It looks like I need to learn some gdb commands I have never used.

Do I need to upload myself build codeblocks binaries somewhere that you want try it?
Or you can already build codeblocks yourself?

Yuanhui Zhang