aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-05 14:08:24 +0200
committervan Hauser <vh@thc.org>2020-05-05 14:08:24 +0200
commitd82ada89fee37068b0ff44f340338af3fc07cc37 (patch)
tree0e4c2be728b417a937563ed9c8f004ebfdc72475
parent9d384b4e383e2b216847e2ed3aee432a25cd37d8 (diff)
downloadafl++-d82ada89fee37068b0ff44f340338af3fc07cc37.tar.gz
support older llvm versions
-rw-r--r--llvm_mode/compare-transform-pass.so.cc42
1 files changed, 25 insertions, 17 deletions
diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc
index 9cf4169e..10413076 100644
--- a/llvm_mode/compare-transform-pass.so.cc
+++ b/llvm_mode/compare-transform-pass.so.cc
@@ -211,20 +211,24 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
// not literal? maybe global or local variable
- if (!(HasStr1 ^ HasStr2)) {
+ if (!(HasStr1 || HasStr2)) {
auto *Ptr = dyn_cast<ConstantExpr>(Str2P);
if (Ptr && Ptr->isGEPWithNoNotionalOverIndexing()) {
if (auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
- if (auto *Array =
- dyn_cast<ConstantDataArray>(Var->getInitializer())) {
+ if (Var->hasInitializer()) {
- HasStr2 = true;
- Str2 = Array->getAsString();
- valueMap[Str2P] = new std::string(Str2.str());
- // fprintf(stderr, "glo2 %s\n", Str2.str().c_str());
+ if (auto *Array =
+ dyn_cast<ConstantDataArray>(Var->getInitializer())) {
+
+ HasStr2 = true;
+ Str2 = Array->getAsString();
+ valueMap[Str2P] = new std::string(Str2.str());
+ fprintf(stderr, "glo2 %s\n", Str2.str().c_str());
+
+ }
}
@@ -239,13 +243,17 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
if (auto *Var = dyn_cast<GlobalVariable>(Ptr->getOperand(0))) {
- if (auto *Array =
- dyn_cast<ConstantDataArray>(Var->getInitializer())) {
+ if (Var->hasInitializer()) {
+
+ if (auto *Array = dyn_cast<ConstantDataArray>(
+ Var->getInitializer())) {
+
+ HasStr1 = true;
+ Str1 = Array->getAsString();
+ valueMap[Str1P] = new std::string(Str1.str());
+ // fprintf(stderr, "glo1 %s\n", Str1.str().c_str());
- HasStr1 = true;
- Str1 = Array->getAsString();
- valueMap[Str1P] = new std::string(Str1.str());
- // fprintf(stderr, "glo1 %s\n", Str1.str().c_str());
+ }
}
@@ -260,13 +268,13 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
- if ((HasStr1 ^ HasStr2)) indirect = true;
+ if ((HasStr1 || HasStr2)) indirect = true;
}
if (isIntMemcpy) continue;
- if (!(HasStr1 ^ HasStr2)) {
+ if (!(HasStr1 || HasStr2)) {
// do we have a saved local variable initialization?
std::string *val = valueMap[Str1P];
@@ -294,7 +302,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
/* handle cases of one string is const, one string is variable */
- if (!(HasStr1 ^ HasStr2)) continue;
+ if (!(HasStr1 || HasStr2)) continue;
if (isMemcmp || isStrncmp || isStrncasecmp) {
@@ -359,7 +367,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
- if (!(HasStr1 ^ HasStr2)) {
+ if (!(HasStr1 || HasStr2)) {
// do we have a saved local or global variable initialization?
std::string *val = valueMap[Str1P];