How to get the address of the instruction in the shared library?

176 Views Asked by At

I want to reproduce some experiments in the flush-reload paper. In this experiment, there are two threads called A and B. There is a shared library c. The A thread flushes an instruction d in the shared library c from the cache through a flush instruction. Then A waits for a while. Then A reloads instruction d. If the loading time is short, it means that the instruction d is in the cache, indicating that the thread B used this instruction while the thread A was waiting. If it takes a long time to load instruction d, it means that instruction d is in the memory, indicating that thread B did not use this instruction during the waiting time of thread A.

I want to know how to get the address of an instruction in a shared library.

For example, I have a shared library with a function print. I want to get the address of the instruction a=a+1 in this function. by

gadget_module = dlopen("sym.so", RTLD_LAZY);
probe= (char**)(dlsym(gadget_module,"print"));

I can get the address of the print function, but how do I get the address of a=a+1? probe+n? (What should this n be?) How can it be verified that this address is indeed the instruction?

  int print(){
    a=a+1;
}
0

There are 0 best solutions below