Fuzz-code-coverage motivated improvements (#3905)
* fuzz: Fuzz padding between compiled functions This commit hooks up the custom `wasmtime_linkopt_padding_between_functions` configuration option to the cranelift compiler into the fuzz configuration, enabling us to ensure that randomly inserting a moderate amount of padding between functions shouldn't tamper with any results. * fuzz: Fuzz the `Config::generate_address_map` option This commit adds fuzz configuration where `generate_address_map` is either enabled or disabled, unlike how it's always enabled for fuzzing today. * Remove unnecessary handling of relocations This commit removes a number of bits and pieces all related to handling relocations in JIT code generated by Wasmtime. None of this is necessary nowadays that the "old backend" has been removed (quite some time ago) and relocations are no longer expected to be in the JIT code at all. Additionally with the minimum x86_64 features required to run wasm code it should be expected that no libcalls are required either for Wasmtime-based JIT code.
This commit is contained in:
@@ -148,18 +148,12 @@ impl CodeMemory {
|
||||
std::slice::from_raw_parts_mut(ret.text.as_ptr() as *mut u8, ret.text.len());
|
||||
let text_offset = ret.text.as_ptr() as usize - ret.mmap.as_ptr() as usize;
|
||||
let text_range = text_offset..text_offset + text_mut.len();
|
||||
let mut text_section_readwrite = false;
|
||||
for (offset, r) in text.relocations() {
|
||||
// If the text section was mapped at readonly we need to make it
|
||||
// briefly read/write here as we apply relocations.
|
||||
if !text_section_readwrite && self.mmap.is_readonly() {
|
||||
self.mmap
|
||||
.make_writable(text_range.clone())
|
||||
.expect("unable to make memory writable");
|
||||
text_section_readwrite = true;
|
||||
}
|
||||
crate::link::apply_reloc(&ret.obj, text_mut, offset, r);
|
||||
}
|
||||
|
||||
// Double-check there are no relocations in the text section. At
|
||||
// this time relocations are not expected at all from loaded code
|
||||
// since everything should be resolved at compile time. Handling
|
||||
// must be added here, though, if relocations pop up.
|
||||
assert!(text.relocations().count() == 0);
|
||||
|
||||
// Switch the executable portion from read/write to
|
||||
// read/execute, notably not using read/write/execute to prevent
|
||||
|
||||
Reference in New Issue
Block a user