[rock-devel] Re: flist wrapper patch

ROCK Mailing List Archives

Attachments
Entire message
+ (text/plain)
Author: rlx@clemy.org
Date:  
To: clifford
CC: rock-devel
Subject: [rock-devel] Re: flist wrapper patch
>
> regarding patch [2004111816541912951]
>
> Bernhard C. Schrenk:
> Use variable argument list for open and open64 in flist wrapper
>
> what exactly is the problem which is solved by the patch. Simply
> assuming open has always three arguments (as before) should do the job
> as well, or not?
>


The problem was, that the old code crashed randomly on x86_64. As I
submitted the patch, I did not exactly know, why it did not work, so I
have appearantly changed more then necessary.

In the meantime I came to the conclusion that it should be enough to change
    int (*orig_open)(const char* f, int a, int b) = 0;
into
    int (*orig_open)(const char* f, int a, ...) = 0;
to show the compiler that he has to use another call type.

The exact reason is:
On x86_64 the arguments are passed in registers. Most in the general
purpose registers, but some (ie. float) in the %xmm0-8 registers.
When a call with variable argument list (or a stdcall without prototype)
is used, the %al register is filled with the number of used xmm registers.
For normal calls the value of %al is undefined (because the number is
already known at compile time).

For the called function gcc generates code, which stores the values of the
xmm registers on the stack (even in code, which does not use these values
and even when compiled with O3). This code uses the passed %al for
calculating an indirect jump target.

Due to the undefined %al (in this case, %rax was used for the address of
orig_open), this jump crashes the process.

Regards,
Bernhard



_______________________________________________
rock-devel mailing list

http://www.rocklinux.net/mailman/listinfo/rock-devel