chiark / gitweb /
base/asm-common.h: Introduce simpler PIC data reference macro.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 24 Jun 2016 00:17:43 +0000 (01:17 +0100)
Using the `GOT_PREL' relocation type means that we don't need to burn a
register for the GOT.

base/asm-common.h

index 32c054301364decce6f7bf9090bd5c9cf128c7dc..9c2dfb30a787122f209e7a4ed991559de9bab605 100644 (file)
@@ -210,6 +210,22 @@ _where_am_i.\got :
 #endif
        .endm
 
+// Load address of external symbol ADDR into REG directly.
+       .macro  leaextq reg, addr, cond=
+#if WANT_PIC
+       ldr\cond \reg, .L$_leaextq$\@
+.L$_leaextq_pc$\@:
+       ldr\cond \reg, [pc, \reg]
+       _LIT
+       .balign 4
+.L$_leaextq$\@:
+       .word   \addr(GOT_PREL) + (. - .L$_leaextq_pc$\@ - 8)
+       _ENDLIT
+#else
+       ldr\cond \reg, =\addr
+#endif
+       .endm
+
 #endif
 
 ///--------------------------------------------------------------------------