[FFmpeg-devel] [PATCH] configure: reserve a register for gcc before 5 on x86_32 with PIE

James Almer jamrial at gmail.com
Sun Nov 20 05:40:14 EET 2016


On 11/20/2016 12:19 AM, Ronald S. Bultje wrote:
> Hi,
> 
> On Sat, Nov 19, 2016 at 7:07 PM, Andreas Cadhalpun <
> andreas.cadhalpun at googlemail.com> wrote:
> 
>> gcc before gcc-5 reserves a register on x86_32 for the GOT, when PIE is
>> enabled.
>>
>> This fixes build failures due to:
>> error: 'asm' operand has impossible constraints
>>
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
>> ---
>>
>> A build log of a failed build with gcc 4.9 is available at:
>> https://buildd.debian.org/status/fetch.php?pkg=ffmpeg&
>> arch=i386&ver=7%3A3.2-2~bpo8%2B1&stamp=1478791165
>>
>> ---
>>  configure | 13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>>
>> diff --git a/configure b/configure
>> index b5bfad6..8794580 100755
>> --- a/configure
>> +++ b/configure
>> @@ -5364,6 +5364,19 @@ EOF
>>      enabled ssse3  && check_inline_asm ssse3_inline  '"pabsw %xmm0,
>> %xmm0"'
>>      enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
>>
>> +    case "$toolchain" in
>> +        hardened)
>> +            if enabled x86_32; then
>> +                # When PIE is enabled on x86_32, gcc before gcc-5
>> reserves a register for the GOT.
>> +                case $gcc_basever in
>> +                    2*|3*|4*)
>> +                        disable ebp_available
>> +                    ;;
>> +                esac
>> +            fi
>> +        ;;
>> +    esac
> 
> 
> This doesn't test whether PIE is enabled, it does it unconditionally. I'm
> almost 100% sure that's not necessary.
> 
> Ronald

"-fPIE" is added unconditionally to cflags somewhere else in configure
if the hardened toolchain is used.

In any case, there's a test for ebp_available long after "-fPIE" is
added to cflags and it evidently passes on gcc < 5, so the proper way
to do this is to either fix/adapt the ebp_available check  (assuming
gcc < 5 x86_32 reserves that specific register when -fPIE is used), or
adding a different check that can detect this behavior and make it
alter HAVE_7REGS and HAVE_6REGS, in a similar fashion ebp_available
and ebx_available do.



More information about the ffmpeg-devel mailing list