rmmh / beefit

An optimizing BF compiler.
5 stars 2 forks source link

Linux x64 compilers now turn on PIC always #4

Open rdebath opened 4 years ago

rdebath commented 4 years ago

This means that the C library will be mapped above the 2GB line and you must use a 64bit mov to load the addresses of putchar and getchar.

diff --git a/emit_x64.dasc b/emit_x64.dasc
index d4f78ef..715232e 100644
--- a/emit_x64.dasc
+++ b/emit_x64.dasc
@@ -8,7 +8,11 @@
 |.define TMP, al
 |
 |.macro callp, addr
+#if (defined(__code_model_small__) && !defined(__PIC__)) || defined(__ILP32__)
 |  mov  rax, (uintptr_t)addr
+#else
+|  mov64 rax, (uintptr_t)addr
+#endif
 |  call rax
 |.endmacro
 |