I am currently using llc to convert a .ll
file to a .s
using the commandline. Then I want to take this file and then use nasm to create an executable from it. While the first step seems to work fine, I can't get the second step to work.
the original file is called code.ll
and contains the following code:
define i32 @main() {
ret i32 0
}
now I use the cmd to build the .s
file by typing:
llc code.ll
this works fine and creates a code.s
file containing the following code:
.def @feat.00;
.scl 3;
.type 0;
.endef
.globl @feat.00
@feat.00 = 1
.def _main;
.scl 2;
.type 32;
.endef
.text
.globl _main
.align 16, 0x90
_main: # @main
# BB#0:
xorl %eax, %eax
ret
Now I want to create an executable using this code, about which the llc doc tells me this:
The assembly language output can then be passed through a native assembler and linker to generate a native executable.
So I use nasm (which should do what I want as far as I understand) by typing:
nasm code.s
which produces the following list of errors:
code.s:1: error: attempt to define a local label before any non-local labels
code.s:1: error: parser: instruction expected
code.s:2: error: attempt to define a local label before any non-local labels
code.s:2: error: parser: instruction expected
code.s:3: error: attempt to define a local label before any non-local labels
code.s:3: error: parser: instruction expected
code.s:4: error: attempt to define a local label before any non-local labels
code.s:5: error: attempt to define a local label before any non-local labels
code.s:5: error: parser: instruction expected
code.s:6: error: parser: instruction expected
code.s:7: error: parser: instruction expected
code.s:8: error: parser: instruction expected
code.s:9: error: parser: instruction expected
code.s:12: error: parser: instruction expected
code.s:13: error: parser: instruction expected
code.s:14: error: parser: instruction expected
BB#0::1: error: parser: instruction expected
BB#0::2: error: parser: instruction expected
BB#0::3: error: parser: instruction expected
BB#0::4: error: parser: instruction expected
BB#0::5: error: parser: instruction expected
BB#0::8: error: parser: instruction expected
BB#0::9: error: parser: instruction expected
BB#0::10: error: parser: instruction expected
As my experience concerning LLVM or assembler is close to zero I were unable to solve this myself.
In case I have left out something important just tell me and I will edit my answer as fast as possible.