是否可以从Assembly文件中获取LLVM-IR? [英] Is it possible to get LLVM-IR from Assembly file?
问题描述
我使用命令编译了.S文件:
I compiled .S file using command:
clang-8 -c funcs.s -o funcs.o -emit-llvm
我发现,.o文件是以ELF格式生成的. 预计我会看到llvm-ir格式(结果文件开头带有"BC"字符).
I found, that .o file was generated in ELF format. I was expected to see llvm-ir format (with "BC" characters at the beginning of resulting file).
似乎,Clang忽略了"-emit-llvm"标志.
Seems, Clang ignores "-emit-llvm" flag.
推荐答案
Your question isn't fundamentally different from Is it possible to translate an assembly language to LLVM IR, optimize it and then recompile it to a different architecture?.
asm源文件和二进制可执行文件/目标文件基本上等效于此问题.您仍在尝试将其反编译为LLVM-IR.这很难,而且我不知道是否存在反编译器.
asm source and binary executables / object files are basically equivalent for this problem. You're still trying to decompile to LLVM-IR. This is hard, and I don't know if a decompiler exists.
似乎,Clang忽略了"-emit-llvm"标志.
Seems, Clang ignores "-emit-llvm" flag.
不,它只是不影响您要求它执行的操作中涉及的任何步骤.
No, it just didn't affect any of the steps involved in the operation you asked it to do.
您要求编译器将其编译为.o
,所以就这样做了.
You asked your compiler to compile to a .o
, so it did so.
如果输入是.c
,而输出是.s
,则它可以发出LLVM-IR,但是在这种情况下,LLVM-IR并不是组装.s
的过程的一部分.到.o
.
If the input had been .c
and the output a .s
, it would have been able to emit LLVM-IR, but in this case LLVM-IR wasn't part of the process of assembling a .s
to a .o
.
因此,当clang
运行时,不存在该程序的LLVM-IR表示,因此没有任何内容可发送.
So no LLVM-IR representation of the program ever existed while clang
was running, so there was nothing to emit.
这篇关于是否可以从Assembly文件中获取LLVM-IR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!