1 year ago
#332052
Andre Manada
Problems accessing a _Thread_local variable in x86_64 asm
I my currently working on a project that involves asm x86_64 and instrumenting code. I insert asm code thru GIMPLE that allow me to access a variable by name and decrease it. For example: sub $%d, special_counter\n\t
. Now the problem is that I need to make this project multithreaded and each thread needs one of this variables (they cannot be the same variable as it is a counter for each thread), not only that but I only know on what thread that code is going to run after the compilation phase.
My current approach involves the directive _Thread_local and trying to use sub $%d, special_counter@tlsgd(%rip)\n\t
but I get this error:
relocation R_X86_64_32S against \.text' cannot be used when making a shared object; recompile with -fPIC
and Iām using the -fPIC flag.
So do you have any suggestions on how to fix this? (I got the @tlsgd(%rip)
from writing a smaller program that uses a _Thread_local
variable and examining the asm code produced)
If you have any other idea on how to approach this problem it is also welcomed.
c
assembly
x86-64
instrumentation
thread-local-storage
0 Answers
Your Answer