Fwd: error in variable dereferencing

Thibaud GUERIN thibaud@ploposor.com
Thu Apr 20 14:37:00 GMT 2006


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


More information about the Gcc-help mailing list