Skip to content

Instantly share code, notes, and snippets.

@NattyNarwhal
Created June 28, 2018 20:33
Show Gist options
  • Save NattyNarwhal/654903bc94af9541ba8661b64f643a4d to your computer and use it in GitHub Desktop.
Save NattyNarwhal/654903bc94af9541ba8661b64f643a4d to your computer and use it in GitHub Desktop.
Initial work for Mono AOT on AIX
diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c
index c5648e9..bab5949 100644
--- a/mono/mini/aot-compiler.c
+++ b/mono/mini/aot-compiler.c
@@ -948,6 +948,11 @@ emit_code_bytes (MonoAotCompile *acfg, const guint8* buf, int size)
#define EMIT_WIN32_CODEVIEW_INFO
#endif
+#ifdef _AIX
+#undef EMIT_DWARF_INFO
+/* TODO: XCOFF debug info */
+#endif
+
#ifdef EMIT_WIN32_UNWIND_INFO
static UnwindInfoSectionCacheItem *
get_cached_unwind_info_section_item_win32 (MonoAotCompile *acfg, const char *function_start, const char *function_end, GSList *unwind_ops);
@@ -11192,6 +11197,9 @@ compile_asm (MonoAotCompile *acfg)
#define AS_NAME "clang"
#elif defined(TARGET_WIN32_MSVC)
#define AS_NAME "clang.exe"
+#elif defined(_AIX)
+/* Don't use IBM as for now */
+#define AS_NAME "gas"
#else
#define AS_NAME "as"
#endif
@@ -11205,6 +11213,9 @@ compile_asm (MonoAotCompile *acfg)
#if defined(sparc)
#define LD_NAME "ld"
#define LD_OPTIONS "-shared -G"
+#elif defined(_AIX)
+#define LD_NAME "gcc"
+#define LD_OPTIONS "-maix64 -shared"
#elif defined(__ppc__) && defined(TARGET_MACH)
#define LD_NAME "gcc"
#define LD_OPTIONS "-dynamiclib"
diff --git a/mono/mini/helpers.c b/mono/mini/helpers.c
index 1e37c6a..a1438e4 100644
--- a/mono/mini/helpers.c
+++ b/mono/mini/helpers.c
@@ -254,9 +254,9 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
#elif defined(__mips__) && (_MIPS_SIM == _ABIO32)
#define AS_CMD "as -mips32"
#elif defined(__ppc64__)
-#define AS_CMD "as -arch ppc64"
+#define AS_CMD "gas -arch ppc64"
#elif defined(__powerpc64__)
-#define AS_CMD "as -mppc64"
+#define AS_CMD "gas -mppc64"
#else
#define AS_CMD "as"
#endif
aix$ MONO_PATH=mcs/class/lib/build runtime/mono-wrapper --aot /home/calvin/process-text.exe
Mono Ahead of Time compiler - compiling assembly /home/calvin/process-text.exe
AOTID 9C820D85-17FE-1802-D09C-5F3412E60F00
Code: 144(22%) Info: 5(0%) Ex Info: 16(2%) Unwind Info: 30(4%) Class Info: 30(4%) PLT: 2(0%) GOT Info: 291(45%) Offsets: 120(18%) GOT: 224
Compiled: 2/2 (100%), No GOT slots: 1 (50%), Direct calls: 0 (100%)
Executing the native assembler: "gas" -a64 -mppc64 -o /tmp/mono_aot_R7P7aa.o /tmp/mono_aot_R7P7aa
/tmp/mono_aot_R7P7aa: Assembler messages:
/tmp/mono_aot_R7P7aa:1: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:6: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:11: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:14: Error: unknown pseudo-op: `.local'
/tmp/mono_aot_R7P7aa:15: Warning: .type pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:15: Error: junk at end of line, first unrecognized character is `p'
/tmp/mono_aot_R7P7aa:20: Error: syntax error; found `@', expected `,'
/tmp/mono_aot_R7P7aa:20: Error: junk at end of line: `@h'
/tmp/mono_aot_R7P7aa:21: Error: syntax error; found `@', expected `,'
/tmp/mono_aot_R7P7aa:21: Error: junk at end of line: `@l'
/tmp/mono_aot_R7P7aa:27: Warning: .size pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:27: Error: junk at end of line, first unrecognized character is `p'
/tmp/mono_aot_R7P7aa:29: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:32: Error: unknown pseudo-op: `.local'
/tmp/mono_aot_R7P7aa:33: Warning: .type pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:33: Error: junk at end of line, first unrecognized character is `p'
/tmp/mono_aot_R7P7aa:38: Error: syntax error; found `@', expected `,'
/tmp/mono_aot_R7P7aa:38: Error: junk at end of line: `@h'
/tmp/mono_aot_R7P7aa:39: Error: syntax error; found `@', expected `,'
/tmp/mono_aot_R7P7aa:39: Error: junk at end of line: `@l'
/tmp/mono_aot_R7P7aa:48: Warning: .size pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:48: Error: junk at end of line, first unrecognized character is `p'
/tmp/mono_aot_R7P7aa:50: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:55: Error: junk at end of line, first unrecognized character is `1'
/tmp/mono_aot_R7P7aa:58: Error: unknown pseudo-op: `.local'
/tmp/mono_aot_R7P7aa:59: Warning: .type pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:59: Error: junk at end of line, first unrecognized character is `m'
/tmp/mono_aot_R7P7aa:65: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:71: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:76: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:81: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:90: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:95: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:101: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:107: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:112: Error: junk at end of line, first unrecognized character is `1'
/tmp/mono_aot_R7P7aa:117: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:123: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:127: Error: unknown pseudo-op: `.local'
/tmp/mono_aot_R7P7aa:128: Warning: .type pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:128: Error: junk at end of line, first unrecognized character is `p'
/tmp/mono_aot_R7P7aa:131: Error: syntax error; found `@', expected `,'
/tmp/mono_aot_R7P7aa:131: Error: junk at end of line: `@h'
/tmp/mono_aot_R7P7aa:132: Error: syntax error; found `@', expected `,'
/tmp/mono_aot_R7P7aa:132: Error: junk at end of line: `@l'
/tmp/mono_aot_R7P7aa:141: Warning: .size pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:141: Error: junk at end of line, first unrecognized character is `p'
/tmp/mono_aot_R7P7aa:142: Warning: .size pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:142: Error: junk at end of line, first unrecognized character is `m'
/tmp/mono_aot_R7P7aa:144: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:156: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:161: Error: the XCOFF file format does not support arbitrary sections
/tmp/mono_aot_R7P7aa:162: Error: unknown pseudo-op: `.subsection'
/tmp/mono_aot_R7P7aa:164: Error: unknown pseudo-op: `.local'
/tmp/mono_aot_R7P7aa:165: Warning: .type pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:165: Error: junk at end of line, first unrecognized character is `m'
/tmp/mono_aot_R7P7aa:169: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:184: Error: junk at end of line, first unrecognized character is `1'
/tmp/mono_aot_R7P7aa:187: Error: junk at end of line, first unrecognized character is `1'
/tmp/mono_aot_R7P7aa:190: Error: junk at end of line, first unrecognized character is `1'
/tmp/mono_aot_R7P7aa:193: Error: junk at end of line, first unrecognized character is `0'
/tmp/mono_aot_R7P7aa:197: Warning: .type pseudo-op used outside of .def/.endef ignored.
/tmp/mono_aot_R7P7aa:197: Error: junk at end of line, first unrecognized character is `m'
/tmp/mono_aot_R7P7aa:276: Error: junk at end of line, first unrecognized character is `1'
/tmp/mono_aot_R7P7aa:21: Error: operand out of range (0xffffffffffffffc8 is not between 0x0000000000000000 and 0x000000000000ffff)
/tmp/mono_aot_R7P7aa:39: Error: operand out of range (0xffffffffffffff88 is not between 0x0000000000000000 and 0x000000000000ffff)
AOT of image /home/calvin/process-text.exe failed.
.text 0
.balign 8
.Lgot_addr:
.balign 8
.quad mono_aot_process_test_got
.text 0
.balign 8
jit_code_start:
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.text 0
.balign 16
.Lm_0:
.local proctest__ctor
.type proctest__ctor,@function
proctest__ctor:
.byte 124,8,2,166,248,1,0,16,248,33,255,113,251,193,0,136,248,97,0,112,72,0,0,5,127,200,2,166
.L0:
lis 0, (.Lgot_addr + 4 - .L0)@h
ori 0, 0, (.Lgot_addr + 4 - .L0)@l
add 30, 30, 0
ld 30, 0(30)
.byte 232,1,0,160,124,8,3,166,235,193,0,136,56,33,0,144,78,128,0,32
.size proctest__ctor,.-proctest__ctor
.Lme_0:
.text 0
.balign 16
.Lm_1:
.local proctest_Main_string__
.type proctest_Main_string__,@function
proctest_Main_string__:
.byte 124,8,2,166,248,1,0,16,248,33,255,49,251,193,0,200,248,97,0,176,72,0,0,5,127,200,2,166
.L1:
lis 0, (.Lgot_addr + 4 - .L1)@h
ori 0, 0, (.Lgot_addr + 4 - .L1)@l
add 30, 30, 0
ld 30, 0(30)
.byte 60,0,0,0,96,0,0,200,124,126,0,42
bl .Lp_1
.byte 232,1,0,224,124,8,3,166,235,193,0,200,56,33,0,208,78,128,0,32
.size proctest_Main_string__,.-proctest_Main_string__
.Lme_1:
.text 0
.balign 8
jit_code_end:
.byte 0,0,0,0
.text 1
.balign 8
method_addresses:
.local method_addresses
.type method_addresses,@function
bl .Lm_0
bl .Lm_1
bl method_addresses
method_addresses_end:
.text 0
.balign 8
unbox_trampolines:
unbox_trampolines_end:
.long 0
.text 0
.balign 8
unbox_trampoline_addresses:
.long 0
.text 0
.balign 8
method_info_offsets:
.byte 3,0,0,0,10,0,0,0,1,0,0,0,2,0,0,0,0,0,1,2,255,255,255,255,253
.text 0
.balign 8
extra_method_table:
.byte 11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0
.text 0
.balign 8
extra_method_info_offsets:
.byte 0,0,0,0
.text 0
.balign 8
class_name_table:
.byte 11,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0
.text 0
.balign 8
got_info_offsets:
.byte 26,0,0,0,10,0,0,0,3,0,0,0,2,0,0,0,0,0,10,0,20,0,6,2,1,1,1,1,1,2,2,2
.byte 21,2,2,2,2,2,2,1,27,28,125,38,38,35,24,29
.text 0
.balign 8
ex_info_offsets:
.byte 3,0,0,0,10,0,0,0,1,0,0,0,2,0,0,0,0,0,129,41,7,255,255,255,254,208
.text 1
.balign 8
unwind_info:
.byte 14,12,1,0,72,17,108,126,68,14,144,1,68,158,1,14,12,1,0,72,17,108,126,68,14,208,1,68,158,1
.text 0
.balign 8
class_info_offsets:
.byte 2,0,0,0,10,0,0,0,1,0,0,0,2,0,0,0,0,0,129,57,7
.text 0
.balign 16
plt:
mono_aot_process_test_plt:
.local plt_System_Diagnostics_Process_Start_string
.type plt_System_Diagnostics_Process_Start_string,@function
plt_System_Diagnostics_Process_Start_string:
.Lp_1:
lis 11, 216@h
ori 11, 11, 216@l
add 11, 11, 30
ld 11, 0(11)
ld 2, 8(11)
ld 11, 0(11)
mtctr 11
bctr
.long 292
.size plt_System_Diagnostics_Process_Start_string,.-plt_System_Diagnostics_Process_Start_string
.size mono_aot_process_test_plt,.-mono_aot_process_test_plt
plt_end:
.text 0
.balign 8
image_table:
.byte 3,0,0,0,112,114,111,99,101,115,115,45,116,101,115,116,0,48,70,49,70,52,50,70,50,45,49,66,50,66,45,52
.byte 54,48,49,45,57,48,65,54,45,65,54,57,55,66,53,70,51,70,56,52,49,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,83,121,115,116,101,109,0,56,56,51,56,51,69,69,55,45,67,66,54,54
.byte 45,52,57,54,54,45,66,67,70,70,45,66,65,70,69,52,57,53,55,51,66,48,68,0,0,98,55,55,97,53,99,53
.byte 54,49,57,51,52,101,48,56,57,0,0,0,0,0,0,0,1,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,109,115,99,111,114,108,105,98,0,65,65,54,66,50,70,49,51,45,53,69,67,68,45,52,65,55,68,45
.byte 65,56,66,67,45,52,70,52,56,69,66,54,69,53,52,68,57,0,0,98,55,55,97,53,99,53,54,49,57,51,52,101
.byte 48,56,57,0,0,0,0,0,1,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.text 0
.balign 8
weak_field_indexes:
.byte 0,0,0,0
.section ".bss"
.subsection 0
.balign 8
.local mono_aot_process_test_got
.type mono_aot_process_test_got,@object
mono_aot_process_test_got:
.skip 224
got_end:
.text 0
.balign 8
blob:
.byte 0,0,0,0,1,25,12,0,36,38,46,50,52,55,0,57,0,55,1,57,1,55,2,57,2,55,3,57,3,55,4,57
.byte 4,56,58,24,109,111,110,111,95,116,104,114,101,97,100,115,95,97,116,116,97,99,104,95,99,111,111,112,0,7,25,109
.byte 111,110,111,95,97,111,116,95,105,110,105,116,95,108,108,118,109,95,109,101,116,104,111,100,0,7,33,109,111,110,111,95
.byte 97,111,116,95,105,110,105,116,95,103,115,104,97,114,101,100,95,109,101,116,104,111,100,95,116,104,105,115,0,7,35,109
.byte 111,110,111,95,97,111,116,95,105,110,105,116,95,103,115,104,97,114,101,100,95,109,101,116,104,111,100,95,109,114,103,99
.byte 116,120,0,7,35,109,111,110,111,95,97,111,116,95,105,110,105,116,95,103,115,104,97,114,101,100,95,109,101,116,104,111
.byte 100,95,118,116,97,98,108,101,0,7,32,109,111,110,111,95,108,108,118,109,95,116,104,114,111,119,95,99,111,114,108,105
.byte 98,95,101,120,99,101,112,116,105,111,110,0,7,21,109,111,110,111,95,105,110,105,116,95,118,116,97,98,108,101,95,115
.byte 108,111,116,0,7,26,109,111,110,111,95,104,101,108,112,101,114,95,108,100,115,116,114,95,109,115,99,111,114,108,105,98
.byte 0,16,0,1,3,193,0,38,214,10,0,0,2,12,88,0,10,15,0,4,0,88,22,32,0,0,128,144,16,0,0,1
.byte 4,128,144,16,0,0,1,194,0,100,128,194,0,100,125,194,0,100,124,194,0,100,122,115,103,101,110,0
.text 1
runtime_version:
.asciz ""
.text 1
assembly_guid:
.asciz "0F1F42F2-1B2B-4601-90A6-A697B5F3F841"
.text 1
assembly_name:
.asciz "process-test"
.data 0
.balign 8
mono_aot_file_info:
.globl mono_aot_file_info
.type mono_aot_file_info,@object
.long 145,0
.balign 8
.quad mono_aot_process_test_got
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad jit_code_start
.balign 8
.quad jit_code_end
.balign 8
.quad method_addresses
.balign 8
.quad blob
.balign 8
.quad class_name_table
.balign 8
.quad class_info_offsets
.balign 8
.quad method_info_offsets
.balign 8
.quad ex_info_offsets
.balign 8
.quad extra_method_info_offsets
.balign 8
.quad extra_method_table
.balign 8
.quad got_info_offsets
.balign 8
.quad 0
.balign 8
.quad image_table
.balign 8
.quad weak_field_indexes
.balign 8
.quad mem_end
.balign 8
.quad assembly_guid
.balign 8
.quad runtime_version
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad 0
.balign 8
.quad assembly_name
.balign 8
.quad plt
.balign 8
.quad plt_end
.balign 8
.quad unwind_info
.balign 8
.quad unbox_trampolines
.balign 8
.quad unbox_trampolines_end
.balign 8
.quad unbox_trampoline_addresses
.long 26,224,2,3,0,374417919,0,343
.long 128,4,8,8,0,25,0,0
.long 0,0,0,0,0,0,0,0
.long 0,0,0,0,0,0,0,0
.long 0,0,0,0,0,0,0,0
.long 0,0
.byte 133,13,130,156,254,23,2,24,208,156,95,52,18,230,15,0
.text 1
.balign 8
mem_end:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment