我试图在x86_64 ubuntu 12.04机器上编译32位目标的应用程序.我使用安装了所需的包
sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386
Run Code Online (Sandbox Code Playgroud)
第一个命令用于生成32位版本.但是,第二个命令出错了
1. g++ -m32 hello.c
2. gcc -m32 hello.c
skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
Run Code Online (Sandbox Code Playgroud)
任何人都可以向我解释为什么gcc无法工作.我错过了一些图书馆吗?
谢谢!
我是 LLVM 的新手,我正在学习如何使用 LLVM 进行分析。我需要将数组传递给外部方法,并在代码中插入对该方法的调用指令。我目前正在使用以下代码,该代码在执行时会出现分段错误。
std::vector<Value*> Args(1);
//Vector with array values
SmallVector<Constant*, 2> counts;
counts.push_back(ConstantInt::get(Type::getInt32Ty(BB->getContext()),32, false));
counts.push_back(ConstantInt::get(Type::getInt32Ty(BB->getContext()),12, false));
//Array with 2 integers
Args[0]= ConstantArray::get(llvm::ArrayType::get(llvm::Type::getInt32Ty(BI->getContext()),2), counts);
Run Code Online (Sandbox Code Playgroud)
这里,外部函数 'hook' 定义为 M.getOrInsertFunction("hook", Type::getVoidTy(M.getContext()),
llvm::ArrayType::get(llvm::Type::getInt32Ty(BI->getContext()),2)
(Type*)0);
阅读了几个源文件后,我尝试使用 GetElementPtrInst 来传递数组
std::vector<Value*> ids(1);
ids.push_back(ConstantInt::get(Type::getInt32Ty(BB->getContext()),0));
Constant* array = ConstantArray::get(llvm::ArrayType::get(llvm::Type::getInt32Ty(BI->getContext()),2), counts);
Args[0] = ConstantExpr::getGetElementPtr(&(*array), ids, false);
Run Code Online (Sandbox Code Playgroud)
但它失败了
7 opt 0x00000000006c59f5 bool llvm::isa<llvm::Constant, llvm::Value*>(llvm::Value* const&) + 24
8 opt 0x00000000006c5a0f llvm::cast_retty<llvm::Constant, llvm::Value*>::ret_type llvm::cast<llvm::Constant, llvm::Value*>(llvm::Value* const&) + 24
9 opt 0x0000000000b2b22f
10 opt 0x0000000000b2a4fe llvm::ConstantFoldGetElementPtr(llvm::Constant*, bool, llvm::ArrayRef<llvm::Value*>) + 55
11 …Run Code Online (Sandbox Code Playgroud)