aarch64: Add an offset parameter to the movrel macro
authorMartin Storsjö <martin@martin.st>
Wed, 9 Nov 2016 09:47:57 +0000 (11:47 +0200)
committerMartin Storsjö <martin@martin.st>
Thu, 10 Nov 2016 09:06:08 +0000 (11:06 +0200)
With apple tools, the linker fails with errors like these, if the
offset is negative:

ld: in section __TEXT,__text reloc 8: symbol index out of range for architecture arm64

Signed-off-by: Martin Storsjö <martin@martin.st>
libavutil/aarch64/asm.S

index 6a7f506..0fc649a 100644 (file)
@@ -72,15 +72,21 @@ ELF     .size   \name, . - \name
 \name:
 .endm
 
-.macro  movrel rd, val
+.macro  movrel rd, val, offset=0
 #if CONFIG_PIC && defined(__APPLE__)
+    .if \offset < 0
         adrp            \rd, \val@PAGE
         add             \rd, \rd, \val@PAGEOFF
+        sub             \rd, \rd, -(\offset)
+    .else
+        adrp            \rd, \val+(\offset)@PAGE
+        add             \rd, \rd, \val+(\offset)@PAGEOFF
+    .endif
 #elif CONFIG_PIC
-        adrp            \rd, \val
-        add             \rd, \rd, :lo12:\val
+        adrp            \rd, \val+\offset
+        add             \rd, \rd, :lo12:\val+\offset
 #else
-        ldr             \rd, =\val
+        ldr             \rd, =\val+\offset
 #endif
 .endm