shithub: dav1d

Download patch

ref: 0bb538983122e908353d1487407749bce18ee6a6
parent: 859ae6aade4832761073231d50052c6c8fc0656f
author: Martin Storsjö <[email protected]>
date: Sun Oct 21 18:15:48 EDT 2018

arm64: mc: Make the jump tables local symbols

For MachO, this makes sure that the label difference actually is
evaluated at assembly time (as it already was for ELF and COFF);
evaluating it at link time failed when the difference is stored in
a .hword.

This fixes linking errors like these:
ld: in section __TEXT,__text reloc 0: ARM64_RELOC_SUBTRACTOR must have r_length of 2 or 3 file 'src/src@@dav1d_bitdepth_8@sta/arm_64_mc.S.o' for architecture arm64

This adds an asm.S macro for decorating a symbol for making a
local symbol. For armasm64 with gas-preprocessor, this doesn't
actually create a local label (but neither do the local numbered
labels either currently), which might be slightly inconsistent
in it would be necessary to make the distinction for that assembler
as well.

Alternatively, the table symbol could be made into a plain local
numbered label as all the other labels.

--- a/src/arm/64/mc.S
+++ b/src/arm/64/mc.S
@@ -107,7 +107,7 @@
         movi            v31.16b, #256-2
 .endif
         rbit            w4,  w4
-        adr             x7,  \type\()_tbl
+        adr             x7,  L(\type\()_tbl)
         clz             w4,  w4
         \type           v4,  v0,  v1
         ldrh            w4,  [x7, x4, lsl #1]
@@ -219,14 +219,14 @@
         b               128b
 0:
         ret
-\type\()_tbl:
+L(\type\()_tbl):
         .hword 0, 0
-        .hword \type\()_tbl -    4b
-        .hword \type\()_tbl -    8b
-        .hword \type\()_tbl -  160b
-        .hword \type\()_tbl -  320b
-        .hword \type\()_tbl -  640b
-        .hword \type\()_tbl - 1280b
+        .hword L(\type\()_tbl) -    4b
+        .hword L(\type\()_tbl) -    8b
+        .hword L(\type\()_tbl) -  160b
+        .hword L(\type\()_tbl) -  320b
+        .hword L(\type\()_tbl) -  640b
+        .hword L(\type\()_tbl) - 1280b
 endfunc
 .endm
 
--- a/src/arm/asm.S
+++ b/src/arm/asm.S
@@ -91,4 +91,10 @@
 \name:
 .endm
 
+#ifdef __APPLE__
+#define L(x) L ## x
+#else
+#define L(x) .L ## x
+#endif
+
 #endif /* __DAV1D_SRC_ARM_ASM_S__ */