[FFmpeg-devel] [RFC] replace some static with asm_visibility or so
Trent Piepho
xyzzy
Sun Jan 27 21:24:32 CET 2008
On Sun, 27 Jan 2008, Uoti Urpala wrote:
> likely to cause miscompilations. I don't see how asm in particular would
> be relevant for GOT use. If you want to minimize indirection through GOT
> you should declare visibility whether there is asm or not; and if you're
> willing to add relocations where GOT use cannot otherwise be avoided
> then you shouldn't be compiling with -fPIC.
If you use a global symbol directly in asm code, i.e. use MANGLE, then you
get text relocations (if supported by the system) when creating a dynamic
shared object or a position independent executable.
I don't know of any way to get gcc to use text relocations with asm
arguments. A contraint like "i"(table) will produce an error when
compiling in PIC mode. Text relocations have costs, and PIC code using a
GOT has different costs. One could make the case that using TEXTRELs in
the inner loops of optimized asm functions is better than trying to make
that code PIC. It is probably the situation in which the costs are least
for TEXTRELs and the most for PIC/GOT.
Another issue is that using scale-index-base addressing of a global array
requires very different asm code to do in a PIC manner vs the optimal
non-PIC method. One might want this in non-PIC code:
some_loop:
mov table(,%eax,4), %edx
...
jnz some_loop
And for PIC you would want:
lea table(%rip), %r8
some_loop:
mov (%r8,%rax,4), %edx
...
jnz some_loop
I don't know of any easy way to have gcc generate the correct asm block for
pic vs non-pic (and x86-64 vs ia32) from the same code in this case.
More information about the ffmpeg-devel
mailing list