DreamSoule / ollvm17

Obfuscation LLVM 17
265 stars 40 forks source link

Per Function OLLVM Fail Becouse Missing Annotations #25

Open pinwhell opened 1 month ago

pinwhell commented 1 month ago
__attribute__((annotate("nofla")))
double  heavyComputation  (int n) {
...
}

Generates:

@.str = private unnamed_addr constant [6 x i8] c"nofla\00", section "llvm.metadata"
@.str.1 = private unnamed_addr constant [9 x i8] c"main.cpp\00", section "llvm.metadata"

But

std::string llvm::readAnnotate(Function *f)

seems not able to find/retrieve the annotation(/s) "nofla" ..

to reproduce

// main.cpp
#include <iostream>
#include <vector>
#include <cmath>

// Function to perform some heavy processing

__attribute__((annotate("nofla")))
double  heavyComputation  (int n) {

    // Initialize a vector to store intermediate results
    std::vector<double> results(n);

    // Perform some calculations
    for (int i = 0; i < n; ++i) {
        results[i] = 0;
        for (int j = 1; j <= 1000; ++j) {
            results[i] += sin(i * j) + cos(i / (j + 1.0));
        }
        results[i] = pow(results[i], 2.5) / (i + 1.0);
    }

    // Calculate the final result
    double finalResult = 0;
    for (double value : results) {
        finalResult += sqrt(value);
    }

    std::cout << " + Some Bullshit ";

    return finalResult;
}

int main() {
    // Print "Hello, World!"
    std::cout << "Hello, World!" << std::endl;

    // Perform the heavy computation
    int n = 1000; // Number of elements to process
    double result = heavyComputation(n);

    // Print the result of the computation
    std::cout << "The result of the heavy computation is: " << result << std::endl;

    return 0;
}
clang-cl main.cpp -o main.exe
pinwhell commented 1 month ago

I guess the annotation seems to be present but not attached to the function 🤔