Mono 'asmonly' option
I created a simple mono executable using MonoDevelop that prints "hello world". I wanted to try the AOT 'asmonly' option. So:
[root@localhost Debug]# ls
abc.exe
[root@localhost Debug]# mono --aot=full,static,asmonly abc.exe
Mono Ahead of Time compiler - compiling assembly /home/alon/Projects/abc/abc/bin/Debug/abc.exe
Code: 1538 Info: 50 Ex Info: 114 Class Info: 30 PLT: 5 GOT Info: 105 GOT Info Offsets: 24 GOT: 60
Output file: '/home/alon/Projects/abc/abc/bin/Debug/abc.exe.s'.
Linking symbol: 'mono_aot_module_abc_info'.
Compiled 9 out of 9 methods (100%)
Methods without GOT slots: 1 (11%)
Direct calls: 0 (100%)
JIT time: 1 ms, Generation time: 0 ms, Assembly+Link time: 0 ms.
GOT slot distribution:
class: 1
image: 1
ldstr: 1
interruption_request_flag: 7
[root@localhost Debug]# ls
abc.exe abc.exe.s
[root@localhost Debug]# as -o hello_world.o abc.exe.s
[root@localhost Debug]# ls
abc.exe abc.exe.s hello_world.o
[root@localhost Debug]# ld -o hello_world.so hello_world.o
ld: warning: cannot find entry symbol _start; defaulting to 0000000008049000
[root@localhost Debug]# ls
abc.exe abc.exe.s hello_world.o hello_world.so
[root@localhost Debug]# ./hello_world.so
Segmentation fault (core dumped)
[root@localhost Debug]#
Why am I getting Segmentation fault? 开发者_如何学编程I'm using Fedora 12 x64. And what is the "cannot find entry symbol _start" error in ld?
Thank You!
AOT still requires the Mono runtime, for the GC, IO-layer, reflection, threading, runtime code generation, etc. It simply precompiles that code that the JIT would compile and puts it in a shareable library. The "real" entry point that start up the Mono runtime is still in Mono.
_start
is the entry point for your binary. It's the function the OS calls to get your binary up and running. Do you have a Main function defined?
Does it work when you're not using AOT? (I.e. running mono hello_world.exe
.)
精彩评论