This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Eli reported a problem with GDB trying to call a function in kernel32.dll. The idea that the calling convention was responsible for the signal when trying to call a function declared in kernel32 dll did not make muich sense for a function like GetLastError, which has no parameters. All i386 calling convention agree that simple return values should be in register EAX. Anyhow an error on location of return value should only have the effect of losing the correct return value but never generate a signal... After some investigation, I noticed that the minimal symbol GetLastError was offset by 0xf0000 respective to the '_imp__GetLastError@0'. The patch attached allowed me to call (gdb) call GetLastError () And get a simple $2 = 126 (for instance, depending on when you do the call). Could someone please test the patch and confirm that it does fix the problem? The main fix consists in a new function pe_text_section_offset that I added to coff-pe-read.c source, which allows to fetch the real offset of the .text section relative to the image base, instead of assuming 0x1000. I tried to leave the code in windows_xfer_shared_library "backward compatible", in the sense that if the DLL is not available (as might happen using gdbserver) we still default to 0x1000 value. In fact, the patch contains a second fix about the parsing of exported symbols, which currently can mix symbol names and associated RVA addresses if some function had a imposed ordinal value (which can lead to empty entries in the RVA addresses array). I did not separate the two parts as I was unsure if they are really independent. Comments most welcome, Pierre Muller GDB pascal language maintainer > -----Message d'origine----- > De?: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] De la part > de Eli Zaretskii > Envoyé?: vendredi 12 octobre 2012 15:26 > À?: Pedro Alves > Cc?: mark.kettenis@xs4all.nl; gdb@sourceware.org > Objet?: Re: Calling __stdcall functions in the inferior > > > Date: Fri, 12 Oct 2012 12:27:53 +0100 > > From: Pedro Alves <palves@redhat.com> > > CC: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb@sourceware.org > > > > In gcc/config/i386/winnt.c: > > > > /* Return string which is the function name, identified by ID, modified > > with a suffix consisting of an atsign (@) followed by the number of > > bytes of arguments. If ID is NULL use the DECL_NAME as base. If > > FASTCALL is true, also add the FASTCALL_PREFIX. > > Return NULL if no change required. */ > > > > static tree > > gen_stdcall_or_fastcall_suffix (tree decl, tree id, bool fastcall) > > { > > > > As you see above, fastcall also has identifiable decoration. > > Thanks.
Attachment:
fix-dll-offset.patch
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |