pub enum LookupAddress {
Relative(u32),
Svma(u64),
FileOffset(u64),
}Expand description
An address that can be looked up in a SymbolMap.
You’ll usually want to use LookupAddress::Relative, i.e. addresses that
are relative to some “image base address”. This form works with all types
of symbol maps across all platforms.
When testing, be aware that many binaries are laid out in such a way that all three representations of addresses are the same: The image base address is often zero and the sections are often laid out so that each section’s address matches its file offset. So if you misrepresent an address in the wrong form, you might not notice it because it still works until you encounter a more complex binary.
Variants§
Relative(u32)
A relative address is relative to the image base address.
What this means depends on the format of the binary:
- On Windows, a “relative address” is the same as a RVA (“relative virtual address”) in the PE file.
- On macOS, a “relative address” is relative to the start of the
__TEXTsegment. - On Linux / ELF, a “relative address” is relative to the address of the first LOAD command in the program header table. In other words, it’s relative to the start of the first segment.
- For Jitdump files, the “relative address” space is a conceptual space
in which the code from all
JIT_CODE_LOADrecords is laid out sequentially, starting at 0. So the relative address of an instruction inside aJIT_CODE_LOADrecord is the sum of thecode_sizefields of all previousJIT_CODE_LOADrecords plus the offset of the instruction within the code of thisJIT_CODE_LOADrecord.
See relative_address_base for more information.
Svma(u64)
A “stated virtual memory address”, i.e. a virtual memory address as
written down in the binary. In mach-O and ELF, this is the space that
section addresses and symbol addresses are in. It’s the type of address
you’d pass to the Linux addr2line tool.
This type of lookup address is not supported by symbol maps for PDB files or Breakpad files.
FileOffset(u64)
A raw file offset to the point in the binary file where the bytes of the instruction are stored for which symbols should be looked up.
On Linux, if you have an “AVMA” (absolute virtual memory address) and
the /proc/<pid>/maps for the process, this is probably the easiest
form of address to compute, because the process maps give you the file offsets.
However, if you do this, be aware that the file offset often is not the same as an SVMA, so expect wrong results if you end up using it in places where SVMAs are expected - it might work fine with some binaries and then break with others.
File offsets are not supported by symbol maps for PDB files or Breakpad files.
Trait Implementations§
Source§impl Clone for LookupAddress
impl Clone for LookupAddress
Source§fn clone(&self) -> LookupAddress
fn clone(&self) -> LookupAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more