afl_cc llvm 18 build fixes (#1759)

This commit is contained in:
David CARLIER 2024-01-02 13:13:52 +00:00 committed by GitHub
parent a07563def0
commit 440e57dd6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 21 deletions

View File

@ -344,27 +344,29 @@ bool AutoTokensPass::runOnModule(Module &M) {
isStrcmp &= isStrcmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) && FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext()); FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
isStrcasecmp &= isStrcasecmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) && FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext()); FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
isMemcmp &= FT->getNumParams() == 3 && isMemcmp &= FT->getNumParams() == 3 &&
FT->getReturnType()->isIntegerTy(32) && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0)->isPointerTy() && FT->getParamType(0)->isPointerTy() &&
FT->getParamType(1)->isPointerTy() && FT->getParamType(1)->isPointerTy() &&
FT->getParamType(2)->isIntegerTy(); FT->getParamType(2)->isIntegerTy();
isStrncmp &= FT->getNumParams() == 3 && isStrncmp &=
FT->getReturnType()->isIntegerTy(32) && FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) == FT->getParamType(0) ==
IntegerType::getInt8PtrTy(M.getContext()) && IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
FT->getParamType(2)->isIntegerTy(); FT->getParamType(2)->isIntegerTy();
isStrncasecmp &= FT->getNumParams() == 3 && isStrncasecmp &=
FT->getReturnType()->isIntegerTy(32) && FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) == FT->getParamType(0) ==
IntegerType::getInt8PtrTy(M.getContext()) && IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
FT->getParamType(2)->isIntegerTy(); FT->getParamType(2)->isIntegerTy();
isStdString &= FT->getNumParams() >= 2 && isStdString &= FT->getNumParams() >= 2 &&
FT->getParamType(0)->isPointerTy() && FT->getParamType(0)->isPointerTy() &&

View File

@ -334,7 +334,8 @@ bool CmpLogRoutines::hookRtns(Module &M) {
isStrcmp &= isStrcmp &=
FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) && FT->getNumParams() == 2 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) == IntegerType::getInt8PtrTy(M.getContext()); FT->getParamType(0) ==
IntegerType::getInt8Ty(M.getContext())->getPointerTo(0);
bool isStrncmp = (!FuncName.compare("strncmp") || bool isStrncmp = (!FuncName.compare("strncmp") ||
!FuncName.compare("xmlStrncmp") || !FuncName.compare("xmlStrncmp") ||
@ -347,11 +348,11 @@ bool CmpLogRoutines::hookRtns(Module &M) {
!FuncName.compare("g_ascii_strncasecmp") || !FuncName.compare("g_ascii_strncasecmp") ||
!FuncName.compare("Curl_strncasecompare") || !FuncName.compare("Curl_strncasecompare") ||
!FuncName.compare("g_strncasecmp")); !FuncName.compare("g_strncasecmp"));
isStrncmp &= FT->getNumParams() == 3 && isStrncmp &=
FT->getReturnType()->isIntegerTy(32) && FT->getNumParams() == 3 && FT->getReturnType()->isIntegerTy(32) &&
FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0) == FT->getParamType(1) &&
FT->getParamType(0) == FT->getParamType(0) ==
IntegerType::getInt8PtrTy(M.getContext()) && IntegerType::getInt8Ty(M.getContext())->getPointerTo(0) &&
FT->getParamType(2)->isIntegerTy(); FT->getParamType(2)->isIntegerTy();
bool isGccStdStringStdString = bool isGccStdStringStdString =

View File

@ -99,7 +99,11 @@ static inline bool isIgnoreFunction(const llvm::Function *F) {
}; };
for (auto const &ignoreListFunc : ignoreList) { for (auto const &ignoreListFunc : ignoreList) {
#if LLVM_VERSION_MAJOR >= 18
if (F->getName().starts_with(ignoreListFunc)) { return true; }
#else
if (F->getName().startswith(ignoreListFunc)) { return true; } if (F->getName().startswith(ignoreListFunc)) { return true; }
#endif
} }
static constexpr const char *ignoreSubstringList[] = { static constexpr const char *ignoreSubstringList[] = {