chiark / gitweb /
base/asm-common.h: Introduce bad literal-pool handling macros.
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:24 +0000 (01:17 +0100)
Abuse subsections for arranging to place literals near the functions
which need them.  These are no use for human-written code, but they're
useful in macros, especially since GAS is actually rather bad at dealing
with complex expressions and relocation types in its ARM literal syntax.

base/asm-common.h

index 28ddd0d1893119d62aee65bca6fd1f211029a427..aa6b4c3e40696794d60b255bb1a110c4158d7b49 100644 (file)
 ///--------------------------------------------------------------------------
 /// General definitions.
 
+// Some useful variables.
+       .L$_subsec = 0
+
+// Literal pools done the hard way.
+#define _LIT .text .L$_subsec + 1
+#define _ENDLIT .text .L$_subsec
+
 // Announcing an external function.
 #define FUNC(name)                                                     \
        .globl  F(name);                                                \
@@ -40,7 +47,9 @@ F(name):                                                              \
 #define _ENDFUNC(name)                                                 \
        .purgem ENDFUNC;                                                \
        SIZE_OBJ(name);                                                 \
-       ENDFUNC_HOOK(name)
+       ENDFUNC_HOOK(name);                                             \
+       .L$_subsec = .L$_subsec + 2;                                    \
+       .text .L$_subsec
 
 ///--------------------------------------------------------------------------
 /// ELF-specific hacking.