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

Eli Zaretskii
2012-11-03T10:36:24Z

> Date: Mon, 15 Oct 2012 19:23:13 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: gdb-patches@sourceware.org
>
> > From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
> > Date: Mon, 15 Oct 2012 15:35:55 +0200
> >
> > 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).
>
> Thanks.
>
> > Could someone please test the patch and
> > confirm that it does fix the problem?
>
> I will try that in a few days.

Sorry for the long delay.

I tried that now, but then I realized that the patch cannot be applied
to GDB 7.5, because it uses gdb_bfd.h stuff. I tried to work around
that by replacing the call to gdb_bfd_open_maybe_remote by
bfd_open_maybe_remote; that compiled, but when I tried to use the
resulting binary, it crashed in the marked assertion:

gdb.exe caused an Access Violation at location 00532b99 in module gdb.exe Reading from location 00000000.
00532B99 gdb.exe:00532B99 gdb_bfd_unref objfiles.c:1514

...
/* Valid range for p_refcount: a pointer to int counter, which has a
value of 1 (single owner) or 2 (shared). */
> gdb_assert (*p_refcount == 1 || *p_refcount == 2);

*p_refcount -= 1;
...

Is it possible to have a patch for GDB 7.5?

TIA