[Ffmpeg-devel] [BUG] Compilation failure when using --disable-opts

Måns Rullgård mans
Wed Mar 14 23:03:23 CET 2007


Panagiotis Issaris <takis at issaris.org> writes:

> Hi Diego,
>
> Diego Biurrun schreef:
>> On Wed, Mar 14, 2007 at 09:32:51PM +0100, Panagiotis Issaris wrote:
>>> M?ns Rullg?rd schreef:
>>>> Panagiotis Issaris <takis.issaris at uhasselt.be> writes:
>>>>
>>>>> +int main(){
>>>>> +    volatile int i=0;
>>>>> +    asm volatile (
>>>>> +        "xorl %%ebp, %%ebp"
>>>>> +    ::: "%ebp");
>>>>> +    return i;
>>>>> +}
>>>>> +EOF
>>>> And what's the "int i" good for?
>>> The 'i' is set at the beginning of the program, and so base pointer will
>>> be used to initialize it (it is on the stack). At the end of the program
>>> the the contents of 'i' is the returnvalue of the program and so the
>>> base pointer will again be used to get at the value of 'i'. As it is set
>>> to zero by the inline assembly code, a 0+offset pointer will be
>>> dereferenced caused a segfault. Without the 'i' or with
>>> -fomit-frame-pointer this won't happen.
>> 
>> Could you add a comment?  This is non-intuitive..
> Sure.
>
> Would you prefer the shorted but less clear:
>
> +# check whether EBP is available on x86
> +# As 'i' is stored on the stack, this program will crash
> +# if a the base pointer is used to access it because the
> +# base pointer is cleared in the inline assembly code.

That will do nicely.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list