This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: error in variable dereferencing
- From: "Thibaud GUERIN" <thibaud at ploposor dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 20 Apr 2006 22:37:27 +0800
- Subject: Re: Fwd: error in variable dereferencing
- References: <96d59a150604200353h6249fa1fr8a93d20baff37fc5@mail.gmail.com> <96d59a150604200657m53252a12t601302ec580f44b7@mail.gmail.com> <17479.38716.774167.250676@zapata.pink>
On 4/20/06, Andrew Haley <aph@gcc.gnu.org> wrote:
> Thibaud GUERIN writes:
> > hi,
> > I'm actually writing a program in C and i'm fighting with an address
> > dereferencing since some days now.
> >
> > int the_bug(const char *fmt, ...)
> > {
> > char **ap;
> > char **s = (char **)(&fmt);
> >
> > /* __asm__ volatile ( */
> > /* "\tleal %1, %%eax\n" */
> > /* "\tmovl %%eax,%0\n" */
> > /* "\tmovl %1, %%eax\n" */
> > /* "\tmovl %2, %%ebx \n" */
> > /* "\tmovl %%eax, (%%ebx)\n" */
> > /* : "=m"(ap) : "m" (fmt), "m"(ap)); */
>
> This is wrong in so many ways I don't know where to start.
>
> It may be better if you try to tell us what you are trying to do.
>
> Redirecting gcc-help@gcc.gnu.org.
Not clear in the first message, (and maybe not in this one too..), sorry
This asm inline was something like a "test/patch code".
I try to have a simple :
char **ap = (char **)(&fmt);
working, It didn't :
ap was equal to &fmt BUT *ap wasn't equal to fmt (don't kown why...)
so i try by my self... to do :
ap = &fmt;
*ap = fmt;
in asm inline.... (dirty i know...)
problem is :
With this asm code in the binary *s is equal to fmt
Without this asm code in the binary *s isn't equal to fmt
All the 's' variable stuffs are from my debug...
Again :
My only aim is to have an 'ap = &fmt' valid (->ap = &fmt AND *ap = fmt)
The resulting asm was here to help you to understand wath's wrong ....
I'm looking for some days now without answer...
--
Thibaud