Re: Fwd: error in variable dereferencing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/20/06, Andrew Haley <aph@xxxxxxxxxx> wrote:> Thibaud GUERIN writes:>  >>  >>  > 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);>> I don't think that's legal.  (Actually, I'm not perfectly sure it's> not legal, but I think not.)  Also, I have no idea why you're trying> to do such a thing.
as i'm compiling with :-Wall -Werror -nostdinc -Wstrict-aliasing=2it will not compile if it wasn't (i think, not sure too...)
>>  > working, It didn't :>  > ap was equal to &fmt BUT *ap wasn't equal to fmt (don't kown why...)>> I'm sure that's impossible.  :-)
it wasn't belive me... and it's driving me crasy since days....
>  > 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)>> So why not do the obvious>>   const char **ap = &fmt ;>> ?
because i need to do some :ap++;to get the next args in stack, as my end aim is to do re-write a printf...
>>  > The resulting asm was here to help you to understand wath's wrong ....>  > I'm looking for some days now without answer...>> You're still not explaining yourself.  You have a const char* arg that> you are trying to alter, but instead of doing it the obvious way with> an assignment, you're taking the address of the arg, casting the> resulting pointer to a different pointer type, and then overwriting> the arg through the resulting pointer.>> What's the point of all this?>
i'm not trying to alter an (const char*) but to get the args in mystack by getting some pointers on it, as in all va_args fonctions....

An thing i forgot (shame on me) : in my VM, i ork with segmented memory, ....but i don't think that make the trick as all variavles are on stack inthis code (exepte the 'fmt' in the parent function, but it's addressis pushed in stack for the call so....)
the call in the parent is something like :
int parent (){the_bug("string1", "string2", "string 3");}
--Thibaud

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux