[FFmpeg-devel] PIC and YASM

Reimar Döffinger Reimar.Doeffinger
Sun Nov 8 00:30:31 CET 2009

I have been trying to figure out some compilation issues with hardened
gentoo on AMD64 and they all come down to YASM.
Several issues:
-DPIC is and must be added explicitly to the yasm flags.
in particular:
--enable-pic will not add -DPIC to YASMFLAGS, nor will the enable_pic
function. --enable-shared will though.
Also the code will not be compiled as PIC if the compiler generates
PIC code by default (the remaining code handles this by detecting
__PIC__ or __pic__ set by the compiler).
Lastly, this is also inconsistent with all other code, including other
asm code, which always uses RIP-relative addressing for AMD64 (which is
the only effect that -DPIC has for the yasm stuff).
The easiest way to "fix" this and at the same time remove some crap from
configure is to do this:
Index: x86/x86inc.asm
--- x86/x86inc.asm      (revision 20469)
+++ x86/x86inc.asm      (working copy)
@@ -60,10 +60,8 @@
 ; Some distros prefer shared objects to be PIC, but nothing breaks if
 ; the code contains a few textrels, so we'll skip that complexity.
-%ifdef WIN64
+%ifdef ARCH_X86_64
     %define PIC
-%elifndef ARCH_X86_64
-    %undef PIC
 %ifdef PIC
     %define GLOBAL wrt rip

More information about the ffmpeg-devel mailing list