[llvm-dev] How to convert assembly code to executable

Robinson, Paul via llvm-dev llvm-dev at lists.llvm.org
Mon May 2 10:46:40 PDT 2016

Please make sure to "reply all" so the whole email conversation appears on the list.

The [additional library locations] and [additional include location] specify where your Alpha-target headers and libraries are. I can't help you find those places; they don't come with clang/LLVM.  If you don't specify them, you should also leave out the preceding –L and –I options.  In fact you shouldn't need –I at all if you are compiling assembler source.
You can look at gcc documentation for help with these options if you are unfamiliar with them; they work exactly the same way in clang.
Not sure where you got "-mllvm –Wall" that looks very odd and you don't really need it.
I wouldn't bother with –g when trying to compile assembler source.
That leaves us with:

clang matrix.s –L. –Wl,pie –o matrix.out

Assuming you have an appropriate linker, that might be enough.  If your linker can't handle Alpha objects, you will need to find one; I can't help you there.

From: Balasaheb Dabhade [mailto:dabhadebalasaheb at gmail.com]
Sent: Monday, May 02, 2016 10:27 AM
To: Robinson, Paul
Subject: Re: [llvm-dev] How to convert assembly code to executable

Thanks Paulr,

Yes, I am using old version of LLVM(2.8) for alpha target. I wanted to do some analysis on assembly code and then generate executable from assembly code.

I was looking for exact command to generate executable for assembly code. I got following commands from stackoverflow:

clang matrix.s -L [additional library locations] -mllvm -Wall -g -L. -Wl,-pie -I. -I[additional include locations] -o [executable output]
but I am not sure what to put in place of library location, I tried following command
(matrix.s is my assembly code file) :

#clang matrix.s -L -mllvm -Wall -g -L. -Wl,-pie -I. -I -o matrix.out

getting below error :
clang: error: no such file or directory: 'matrix.out'

Could you please let me know the exact commands to generate assembly code to executable for alpha target which include linking as well?


On Mon, May 2, 2016 at 9:24 PM, Robinson, Paul <paul.robinson at sony.com<mailto:paul.robinson at sony.com>> wrote:
If you add "-filetype=obj" to your llc command, I'd expect you to get an object file instead of assembly source.
After that you would need to run it through a linker for your alpha target.

(The last LLVM release with an Alpha target was 3.0, I guess you are using a really old version of LLVM? Or maintaining it as an out-of-tree target?)

From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org<mailto:llvm-dev-bounces at lists.llvm.org>] On Behalf Of Balasaheb Dabhade via llvm-dev
Sent: Monday, May 02, 2016 7:27 AM
To: llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
Subject: [llvm-dev] How to convert assembly code to executable

Hello All,

I have converted c program into assembly code for alpha target using following commands

clang -emit-llvm matrix.c -c -o matrix.bc

llc -march=alpha matrix.bc -o matrix.s

Now how to convert matrix.s assembly file into executable file of alpha target?

Any help is appreciated

Thanks in advance !!



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160502/ae3cb077/attachment-0001.html>

More information about the llvm-dev mailing list