0

I am trying to reverse an ELF binary that makes use of thread-local variables. I can't figure out how to make Ghidra display them in a friendlier way (something like declaring a struct or similar).

For example, this is how a call to scanf with a FILE* stored in TLS looks like:

scanf(*(FILE **)(in_FS_OFFSET + 0xfffffff0),"%d",&num);

Ideally, I would like this to look something like:

scanf(tls->outfile, "%d", &num);

Is it possible to make it more user-friendly? I looked around but I haven't seen anyone complaining about this.

Here's an example code:

#include <threads.h>
#include <stdio.h>
#include <assert.h>

thread_local int foo = 0;

int main(void) {
    assert(scanf("%d", &foo) == 1);
    printf("foo is: %d\n", foo);
    return 0;
}

tls.c compile with CFLAGS="-std=c11 -Wall -Wextra -O0 -ggdb -Werror" make tls

And here's the decompiled code:

Ghidra's decompiler output for tls binary

1 Answer 1

0

It seems like this feature is not yet implemented in Ghidra.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.