configure.ac: Quote `$ac_cv_search_clock_gettime' properly.
[catacomb] / base / asm-common.h
index aa6b4c3..bcfa735 100644 (file)
@@ -162,6 +162,11 @@ _where_am_i.\got :
 
 #if CPUFAM_ARM
 
+// ARM/Thumb mode things.  Use ARM by default.
+#define ARM .arm; .L$_pcoff = 8
+#define THUMB .thumb; .L$_pcoff = 4
+       ARM
+
 // Set the function hooks.
 #define FUNC_PREHOOK(_) .balign 4
 #define ENDFUNC_HOOK(name) .ltorg
@@ -184,16 +189,48 @@ _where_am_i.\got :
 // Maybe load GOT address into GOT.
        .macro  ldgot   cond=, got=GOTREG
 #if WANT_PIC
-       ldr\cond \got, =_GLOBAL_OFFSET_TABLE_ - . - 12
+       ldr\cond \got, .L$_ldgot$\@
+.L$_ldgot_pc$\@:
        add\cond \got, pc, \got
+       _LIT
+       .balign 4
+.L$_ldgot$\@:
+       .word   _GLOBAL_OFFSET_TABLE_ - .L$_ldgot_pc$\@ - .L$_pcoff
+       _ENDLIT
 #endif
        .endm
 
 // Load address of external symbol ADDR into REG, maybe using GOT.
        .macro  leaext  reg, addr, cond=, got=GOTREG
 #if WANT_PIC
-       ldr\cond \reg, =\addr(GOT)
+       ldr\cond \reg, .L$_leaext$\@
        ldr\cond \reg, [\got, \reg]
+       _LIT
+       .balign 4
+.L$_leaext$\@:
+       .word   \addr(GOT)
+       _ENDLIT
+#else
+       ldr\cond \reg, =\addr
+#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$\@:
+       .if     .L$_pcoff == 8
+       ldr\cond \reg, [pc, \reg]
+       .else
+       add\cond \reg, pc
+       ldr\cond \reg, [\reg]
+       .endif
+       _LIT
+       .balign 4
+.L$_leaextq$\@:
+       .word   \addr(GOT_PREL) + (. - .L$_leaextq_pc$\@ - .L$_pcoff)
+       _ENDLIT
 #else
        ldr\cond \reg, =\addr
 #endif