- 1 year ago
Address resolution of a symbol with Windows (WLS2)
To resolve the address of a symbol in Windows (WSL2), you can use the following steps:
First, compile the program with debugging symbols enabled. For example, if you are using GCC, use the
-g
option.Next, start the program in the debugger. For example, if you are using GDB, type
gdb <program>
.Set a breakpoint at the location where you want to inspect the symbol. For example, if you want to inspect a symbol in a shared library, you may want to set a breakpoint in the
dlopen()
function.Once the breakpoint is hit, type the command
info sharedlibrary
to list all loaded shared libraries and their addresses.Find the name of the shared library that contains the symbol you want to inspect, and note its address.
Type the command
info symbol <symbol>
to get the address of the symbol.Add the base address of the shared library to the symbol address to get the absolute address of the symbol.
Alternatively, you can use a tool like nm
or objdump
to extract symbol information from the executable or shared library. For example, to extract symbol information from a shared library, you can type nm -D <shared-library>
. This will output a list of symbols and their addresses.