googleprojectzero / TinyInst

A lightweight dynamic instrumentation library
Apache License 2.0
1.18k stars 119 forks source link

fix wrong base calculation when running no pie target. #69

Closed d0now closed 1 year ago

d0now commented 1 year ago

related issue: https://github.com/googleprojectzero/TinyInst/issues/68

test.c

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void routine(void)
{
    if (rand() % 2) {
        puts("even");
    } else {
        puts("odd");
    }

    if (rand() % 2) {
        puts("even");
    } else {
        puts("odd");
    }

    for (int i = 0; i < 10; i++)
    {
        int n = rand() % 3;
        if (n == 0) {
            puts("zero");
        } else if (n == 1) {
            puts("one");
        } else {
            puts("two");
        }
    }
}

int main(int argc, const char **argv, const char **envp)
{
    srand(time(0));
    printf("run> ");
    getchar();
    routine();
    return 0;
}

output

$ gcc -o test test.c -m32
$ sudo ~/TinyInst/src.forked/build/litecov -patch_return_addresses -pid $(pidof test)
Process finished normally
google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.