如何在使用LLVM进行编译时获取部分源代码的二进制代码

问题描述 投票:0回答:1

例如,我有一个名为test.cpp的C ++文件:

#include <iostream>
int main(){
  int a = 0;
  int b = 1;
  char c = '3';
  cout<< a <<endl;  //  We want to get the binary code from here
  cout<< b <<endl;  //  to here
  cout<< c <<endl;
}

当我使用LLVM编译它时(我猜应该修改LLVM),如何获得上面注释中所述的二进制代码?

我是否需要插入额外的标志以将它们与其他标志区分开?

c++ llvm code-generation
1个回答
0
投票
首先添加using namespace std;,以便您的代码编译,然后再尝试g++ -S <your file here> -o result。现在打开结果文件。
© www.soinside.com 2019 - 2024. All rights reserved.