Skip to content

Commit

Permalink
Switch to LLVM11
Browse files Browse the repository at this point in the history
Mostly working, but have some issues with LLVM instruction processing in taint2 plugin.
  • Loading branch information
LauraLMann authored and Andrew Fasano committed Mar 5, 2021
1 parent 126008c commit f2b3158
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ msg() {

# Default targets to build. Change with argument. small = i386-softmmu
TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,aarch64-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu"
LLVM_CONFIG_BINARY="llvm-config-10"
LLVM_CONFIG_BINARY="llvm-config-11"

pypanda=""
# Check if first argument is --python
Expand Down Expand Up @@ -81,7 +81,7 @@ fi
### Set LLVM_CONFIG to be used with the configure script.
# No LLVM binary: Disable LLVM
if ! command -v $LLVM_CONFIG_BINARY &> /dev/null; then
echo "LLVM 10 not installed. LLVM SUPPORT IS DISABLED."
echo "LLVM 11 not installed. LLVM SUPPORT IS DISABLED."
LLVM_CONFIG=""
fi
# OSX: Disable LLVM
Expand All @@ -90,7 +90,7 @@ if [ $(getconf LONG_BIT) = 32 ]; then
LLVM_CONFIG=""
fi

## Use system LLVM-10
## Use system LLVM-11
if $LLVM_CONFIG_BINARY --version >/dev/null 2>/dev/null; then
msg "Found LLVM on $($LLVM_CONFIG_BINARY --prefix) -- LLVM SUPPORT IS ENABLED"
LLVM_CONFIG="--enable-llvm --with-llvm=$($LLVM_CONFIG_BINARY --prefix)"
Expand Down
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ stack_protector=""
git_submodules=""
protobuf="yes"
llvm="no"
llvmdir="/usr/lib/llvm-10" # Default to try if unspecified
llvmver="10"
llvmdir="/usr/lib/llvm-11" # Default to try if unspecified
llvmver="11"

# Don't accept a target_list environment variable.
unset target_list
Expand Down
26 changes: 19 additions & 7 deletions panda/llvm/tcg-llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ void getLLVMAssemblySize(orc::VModuleKey,
*/
for (object::symbol_iterator cur_sym = obj.symbol_begin(),
end_sym = obj.symbol_end(); cur_sym != end_sym; ++cur_sym) {
/* don't waste time with undefined symbols */
uint32_t flags = cur_sym->getFlags();
if (flags & object::SymbolRef::SF_Undefined) {
if (cur_sym->getFlags()) {
/* don't waste time with undefined symbols */
uint32_t flags = cur_sym->getFlags().get();
if (flags & object::SymbolRef::SF_Undefined) {
continue;
}
} else {
/* flags indicate an error, hopefully not important */
std::cerr << "Error getting symbol flags" << std::endl;
continue;
}

Expand Down Expand Up @@ -655,8 +661,9 @@ int TCGLLVMTranslator::generateOperation(int opc, const TCGOp *op,
}
}

result = m_builder.CreateCall(callTarget,
ArrayRef<Value*>(argValues));
result = m_builder.CreateCall(
cast<FunctionType>(callTarget->getType()->getPointerElementType()),
callTarget, ArrayRef<Value*>(argValues));

/* Invalidate in-memory values because
* function might have changed them */
Expand Down Expand Up @@ -1440,7 +1447,6 @@ void TCGLLVMTranslator::generateCode(TCGContext *s, TranslationBlock *tb)
#endif

if(execute_llvm || qemu_loglevel_mask(CPU_LOG_LLVM_ASM)) {

jitPendingModule();

auto symbol = jit->lookup(fName.str());
Expand Down Expand Up @@ -1475,7 +1481,13 @@ void TCGLLVMTranslator::generateCode(TCGContext *s, TranslationBlock *tb)
// stores it in section_size.
pending_tb = tb;
need_section_size = true;
auto dylib = jit->getJITDylibByName("<main>.impl");
auto dylib = jit->getJITDylibByName("main.impl");
if (nullptr == dylib) {
std::cerr <<
"Cannot find magic symbol table - has the name changed again?" <<
std::endl;
assert(false);
}
auto fnsym = jit->lookup(*dylib, tb->llvm_fn_name);
// assert forces the return value to be checked for an error, so don't
// fail the next step
Expand Down
5 changes: 1 addition & 4 deletions panda/plugins/taint2/llvm_taint_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,7 @@ void PandaTaintVisitor::inlineCall(CallInst *CI) {
assert(CI && "CallInst can't be null");
if (inline_taint) {
InlineFunctionInfo IFI;
// LLVM-10
if (!InlineFunction(CI, IFI)) {
// LLVM-11
//if (!InlineFunction(*CI, IFI).isSuccess()) {
if (!InlineFunction(*CI, IFI).isSuccess()) {
printf("Inlining failed!\n");
}
}
Expand Down

0 comments on commit f2b3158

Please sign in to comment.