Stream: git-wasmtime

Topic: wasmtime / Issue #1856 Rewrite `convert_object_elf_to_loa...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 10 2020 at 16:31):

bjorn3 opened Issue #1856:

object::elf export type definitions for all important structs used here. You can use object::pod::from_bytes and object::pos::bytes_of to convert between a slice and these structs. A from_bytes_mut method would be useful for this though. You should be able to create one by adapting from_bytes.

_Originally posted by @bjorn3 in https://github.com/bytecodealliance/wasmtime/pull/1848_

view this post on Zulip Wasmtime GitHub notifications bot (Jun 11 2020 at 15:45):

yurydelendik commented on Issue #1856:

I created #1860 to partially address the issue. Though I had a little success with the object v0.19's pod API to refactor convert_object_elf_to_loadable_file. There are gaps in this API to make it simple.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 17 2020 at 04:59):

philipc commented on Issue #1856:

@yurydelendik What is missing besides from_bytes_mut? Some of what you have done can be simplified already. For example:

-    let header: &FileHeader64<LittleEndian> =
-        unsafe { &*(bytes.as_mut_ptr() as *const FileHeader64<_>) };
+    let header = from_bytes::<FileHeader64<LittleEndian>>(&bytes).unwrap().0;

I thought about adding a &mut [u8] equivalent of Bytes, but I think it would be unusable with rust's borrowing rules.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 17 2020 at 05:02):

philipc edited a comment on Issue #1856:

@yurydelendik What is missing besides from_bytes_mut? Some of what you have done can be simplified already. For example:

-    let header: &FileHeader64<LittleEndian> =
-        unsafe { &*(bytes.as_mut_ptr() as *const FileHeader64<_>) };
+    let header = from_bytes::<FileHeader64<LittleEndian>>(&bytes).unwrap().0;

(Note that this is for the use that doesn't need to be mutable.)

I thought about adding a &mut [u8] equivalent of Bytes, but I think it would be unusable with rust's borrowing rules.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 17 2020 at 18:45):

yurydelendik commented on Issue #1856:

Yes, the immutable/reading part worked. Once I started patching, it all felt apart (including borrowing rules you mentioned).

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2021 at 17:57):

bjorn3 commented on Issue #1856:

I think this is fixed since #1860.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2021 at 17:58):

bjorn3 closed Issue #1856:

object::elf export type definitions for all important structs used here. You can use object::pod::from_bytes and object::pos::bytes_of to convert between a slice and these structs. A from_bytes_mut method would be useful for this though. You should be able to create one by adapting from_bytes.

_Originally posted by @bjorn3 in https://github.com/bytecodealliance/wasmtime/pull/1848_


Last updated: Oct 23 2024 at 20:03 UTC