From: Robert Baruch <autophile@starband.net>
To: Pierre Muller <muller@cerbere.u-strasbg.fr>
Cc: gdb@sources.redhat.com, Eli Zaretskii <eliz@is.elta.co.il>,
Christopher Faylor <cgf@redhat.com>
Subject: Re: [Q] Accessing fs:0 on x86 Linux?
Date: Fri, 14 Dec 2001 07:53:00 -0000 [thread overview]
Message-ID: <3C1A1F92.1090509@starband.net> (raw)
In-Reply-To: <4.2.0.58.20011214092106.00aca8d8@ics.u-strasbg.fr>
Hi Pierre,
> On that target, its rather easy, as the debugger and debuggee share the same local descriptors.
> It should also be possible to do this on cygwin target.
> We would need to use GetThreadSelectorEntry
> win32 API function to get
> the linear base address of the %fs selector.
> This function is not called in current xwin32-nat.c code and this only works
> because win32 kernel does give a zero linear base address to the
> ordinary code and data selector (value of %cs for code , %ds, %es and %ss for data selector).
True, but I'm more concerned about how to do this on Linux, since it
uses a flat memory model.
>
> Regarding wine on linux, this really depends on how wine does set the %fs selector
> base and size, I have no idea how this is done...
Here's the code from Wine which gets some %fs data for an i386 platform.
#if defined(__i386__) && defined(__GNUC__)
extern inline struct _TEB WINAPI *NtCurrentTeb(void);
extern inline struct _TEB WINAPI *NtCurrentTeb(void)
{
struct _TEB *teb;
__asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
return teb;
}
#else
extern struct _TEB WINAPI *NtCurrentTeb(void);
#endif
This is the corresponding disassembly from gdb:
0x400911e2 <task_start+18>: mov %fs:0x18,%esi
So basically it uses inline assembly to manually get fs data.
--Rob
next prev parent reply other threads:[~2001-12-14 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-13 16:55 Robert Baruch
2001-12-14 0:38 ` Pierre Muller
2001-12-14 7:53 ` Robert Baruch [this message]
2001-12-15 9:33 ` Eli Zaretskii
2001-12-15 10:04 ` Andrew Cagney
2001-12-16 0:15 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C1A1F92.1090509@starband.net \
--to=autophile@starband.net \
--cc=cgf@redhat.com \
--cc=eliz@is.elta.co.il \
--cc=gdb@sources.redhat.com \
--cc=muller@cerbere.u-strasbg.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox