summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Sindholt <opensource@zhasha.com>2015-08-27 16:10:43 +0200
committerJoakim Sindholt <opensource@zhasha.com>2015-08-27 16:10:43 +0200
commit8effa5a8c84d7d3646de046c914ccac44f840471 (patch)
tree3dc15e903c77ee05d046269fc5cc7fbd3ce1bb04
parent04fc581904b32498b3c490330de4587448a7138f (diff)
add assembly macros to avoid boilerplate
-rw-r--r--bin/p9a.sh2
-rw-r--r--src/assembly.h59
2 files changed, 60 insertions, 1 deletions
diff --git a/bin/p9a.sh b/bin/p9a.sh
index 304a62b..68e3d16 100644
--- a/bin/p9a.sh
+++ b/bin/p9a.sh
@@ -87,6 +87,6 @@ do
fi
clang -integrated-as --target="${CLANGARCH}" -g ${RNOPTS[@]} ${OPTS[@]} \
- -x assembler-with-cpp -include "${DIR}/../src/visibility.h" "${f}"
+ -x assembler-with-cpp -include "${DIR}/../src/assembly.h" "${f}"
if [ $? -ne 0 ]; then exit 1; fi
done
diff --git a/src/assembly.h b/src/assembly.h
new file mode 100644
index 0000000..425ab97
--- /dev/null
+++ b/src/assembly.h
@@ -0,0 +1,59 @@
+.macro TEXT n global=yes
+ .text
+ .section .text.\n,"ax",%progbits
+ .hidden \n
+ .ifnc local,\global
+ .globl \n
+ .endif
+ .type \n,%function
+ \n:
+.endm
+
+.macro DATA n global=yes
+ .data
+ .section .data.\n,"aw",%progbits
+ .hidden \n
+ .ifnc local,\global
+ .globl \n
+ .endif
+ .type \n,%object
+ \n:
+.endm
+
+.macro RODATA n global=yes
+ .rodata
+ .section .rodata.\n,"a",%progbits
+ .hidden \n
+ .ifnc local,\global
+ .globl \n
+ .endif
+ .type \n,%object
+ \n:
+.endm
+
+.macro BSS n sz global=yes
+ .hidden \n
+ .ifnc local,\global
+ .comm \n,\sz
+ .else
+ .lcomm \n,\sz
+ .endif
+.endm
+
+.macro TSYM n global=yes
+ .hidden \n
+ .ifnc local,\global
+ .globl \n
+ .endif
+ .type \n,%function
+ \n:
+.endm
+
+.macro DSYM n global=yes
+ .hidden \n
+ .ifnc local,\global
+ .globl \n
+ .endif
+ .type \n,%object
+ \n:
+.endm