可以将C/C ++软件编译成字节码以便以后执行吗? (独立于体系结构的UNIX软件.) [英] Can C/C++ software be compiled into bytecode for later execution? (Architecture independent unix software.)
问题描述
我想将现有软件编译成演示文稿,然后再在不同的体系结构(和OS)上运行.
I would want to compile existing software into presentation that can later be run on different architectures (and OS).
为此,我需要一个可以在另一个arch/OS上轻松运行/模拟的(字节)代码( LLVM IR?有一些RISC装配?)
For that I need a (byte)code that can be easily run/emulated on another arch/OS (LLVM IR? Some RISC assemby?)
一些随机的想法:
- 编译为JVM字节码并与Java一起运行.太严格了吗?有C编译器吗?
- MS CIL.可以使用C编译器吗?
- LLVM?可以稍后再进行中间代理吗?
- 编译为RISC拱门,例如MMIX.那系统调用呢?
然后有系统调用映射的东西,例如BSD具有系统调用转换层.
Then there is the system call mapping thing, but e.g. BSD have system call translation layers.
是否已经有可以将C/C ++编译为某些内容的系统,以后可以在另一个体系结构上使用解释器运行该系统?
Are there any already working systems that compile C/C++ into something that can later be run with an interpreter on another architecture?
我可以将现有的unix软件编译为不太低级的二进制文件,比运行完整的x86模拟器更容易模拟"二进制文件吗?比XEN HVM更像JVM.
Could I compile existing unix software into not-so-lowlevel binary, which could be "emulated" more easily than running full x86 emulator? Something more like JVM than XEN HVM.
推荐答案
There are several C to JVM compilers listed on Wikipedia's JVM page. I've never tried any of them, but they sound like an interesting exercise to build.
由于JVM与Java语言密切相关,因此它执行Java规范要求的严格运行时检查.这就要求C给字节码编译器提供它们自己的松散机器抽象",例如产生使用Java数组表示主内存的编译代码(这样指针就可以编译为整数),并将C库链接到集中式Java类.模拟系统调用.下面列出的大多数或所有编译器都使用类似的方法.
Because of its close association with the Java language, the JVM performs the strict runtime checks mandated by the Java specification. That requires C to bytecode compilers to provide their own "lax machine abstraction", for instance producing compiled code that uses a Java array to represent main memory (so pointers can be compiled to integers), and linking the C library to a centralized Java class that emulates system calls. Most or all of the compilers listed below use a similar approach.
这篇关于可以将C/C ++软件编译成字节码以便以后执行吗? (独立于体系结构的UNIX软件.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!