aarch64: Fix negative movrel offsets for windows
authorMartin Storsjö <martin@martin.st>
Sun, 9 Jul 2017 20:52:10 +0000 (23:52 +0300)
committerMartin Storsjö <martin@martin.st>
Tue, 22 Aug 2017 10:41:08 +0000 (13:41 +0300)
On windows, the offset for the relocation doesn't get stored in
the relocation itself, but as an unsigned immediate in the opcode.
Therefore, negative offsets has to be handled via a separate sub
instruction, just as on MachO.

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

index 86d36cd..7e2af4d 100644 (file)
@@ -82,6 +82,15 @@ ELF     .size   \name, . - \name
         adrp            \rd, \val+(\offset)@PAGE
         add             \rd, \rd, \val+(\offset)@PAGEOFF
     .endif
+#elif CONFIG_PIC && defined(_WIN32)
+    .if \offset < 0
+        adrp            \rd, \val
+        add             \rd, \rd, :lo12:\val
+        sub             \rd, \rd, -(\offset)
+    .else
+        adrp            \rd, \val+(\offset)
+        add             \rd, \rd, :lo12:\val+(\offset)
+    .endif
 #elif CONFIG_PIC
         adrp            \rd, \val+(\offset)
         add             \rd, \rd, :lo12:\val+(\offset)