How to find the absolute address of a shared library symbol?

I want to write a little tracer function. I am using ptrace.

When I see a CALL statement, I want to show a function name equivalent to an address call.

My tracer works with characters with an absolute address (the character is defined in the main binary file). But I do not know how I can get the absolute address in the virtual memory of a shared library function. Define a libc function call, for example.

I noticed that the address of the function in the shared library refers to the file.

Is the following equation good?

Absolute address of symbol = address of the shared library in virtual memory +
                             relative address of the symbol.

How can I get the absolute address of a character from a shared library?

+5
source share
3 answers

'Linkers and Loaders' , . , . , ELF, Windows, .

+1

Once you have not described the system that you are working on, this article explains that at least the described problem can be solved for some cases, not for everyone.
If I were in your situation, I would look for the appropriate binary fragments in memory and in the library. Then, as soon as the memory and library are aligned, the problem is solved. So yes, the equation is good, as soon as the library cannot be divided and loaded as independent parts.

0
source

All Articles