[x264-devel] Possible fix for loader error while building OS X x86_64 dynamic shared library libx264.dylib

Dimitry Andric dimitry at andric.com
Thu May 16 13:46:12 CEST 2013


On 2013-05-06 12:44:02 -0700, Paul Sterne wrote:
> I see the following error while building OS X x86_64 dynamic shared library
> libx264.dylib:
>
> *ld: pointer in read-only segment not allowed in slidable image, used in
> coeff_last_sse2 from common/x86/cabac-a.o*

I get a different error (and a warning), but it is probably related:

   ld: warning: -read_only_relocs cannot be used with x86_64
   ld: illegal text-relocation to _x264_coeff_last16_sse2 in common/x86/quant-a.o from l004 in common/x86/cabac-a.o for architecture x86_64

(The warning is due to "-read_only_relocs suppress" being passed to the
linker, which is ignored for x86_64.)


> I think in the case of a dynamic shared library that pointers to
> relocatable code may not be stored in read-only memory because the dynamic
> loader dyld needs to update those pointers when the library image virtual
> address is changed.

As I wrote in another post, OS X usually uses a different section for
relocatable const data, which can be specified in yasm as ".const_data".

So I am currently using the following diff, similar to yours, where I
specify .const_data for the coeff_last_xxx variables (and I also changed
the alignment to be the same as for the other sections).

-Dimitry

diff --git a/common/x86/cabac-a.asm b/common/x86/cabac-a.asm
index 74dbf93..fe768d2 100644
--- a/common/x86/cabac-a.asm
+++ b/common/x86/cabac-a.asm
@@ -62,6 +62,12 @@ cextern coeff_last64_sse2
  cextern coeff_last64_sse2_lzcnt
  cextern coeff_last64_avx2_lzcnt
  
+%ifidn __OUTPUT_FORMAT__,macho64
+    ; Work around the following link error:
+    ; ld: illegal text-relocation to _x264_coeff_last16_sse2 in common/x86/quant-a.o from l285 in common/x86/cabac-a.o for architecture x86_64
+    SECTION .const_data align=16
+%endif
+
  coeff_last_sse2:       COEFF_LAST_TABLE       mmx2,       sse2,       sse2, 16, 15, 16, 4, 15, 64, 16, 15, 16, 64, 16, 15, 16, 64
  coeff_last_sse2_lzcnt: COEFF_LAST_TABLE mmx2_lzcnt, sse2_lzcnt, sse2_lzcnt, 16, 15, 16, 4, 15, 64, 16, 15, 16, 64, 16, 15, 16, 64
  coeff_last_avx2_lzcnt: COEFF_LAST_TABLE mmx2_lzcnt, avx2_lzcnt, sse2_lzcnt, 16, 15, 16, 4, 15, 64, 16, 15, 16, 64, 16, 15, 16, 64


More information about the x264-devel mailing list