diff mbox

[FFmpeg-devel,6/9] aarch64: Add an offset parameter to the movrel macro

Message ID 1479119547-7392-6-git-send-email-martin@martin.st
State Accepted
Commit c44a8a3eabcd6acd2ba79f32ec8a432e6ebe552c
Headers show

Commit Message

Martin Storsjö Nov. 14, 2016, 10:32 a.m. UTC
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

This is cherry-picked from libav commit
 libavutil/aarch64/asm.S | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff mbox


diff --git a/libavutil/aarch64/asm.S b/libavutil/aarch64/asm.S
index ff34e7a..523b8c5 100644
--- a/libavutil/aarch64/asm.S
+++ b/libavutil/aarch64/asm.S
@@ -72,15 +72,21 @@  ELF     .size   \name, . - \name
-.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
-        adrp            \rd, \val
-        add             \rd, \rd, :lo12:\val
+        adrp            \rd, \val+\offset
+        add             \rd, \rd, :lo12:\val+\offset
-        ldr             \rd, =\val
+        ldr             \rd, =\val+\offset