Note that there are some explanatory texts on larger screens.

plurals
  1. POCompile, Assemble and Disassemble Using the LLVM Tool Chain
    text
    copied!<p>I'm trying to run the following <a href="http://llvm.org/docs/GettingStarted.html#examples" rel="noreferrer">example</a> to Compile, Assemble and Disassemble an small program using the LLVM tool chain.</p> <p>My intention is to learn how it works so in further tries I could do some performance test by changing and/or reordering the assmbly's instructions.</p> <p>To start with, I first get the bite code of a dummy program:</p> <pre><code> % llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc </code></pre> <p>Once I have the bite code, i try to use the llvm-dis utility to take a look at the LLVM assembly code and llc to compile the program back to native assembly using the LLC code generator (just for the shake of trying): </p> <pre><code> % llvm-dis &lt; hello.bc | less % llc hello.bc -o hello.s </code></pre> <p>But in both cases I get the following error:</p> <pre><code> llvm-dis: Invalid MODULE_CODE_GLOBALVAR record </code></pre> <p>Any ideas on how to solve this problem?</p> <p>I've googled and I haven't found a solution. I have also tried to use </p> <pre><code> otool -tV hello </code></pre> <p>But the output is not compatible with llvm. Instead of getting the following assembly format: </p> <pre><code>.section __TEXT,__text,regular,pure_instructions .globl _main .align 4, 0x90 _main: Leh_func_begin1: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: subq $16, %rsp Ltmp2: leaq L_.str(%rip), %rax </code></pre> <p>I get: </p> <pre><code>__TEXT,__text) section start: 0000000100000eb0 pushq $0x00 0000000100000eb2 movq %rsp,%rbp 0000000100000eb5 andq $0xf0,%rsp 0000000100000eb9 movq 0x08(%rbp),%rdi 0000000100000ebd leaq 0x10(%rbp),%rsi 0000000100000ec1 movl %edi,%edx 0000000100000ec3 addl $0x01,%edx </code></pre> <p>Which is not valid for me as I cat compile the latter assembly with for example:</p> <pre><code> % gcc hello.s -o hello.native </code></pre> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload