[Ffmpeg-devel] Broken trunk on AMD64 with PIC enabled

Michael Niedermayer michaelni
Wed Apr 4 00:36:08 CEST 2007


On Tue, Apr 03, 2007 at 02:58:33PM -0700, Trent Piepho wrote:
> > libavutil/internal.h
> > add a MANGLE2 without rip and use that where addressing over rip is inpossible
> MANGLE uses rip relative addressing for PIC code, but scale-index-base
> addressing can't be used at the same time as rip relative.  


> There is
> nothing that can be used for "ff_h264_lps_range(%eax, %esi, 2)" that is PIC
> for ia32 or x86-64.

it can be done with relocations, that is in theory, i dont know if the
compiler/linker/loader can do it and i dont have the time to play with this
ATM, working and clean patches welcome, complaints not

> I've got to wonder, what the point of MANGLE is?  

its point is to workaround some gcc bugs with too many operands

> Not a single reference to
> MANGLE in cabac.h is going to work in PIC mode, so what's the point of
> MANGLE pretending to support pic?  This is what I would do:
> asm("movzbl %c2(%1, %0, 2), %0"
>     : "+r"(range)
>     : "r"(ret), "e"(ff_h264_lps_range));
> The 'e' constraint selects a signed 32-bit constant or symbolic reference,
> which is exactly what is allowed (for both ia32 and x86-64) for the
> displacement field in the address.

this will likely  break with old gcc (hint MANGLE was often added becasue gcc
failed with any other way to access the variables), also it doesnt fix the
problem ...

> gcc will correctly tell you this asm can't be compiled in PIC mode.  If you
> want PIC, ff_h264_lps_range is not a constant, so you must put it in a
> register or not use any addressing modes.

you could use self modifying code or let the loader fix the address up if
it supports that which as i said i dont have time ATM to find out


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

1. write clean, simple and working code
2. high level optimizations
3. low level optimizations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070404/263c8b3c/attachment.pgp>

More information about the ffmpeg-devel mailing list