Add a compilation section to disable address maps (#3598)
* Add a compilation section to disable address maps This commit adds a new `Config::generate_address_map` compilation setting which is used to disable emission of the `.wasmtime.addrmap` section of compiled artifacts. This section is currently around the size of the entire `.text` section itself unfortunately and for size reasons may wish to be omitted. Functionality-wise all that is lost is knowing the precise wasm module offset address of a faulting instruction or in a backtrace of instructions. This also means that if the module has DWARF debugging information available with it Wasmtime isn't able to produce a filename and line number in the backtrace. This option remains enabled by default. This option may not be needed in the future with #3547 perhaps, but in the meantime it seems reasonable enough to support a configuration mode where the section is entirely omitted if the smallest module possible is desired. * Fix some CI issues * Update tests/all/traps.rs Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com> * Do less work in compilation for address maps But only when disabled Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
This commit is contained in:
@@ -297,16 +297,21 @@ impl CompiledModule {
|
||||
};
|
||||
|
||||
let mut ret = Self {
|
||||
meta: info.meta,
|
||||
module: Arc::new(info.module),
|
||||
funcs: info.funcs,
|
||||
trampolines: info.trampolines,
|
||||
wasm_data: subslice_range(section(ELF_WASM_DATA)?, code.mmap),
|
||||
address_map_data: subslice_range(section(ELF_WASMTIME_ADDRMAP)?, code.mmap),
|
||||
address_map_data: code
|
||||
.obj
|
||||
.section_by_name(ELF_WASMTIME_ADDRMAP)
|
||||
.and_then(|s| s.data().ok())
|
||||
.map(|slice| subslice_range(slice, code.mmap))
|
||||
.unwrap_or(0..0),
|
||||
trap_data: subslice_range(section(ELF_WASMTIME_TRAPS)?, code.mmap),
|
||||
code: subslice_range(code.text, code.mmap),
|
||||
dbg_jit_registration: None,
|
||||
code_memory,
|
||||
meta: info.meta,
|
||||
};
|
||||
ret.register_debug_and_profiling(profiler)?;
|
||||
|
||||
@@ -500,6 +505,15 @@ impl CompiledModule {
|
||||
pub fn has_unparsed_debuginfo(&self) -> bool {
|
||||
self.meta.has_unparsed_debuginfo
|
||||
}
|
||||
|
||||
/// Indicates whether this module came with n address map such that lookups
|
||||
/// via `wasmtime_environ::lookup_file_pos` will succeed.
|
||||
///
|
||||
/// If this function returns `false` then `lookup_file_pos` will always
|
||||
/// return `None`.
|
||||
pub fn has_address_map(&self) -> bool {
|
||||
!self.address_map_data().is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
type Addr2LineContext<'a> = addr2line::Context<gimli::EndianSlice<'a, gimli::LittleEndian>>;
|
||||
|
||||
Reference in New Issue
Block a user