diff --git a/Cargo.lock b/Cargo.lock index 51144493fae1..00443db0ae12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -955,7 +955,7 @@ dependencies = [ "cranelift-frontend", "cranelift-module", "log", - "object 0.38.1", + "object 0.39.0", "target-lexicon", ] @@ -2442,7 +2442,7 @@ name = "min-platform-host" version = "44.0.0" dependencies = [ "libloading", - "object 0.38.1", + "object 0.39.0", "wasmtime", ] @@ -2585,9 +2585,9 @@ dependencies = [ [[package]] name = "object" -version = "0.38.1" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271638cd5fa9cca89c4c304675ca658efc4e64a66c716b7cfe1afb4b9611dbbc" +checksum = "63944c133d03f44e75866bbd160b95af0ec3f6a13d936d69d31c81078cbc5baf" dependencies = [ "crc32fast", "hashbrown 0.16.1", @@ -4349,7 +4349,7 @@ version = "44.0.0" dependencies = [ "bitflags 2.9.4", "byte-array-literals", - "object 0.38.1", + "object 0.39.0", "wasip1", "wasm-encoder", "wit-bindgen-rust-macro", @@ -4613,7 +4613,7 @@ dependencies = [ "log", "mach2", "memfd", - "object 0.38.1", + "object 0.39.0", "once_cell", "postcard", "proptest", @@ -4723,7 +4723,7 @@ dependencies = [ "log", "memchr", "num_cpus", - "object 0.38.1", + "object 0.39.0", "pulley-interpreter", "rand 0.9.2", "rayon", @@ -4802,7 +4802,7 @@ dependencies = [ "hashbrown 0.16.1", "indexmap 2.13.0", "log", - "object 0.38.1", + "object 0.39.0", "postcard", "rustc-demangle", "semver", @@ -4981,7 +4981,7 @@ dependencies = [ "gimli 0.33.0", "itertools 0.14.0", "log", - "object 0.38.1", + "object 0.39.0", "pulley-interpreter", "smallvec 1.15.1", "target-lexicon", @@ -5059,7 +5059,7 @@ name = "wasmtime-internal-jit-debug" version = "44.0.0" dependencies = [ "cc", - "object 0.38.1", + "object 0.39.0", "rustix 1.0.8", "wasmtime-internal-versioned-export-macros", ] @@ -5081,7 +5081,7 @@ dependencies = [ "cfg-if", "cranelift-codegen", "log", - "object 0.38.1", + "object 0.39.0", "wasmtime-environ", ] @@ -5101,7 +5101,7 @@ dependencies = [ "cranelift-codegen", "gimli 0.33.0", "log", - "object 0.38.1", + "object 0.39.0", "target-lexicon", "wasmparser 0.245.0", "wasmtime-environ", @@ -5312,7 +5312,7 @@ version = "44.0.0" dependencies = [ "json-from-wast", "log", - "object 0.38.1", + "object 0.39.0", "serde_json", "tokio", "wasmparser 0.245.0", diff --git a/Cargo.toml b/Cargo.toml index 149480a4eb39..62912c3facf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -368,7 +368,7 @@ backtrace = "0.3.75" bumpalo = "3.20.0" mutatis = {version = "0.3.2", features = ["alloc"] } cc = "1.2.41" -object = { version = "0.38.1", default-features = false, features = ['read_core', 'elf'] } +object = { version = "0.39.0", default-features = false, features = ['read_core', 'elf'] } gimli = { version = "0.33.0", default-features = false, features = ['read'] } addr2line = { version = "0.26.0", default-features = false } anyhow = { version = "1.0.100", default-features = false } diff --git a/crates/environ/src/address_map.rs b/crates/environ/src/address_map.rs index c9cafcaa8d60..5dda8e634047 100644 --- a/crates/environ/src/address_map.rs +++ b/crates/environ/src/address_map.rs @@ -1,6 +1,6 @@ //! Data structures to provide transformation of the source -use object::{Bytes, LittleEndian, U32Bytes}; +use object::{Bytes, LittleEndian, U32}; use serde_derive::{Deserialize, Serialize}; /// Single source location to generated address mapping. @@ -63,18 +63,16 @@ impl Default for FilePos { /// Parse an `ELF_WASMTIME_ADDRMAP` section, returning the slice of code offsets /// and the slice of associated file positions for each offset. -fn parse_address_map( - section: &[u8], -) -> Option<(&[U32Bytes], &[U32Bytes])> { +fn parse_address_map(section: &[u8]) -> Option<(&[U32], &[U32])> { let mut section = Bytes(section); // NB: this matches the encoding written by `append_to` in the // `compile::address_map` module. - let count = section.read::>().ok()?; + let count = section.read::>().ok()?; let count = usize::try_from(count.get(LittleEndian)).ok()?; let (offsets, section) = - object::slice_from_bytes::>(section.0, count).ok()?; + object::slice_from_bytes::>(section.0, count).ok()?; let (positions, section) = - object::slice_from_bytes::>(section, count).ok()?; + object::slice_from_bytes::>(section, count).ok()?; debug_assert!(section.is_empty()); Some((offsets, positions)) } diff --git a/crates/environ/src/compile/address_map.rs b/crates/environ/src/compile/address_map.rs index 4420e942be28..8620a4840ebd 100644 --- a/crates/environ/src/compile/address_map.rs +++ b/crates/environ/src/compile/address_map.rs @@ -4,7 +4,7 @@ use crate::InstructionAddressMap; use crate::obj::ELF_WASMTIME_ADDRMAP; use crate::prelude::*; use object::write::{Object, StandardSegment}; -use object::{LittleEndian, SectionKind, U32Bytes}; +use object::{LittleEndian, SectionKind, U32}; use std::ops::Range; /// Builder for the address map section of a wasmtime compilation image. @@ -14,8 +14,8 @@ use std::ops::Range; /// into an `Object`. #[derive(Default)] pub struct AddressMapSection { - offsets: Vec>, - positions: Vec>, + offsets: Vec>, + positions: Vec>, last_offset: u32, } @@ -58,8 +58,8 @@ impl AddressMapSection { } last_srcloc = Some(srcloc); - self.offsets.push(U32Bytes::new(LittleEndian, pos)); - self.positions.push(U32Bytes::new(LittleEndian, srcloc)); + self.offsets.push(U32::new(LittleEndian, pos)); + self.positions.push(U32::new(LittleEndian, srcloc)); } self.last_offset = func_end; } diff --git a/crates/environ/src/compile/frame_table.rs b/crates/environ/src/compile/frame_table.rs index 489e990c9ab0..68ed97bc2e7c 100644 --- a/crates/environ/src/compile/frame_table.rs +++ b/crates/environ/src/compile/frame_table.rs @@ -12,7 +12,7 @@ use crate::{ FrameInstPos, FrameStackShape, FrameStateSlotOffset, FrameTableDescriptorIndex, FrameValType, FuncKey, WasmHeapTopType, WasmValType, prelude::*, }; -use object::{LittleEndian, U32Bytes}; +use object::{LittleEndian, U32}; use std::collections::{HashMap, hash_map::Entry}; /// Builder for a stackslot descriptor. @@ -230,19 +230,19 @@ impl FrameStateSlotBuilder { pub struct FrameTableBuilder { /// (offset, length) pairs into `frame_descriptor_data`, indexed /// by frame descriptor number. - frame_descriptor_ranges: Vec>, + frame_descriptor_ranges: Vec>, frame_descriptor_data: Vec, /// Offset from frame slot up to FP for each frame descriptor. - frame_descriptor_fp_offsets: Vec>, + frame_descriptor_fp_offsets: Vec>, - progpoint_pcs: Vec>, - progpoint_descriptor_offsets: Vec>, - progpoint_descriptor_data: Vec>, + progpoint_pcs: Vec>, + progpoint_descriptor_offsets: Vec>, + progpoint_descriptor_data: Vec>, - breakpoint_pcs: Vec>, - breakpoint_patch_offsets: Vec>, - breakpoint_patch_data_ends: Vec>, + breakpoint_pcs: Vec>, + breakpoint_patch_offsets: Vec>, + breakpoint_patch_data_ends: Vec>, breakpoint_patch_data: Vec, } @@ -264,11 +264,11 @@ impl FrameTableBuilder { u32::try_from(self.frame_descriptor_fp_offsets.len()).unwrap(), ); self.frame_descriptor_fp_offsets - .push(U32Bytes::new(LittleEndian, slot_to_fp_offset)); + .push(U32::new(LittleEndian, slot_to_fp_offset)); self.frame_descriptor_ranges - .push(U32Bytes::new(LittleEndian, start)); + .push(U32::new(LittleEndian, start)); self.frame_descriptor_ranges - .push(U32Bytes::new(LittleEndian, end)); + .push(U32::new(LittleEndian, end)); index } @@ -295,34 +295,32 @@ impl FrameTableBuilder { } let start = u32::try_from(self.progpoint_descriptor_data.len()).unwrap(); - self.progpoint_pcs - .push(U32Bytes::new(LittleEndian, pc_and_pos)); + self.progpoint_pcs.push(U32::new(LittleEndian, pc_and_pos)); self.progpoint_descriptor_offsets - .push(U32Bytes::new(LittleEndian, start)); + .push(U32::new(LittleEndian, start)); for (i, &(wasm_pc, frame_descriptor, stack_shape)) in frames.iter().enumerate() { debug_assert!(wasm_pc < 0x8000_0000); let not_last = i < (frames.len() - 1); let wasm_pc = wasm_pc | if not_last { 0x8000_0000 } else { 0 }; self.progpoint_descriptor_data - .push(U32Bytes::new(LittleEndian, wasm_pc)); + .push(U32::new(LittleEndian, wasm_pc)); self.progpoint_descriptor_data - .push(U32Bytes::new(LittleEndian, frame_descriptor.0)); + .push(U32::new(LittleEndian, frame_descriptor.0)); self.progpoint_descriptor_data - .push(U32Bytes::new(LittleEndian, stack_shape.0)); + .push(U32::new(LittleEndian, stack_shape.0)); } } /// Add one breakpoint patch. pub fn add_breakpoint_patch(&mut self, wasm_pc: u32, patch_start_native_pc: u32, patch: &[u8]) { - self.breakpoint_pcs - .push(U32Bytes::new(LittleEndian, wasm_pc)); + self.breakpoint_pcs.push(U32::new(LittleEndian, wasm_pc)); self.breakpoint_patch_offsets - .push(U32Bytes::new(LittleEndian, patch_start_native_pc)); + .push(U32::new(LittleEndian, patch_start_native_pc)); self.breakpoint_patch_data.extend(patch.iter().cloned()); let end = u32::try_from(self.breakpoint_patch_data.len()).unwrap(); self.breakpoint_patch_data_ends - .push(U32Bytes::new(LittleEndian, end)); + .push(U32::new(LittleEndian, end)); } /// Serialize the framd-table data section, taking a closure to diff --git a/crates/environ/src/compile/stack_maps.rs b/crates/environ/src/compile/stack_maps.rs index a02b5e7162a9..57ce411874bd 100644 --- a/crates/environ/src/compile/stack_maps.rs +++ b/crates/environ/src/compile/stack_maps.rs @@ -2,7 +2,7 @@ use crate::obj::ELF_WASMTIME_STACK_MAP; use crate::prelude::*; use cranelift_bitset::CompoundBitSet; use object::write::{Object, StandardSegment}; -use object::{LittleEndian, SectionKind, U32Bytes}; +use object::{LittleEndian, SectionKind, U32}; /// Builder for the `ELF_WASMTIME_STACK_MAP` section in compiled executables. /// @@ -71,9 +71,9 @@ use object::{LittleEndian, SectionKind, U32Bytes}; /// more. #[derive(Default)] pub struct StackMapSection { - pcs: Vec>, - pointers_to_stack_map: Vec>, - stack_map_data: Vec>, + pcs: Vec>, + pointers_to_stack_map: Vec>, + stack_map_data: Vec>, last_offset: u32, } @@ -103,16 +103,15 @@ impl StackMapSection { } // Record parallel entries in `pcs`/`pointers_to_stack_map`. - self.pcs.push(U32Bytes::new(LittleEndian, code_offset)); - self.pointers_to_stack_map.push(U32Bytes::new( + self.pcs.push(U32::new(LittleEndian, code_offset)); + self.pointers_to_stack_map.push(U32::new( LittleEndian, u32::try_from(self.stack_map_data.len()).unwrap(), )); // The frame data starts with the frame size and is then followed by // `offsets` represented as a bit set. - self.stack_map_data - .push(U32Bytes::new(LittleEndian, frame_size)); + self.stack_map_data.push(U32::new(LittleEndian, frame_size)); let mut bits = CompoundBitSet::::default(); for offset in frame_offsets { @@ -121,10 +120,9 @@ impl StackMapSection { } let count = bits.iter_scalars().count(); self.stack_map_data - .push(U32Bytes::new(LittleEndian, count as u32)); + .push(U32::new(LittleEndian, count as u32)); for scalar in bits.iter_scalars() { - self.stack_map_data - .push(U32Bytes::new(LittleEndian, scalar.0)); + self.stack_map_data.push(U32::new(LittleEndian, scalar.0)); } } diff --git a/crates/environ/src/compile/trap_encoding.rs b/crates/environ/src/compile/trap_encoding.rs index 3cd548aa380b..c5d5b63a54ea 100644 --- a/crates/environ/src/compile/trap_encoding.rs +++ b/crates/environ/src/compile/trap_encoding.rs @@ -2,7 +2,7 @@ use crate::TrapInformation; use crate::obj::ELF_WASMTIME_TRAPS; use crate::prelude::*; use object::write::{Object, StandardSegment}; -use object::{LittleEndian, SectionKind, U32Bytes}; +use object::{LittleEndian, SectionKind, U32}; use std::ops::Range; /// A helper structure to build the custom-encoded section of a wasmtime @@ -13,7 +13,7 @@ use std::ops::Range; /// `lookup_trap_code` below with the resulting section. #[derive(Default)] pub struct TrapEncodingBuilder { - offsets: Vec>, + offsets: Vec>, traps: Vec, last_offset: u32, } @@ -45,7 +45,7 @@ impl TrapEncodingBuilder { for info in traps { let pos = func_start + info.code_offset; assert!(pos >= self.last_offset); - self.offsets.push(U32Bytes::new(LittleEndian, pos)); + self.offsets.push(U32::new(LittleEndian, pos)); self.traps.push(info.trap_code as u8); self.last_offset = pos; } diff --git a/crates/environ/src/frame_table.rs b/crates/environ/src/frame_table.rs index 2d3259b53a1c..76bc8538caa2 100644 --- a/crates/environ/src/frame_table.rs +++ b/crates/environ/src/frame_table.rs @@ -6,7 +6,7 @@ use crate::FuncKey; use alloc::vec::Vec; -use object::{Bytes, LittleEndian, U32Bytes}; +use object::{Bytes, LittleEndian, U32}; /// An index into the table of stack shapes. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -44,18 +44,18 @@ impl FrameTableDescriptorIndex { /// cheap to construct: it reads some header fields but does not /// interpret or validate content data until queried. pub struct FrameTable<'a> { - frame_descriptor_ranges: &'a [U32Bytes], + frame_descriptor_ranges: &'a [U32], frame_descriptor_data: &'a [u8], - frame_descriptor_fp_offsets: &'a [U32Bytes], + frame_descriptor_fp_offsets: &'a [U32], - progpoint_pcs: &'a [U32Bytes], - progpoint_descriptor_offsets: &'a [U32Bytes], - progpoint_descriptor_data: &'a [U32Bytes], + progpoint_pcs: &'a [U32], + progpoint_descriptor_offsets: &'a [U32], + progpoint_descriptor_data: &'a [U32], - breakpoint_pcs: &'a [U32Bytes], - breakpoint_patch_offsets: &'a [U32Bytes], - breakpoint_patch_data_ends: &'a [U32Bytes], + breakpoint_pcs: &'a [U32], + breakpoint_patch_offsets: &'a [U32], + breakpoint_patch_data_ends: &'a [U32], breakpoint_patch_data: &'a [u8], original_text: &'a [u8], @@ -67,67 +67,65 @@ impl<'a> FrameTable<'a> { pub fn parse(data: &'a [u8], original_text: &'a [u8]) -> anyhow::Result> { let mut data = Bytes(data); let num_frame_descriptors = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read frame descriptor count prefix"))?; let num_frame_descriptors = usize::try_from(num_frame_descriptors.get(LittleEndian))?; let num_progpoint_descriptors = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read progpoint descriptor count prefix"))?; let num_progpoint_descriptors = usize::try_from(num_progpoint_descriptors.get(LittleEndian))?; let num_breakpoints = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read breakpoint count prefix"))?; let num_breakpoints = usize::try_from(num_breakpoints.get(LittleEndian))?; let frame_descriptor_pool_length = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read frame descriptor pool length"))?; let frame_descriptor_pool_length = usize::try_from(frame_descriptor_pool_length.get(LittleEndian))?; let progpoint_descriptor_pool_length = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read progpoint descriptor pool length"))?; let progpoint_descriptor_pool_length = usize::try_from(progpoint_descriptor_pool_length.get(LittleEndian))?; let breakpoint_patch_pool_length = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read breakpoint patch pool length"))?; let breakpoint_patch_pool_length = usize::try_from(breakpoint_patch_pool_length.get(LittleEndian))?; let (frame_descriptor_ranges, data) = - object::slice_from_bytes::>(data.0, 2 * num_frame_descriptors) + object::slice_from_bytes::>(data.0, 2 * num_frame_descriptors) .map_err(|_| anyhow::anyhow!("Unable to read frame descriptor ranges slice"))?; let (frame_descriptor_fp_offsets, data) = - object::slice_from_bytes::>(data, num_frame_descriptors) + object::slice_from_bytes::>(data, num_frame_descriptors) .map_err(|_| anyhow::anyhow!("Unable to read frame descriptor FP offset slice"))?; let (progpoint_pcs, data) = - object::slice_from_bytes::>(data, num_progpoint_descriptors) + object::slice_from_bytes::>(data, num_progpoint_descriptors) .map_err(|_| anyhow::anyhow!("Unable to read progpoint PC slice"))?; let (progpoint_descriptor_offsets, data) = - object::slice_from_bytes::>(data, num_progpoint_descriptors) + object::slice_from_bytes::>(data, num_progpoint_descriptors) .map_err(|_| anyhow::anyhow!("Unable to read progpoint descriptor offset slice"))?; let (breakpoint_pcs, data) = - object::slice_from_bytes::>(data, num_breakpoints) + object::slice_from_bytes::>(data, num_breakpoints) .map_err(|_| anyhow::anyhow!("Unable to read breakpoint PC slice"))?; let (breakpoint_patch_offsets, data) = - object::slice_from_bytes::>(data, num_breakpoints) + object::slice_from_bytes::>(data, num_breakpoints) .map_err(|_| anyhow::anyhow!("Unable to read breakpoint patch offsets slice"))?; let (breakpoint_patch_data_ends, data) = - object::slice_from_bytes::>(data, num_breakpoints) + object::slice_from_bytes::>(data, num_breakpoints) .map_err(|_| anyhow::anyhow!("Unable to read breakpoint patch data ends slice"))?; let (frame_descriptor_data, data) = data .split_at_checked(frame_descriptor_pool_length) .ok_or_else(|| anyhow::anyhow!("Unable to read frame descriptor pool"))?; - let (progpoint_descriptor_data, data) = object::slice_from_bytes::>( - data, - progpoint_descriptor_pool_length, - ) - .map_err(|_| anyhow::anyhow!("Unable to read progpoint descriptor pool"))?; + let (progpoint_descriptor_data, data) = + object::slice_from_bytes::>(data, progpoint_descriptor_pool_length) + .map_err(|_| anyhow::anyhow!("Unable to read progpoint descriptor pool"))?; let (breakpoint_patch_data, _) = data .split_at_checked(breakpoint_patch_pool_length) @@ -497,9 +495,9 @@ impl TryFrom for FrameValType { /// and for the stack given a stack shape. pub struct FrameStateSlot<'a> { func_key: FuncKey, - local_offsets: &'a [U32Bytes], - stack_shape_parents: &'a [U32Bytes], - stack_shape_offsets: &'a [U32Bytes], + local_offsets: &'a [U32], + stack_shape_parents: &'a [U32], + stack_shape_offsets: &'a [U32], local_types: &'a [u8], stack_shape_types: &'a [u8], } @@ -512,34 +510,34 @@ impl<'a> FrameStateSlot<'a> { pub fn parse(descriptor: &'a [u8]) -> anyhow::Result> { let mut data = Bytes(descriptor); let func_key_namespace = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read func key namespace"))? .get(LittleEndian); let func_key_index = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read func key index"))? .get(LittleEndian); let func_key = FuncKey::from_raw_parts(func_key_namespace, func_key_index); let num_locals = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read num_locals"))? .get(LittleEndian); let num_locals = usize::try_from(num_locals)?; let num_stack_shapes = data - .read::>() + .read::>() .map_err(|_| anyhow::anyhow!("Unable to read num_stack_shapes"))? .get(LittleEndian); let num_stack_shapes = usize::try_from(num_stack_shapes)?; let (local_offsets, data) = - object::slice_from_bytes::>(data.0, num_locals) + object::slice_from_bytes::>(data.0, num_locals) .map_err(|_| anyhow::anyhow!("Unable to read local_offsets slice"))?; let (stack_shape_parents, data) = - object::slice_from_bytes::>(data, num_stack_shapes) + object::slice_from_bytes::>(data, num_stack_shapes) .map_err(|_| anyhow::anyhow!("Unable to read stack_shape_parents slice"))?; let (stack_shape_offsets, data) = - object::slice_from_bytes::>(data, num_stack_shapes) + object::slice_from_bytes::>(data, num_stack_shapes) .map_err(|_| anyhow::anyhow!("Unable to read stack_shape_offsets slice"))?; let (local_types, data) = data .split_at_checked(num_locals) diff --git a/crates/environ/src/stack_map.rs b/crates/environ/src/stack_map.rs index e01230a62a41..fb6bba2d96a0 100644 --- a/crates/environ/src/stack_map.rs +++ b/crates/environ/src/stack_map.rs @@ -1,10 +1,10 @@ use cranelift_bitset::ScalarBitSet; -use object::{Bytes, LittleEndian, U32Bytes}; +use object::{Bytes, LittleEndian, U32}; struct StackMapSection<'a> { - pcs: &'a [U32Bytes], - pointers_to_stack_map: &'a [U32Bytes], - stack_map_data: &'a [U32Bytes], + pcs: &'a [U32], + pointers_to_stack_map: &'a [U32], + stack_map_data: &'a [U32], } impl<'a> StackMapSection<'a> { @@ -12,14 +12,13 @@ impl<'a> StackMapSection<'a> { let mut section = Bytes(section); // NB: this matches the encoding written by `append_to` in the // `compile::stack_map` module. - let pc_count = section.read::>().ok()?; + let pc_count = section.read::>().ok()?; let pc_count = usize::try_from(pc_count.get(LittleEndian)).ok()?; let (pcs, section) = - object::slice_from_bytes::>(section.0, pc_count).ok()?; + object::slice_from_bytes::>(section.0, pc_count).ok()?; let (pointers_to_stack_map, section) = - object::slice_from_bytes::>(section, pc_count).ok()?; - let stack_map_data = - object::slice_from_all_bytes::>(section).ok()?; + object::slice_from_bytes::>(section, pc_count).ok()?; + let stack_map_data = object::slice_from_all_bytes::>(section).ok()?; Some(StackMapSection { pcs, pointers_to_stack_map, @@ -65,7 +64,7 @@ impl<'a> StackMapSection<'a> { /// the docs over there. pub struct StackMap<'a> { frame_size: u32, - data: &'a [U32Bytes], + data: &'a [U32], } impl<'a> StackMap<'a> { diff --git a/crates/environ/src/trap_encoding.rs b/crates/environ/src/trap_encoding.rs index cf011fe591f7..40d7e62f4cc5 100644 --- a/crates/environ/src/trap_encoding.rs +++ b/crates/environ/src/trap_encoding.rs @@ -1,5 +1,5 @@ use core::fmt; -use object::{Bytes, LittleEndian, U32Bytes}; +use object::{Bytes, LittleEndian, U32}; /// Information about trap. #[derive(Debug, PartialEq, Eq, Clone)] @@ -253,13 +253,12 @@ pub fn lookup_trap_code(section: &[u8], offset: usize) -> Option { trap } -fn parse(section: &[u8]) -> Option<(&[U32Bytes], &[u8])> { +fn parse(section: &[u8]) -> Option<(&[U32], &[u8])> { let mut section = Bytes(section); // NB: this matches the encoding written by `append_to` above. - let count = section.read::>().ok()?; + let count = section.read::>().ok()?; let count = usize::try_from(count.get(LittleEndian)).ok()?; - let (offsets, traps) = - object::slice_from_bytes::>(section.0, count).ok()?; + let (offsets, traps) = object::slice_from_bytes::>(section.0, count).ok()?; debug_assert_eq!(traps.len(), count); Some((offsets, traps)) } diff --git a/crates/unwinder/src/exception_table.rs b/crates/unwinder/src/exception_table.rs index fa87b94b947f..85ba28732ef5 100644 --- a/crates/unwinder/src/exception_table.rs +++ b/crates/unwinder/src/exception_table.rs @@ -10,7 +10,7 @@ //! and used without post-processing; this enables efficient //! module-loading in runtimes such as Wasmtime. -use object::{Bytes, LittleEndian, U32Bytes}; +use object::{Bytes, LittleEndian, U32}; #[cfg(feature = "cranelift")] use alloc::vec; @@ -108,12 +108,12 @@ use wasmtime_environ::prelude::*; #[cfg(feature = "cranelift")] #[derive(Clone, Debug, Default)] pub struct ExceptionTableBuilder { - pub callsites: Vec>, - pub frame_offsets: Vec>, - pub ranges: Vec>, - pub tags: Vec>, - pub contexts: Vec>, - pub handlers: Vec>, + pub callsites: Vec>, + pub frame_offsets: Vec>, + pub ranges: Vec>, + pub tags: Vec>, + pub contexts: Vec>, + pub handlers: Vec>, last_start_offset: CodeOffset, } @@ -145,17 +145,17 @@ impl ExceptionTableBuilder { for handler in call_site.exception_handlers { match handler { FinalizedMachExceptionHandler::Tag(tag, offset) => { - self.tags.push(U32Bytes::new(LittleEndian, tag.as_u32())); - self.contexts.push(U32Bytes::new(LittleEndian, context)); - self.handlers.push(U32Bytes::new( + self.tags.push(U32::new(LittleEndian, tag.as_u32())); + self.contexts.push(U32::new(LittleEndian, context)); + self.handlers.push(U32::new( LittleEndian, offset.checked_add(start_offset).unwrap(), )); } FinalizedMachExceptionHandler::Default(offset) => { - self.tags.push(U32Bytes::new(LittleEndian, u32::MAX)); - self.contexts.push(U32Bytes::new(LittleEndian, context)); - self.handlers.push(U32Bytes::new( + self.tags.push(U32::new(LittleEndian, u32::MAX)); + self.contexts.push(U32::new(LittleEndian, context)); + self.handlers.push(U32::new( LittleEndian, offset.checked_add(start_offset).unwrap(), )); @@ -176,12 +176,12 @@ impl ExceptionTableBuilder { // Omit empty callsites for compactness. if end_idx > start_idx { - self.ranges.push(U32Bytes::new(LittleEndian, end_idx)); - self.frame_offsets.push(U32Bytes::new( + self.ranges.push(U32::new(LittleEndian, end_idx)); + self.frame_offsets.push(U32::new( LittleEndian, call_site.frame_offset.unwrap_or(u32::MAX), )); - self.callsites.push(U32Bytes::new(LittleEndian, ret_addr)); + self.callsites.push(U32::new(LittleEndian, ret_addr)); } } @@ -224,12 +224,12 @@ impl ExceptionTableBuilder { /// [`ExceptionTableBuilder::serialize`]. #[derive(Clone, Debug)] pub struct ExceptionTable<'a> { - callsites: &'a [U32Bytes], - ranges: &'a [U32Bytes], - frame_offsets: &'a [U32Bytes], - tags: &'a [U32Bytes], - contexts: &'a [U32Bytes], - handlers: &'a [U32Bytes], + callsites: &'a [U32], + ranges: &'a [U32], + frame_offsets: &'a [U32], + tags: &'a [U32], + contexts: &'a [U32], + handlers: &'a [U32], } /// Wasmtime exception table item, after parsing. @@ -256,30 +256,27 @@ impl<'a> ExceptionTable<'a> { pub fn parse(data: &'a [u8]) -> Result> { let mut data = Bytes(data); let callsite_count = data - .read::>() + .read::>() .map_err(|_| format_err!("Unable to read callsite count prefix"))?; let callsite_count = usize::try_from(callsite_count.get(LittleEndian))?; let handler_count = data - .read::>() + .read::>() .map_err(|_| format_err!("Unable to read handler count prefix"))?; let handler_count = usize::try_from(handler_count.get(LittleEndian))?; let (callsites, data) = - object::slice_from_bytes::>(data.0, callsite_count) + object::slice_from_bytes::>(data.0, callsite_count) .map_err(|_| format_err!("Unable to read callsites slice"))?; let (frame_offsets, data) = - object::slice_from_bytes::>(data, callsite_count) + object::slice_from_bytes::>(data, callsite_count) .map_err(|_| format_err!("Unable to read frame_offsets slice"))?; - let (ranges, data) = - object::slice_from_bytes::>(data, callsite_count) - .map_err(|_| format_err!("Unable to read ranges slice"))?; - let (tags, data) = object::slice_from_bytes::>(data, handler_count) + let (ranges, data) = object::slice_from_bytes::>(data, callsite_count) + .map_err(|_| format_err!("Unable to read ranges slice"))?; + let (tags, data) = object::slice_from_bytes::>(data, handler_count) .map_err(|_| format_err!("Unable to read tags slice"))?; - let (contexts, data) = - object::slice_from_bytes::>(data, handler_count) - .map_err(|_| format_err!("Unable to read contexts slice"))?; - let (handlers, data) = - object::slice_from_bytes::>(data, handler_count) - .map_err(|_| format_err!("Unable to read handlers slice"))?; + let (contexts, data) = object::slice_from_bytes::>(data, handler_count) + .map_err(|_| format_err!("Unable to read contexts slice"))?; + let (handlers, data) = object::slice_from_bytes::>(data, handler_count) + .map_err(|_| format_err!("Unable to read handlers slice"))?; if !data.is_empty() { bail!("Unexpected data at end of serialized exception table"); @@ -362,9 +359,9 @@ impl<'a> ExceptionTable<'a> { &self, idx: usize, ) -> ( - &[U32Bytes], - &[U32Bytes], - &[U32Bytes], + &[U32], + &[U32], + &[U32], ) { let end_idx = self.ranges[idx].get(LittleEndian); let start_idx = if idx > 0 { diff --git a/crates/wasi-preview1-component-adapter/build.rs b/crates/wasi-preview1-component-adapter/build.rs index e4b87e021333..2b1f7f95d0ef 100644 --- a/crates/wasi-preview1-component-adapter/build.rs +++ b/crates/wasi-preview1-component-adapter/build.rs @@ -239,7 +239,7 @@ fn build_raw_intrinsics() -> Vec { /// Like above this is still tricky, mainly around the production of the symbol /// table. fn build_archive(wasm: &[u8]) -> Vec { - use object::{U32Bytes, bytes_of, endian::BigEndian}; + use object::{U32, bytes_of, endian::BigEndian}; let mut archive = Vec::new(); archive.extend_from_slice(&object::archive::MAGIC); @@ -265,9 +265,9 @@ fn build_archive(wasm: &[u8]) -> Vec { ]; let mut symbol_table = Vec::new(); - symbol_table.extend_from_slice(bytes_of(&U32Bytes::new(BigEndian, syms.len() as u32))); + symbol_table.extend_from_slice(bytes_of(&U32::new(BigEndian, syms.len() as u32))); for _ in syms.iter() { - symbol_table.extend_from_slice(bytes_of(&U32Bytes::new(BigEndian, 0))); + symbol_table.extend_from_slice(bytes_of(&U32::new(BigEndian, 0))); } for s in syms.iter() { symbol_table.extend_from_slice(&std::ffi::CString::new(*s).unwrap().into_bytes_with_nul()); @@ -298,7 +298,7 @@ fn build_archive(wasm: &[u8]) -> Vec { let member_offset = archive.len(); for (index, _) in syms.iter().enumerate() { let index = index + 1; - archive[symtab_offset + (index * 4)..][..4].copy_from_slice(bytes_of(&U32Bytes::new( + archive[symtab_offset + (index * 4)..][..4].copy_from_slice(bytes_of(&U32::new( BigEndian, member_offset.try_into().unwrap(), ))); diff --git a/crates/wasmtime/src/runtime/code_memory.rs b/crates/wasmtime/src/runtime/code_memory.rs index 07fe1b10ecf2..5c972a3547af 100644 --- a/crates/wasmtime/src/runtime/code_memory.rs +++ b/crates/wasmtime/src/runtime/code_memory.rs @@ -6,7 +6,7 @@ use crate::runtime::vm::MmapVec; use alloc::sync::Arc; use core::ops::Range; use object::read::elf::SectionTable; -use object::{LittleEndian, SectionIndex, U32Bytes}; +use object::{LittleEndian, SectionIndex, U32}; use object::{ elf::{FileHeader64, SectionHeader64}, endian::Endianness, @@ -378,7 +378,7 @@ impl CodeMemory { } let ends = self.wasm_bytecode_ends(); let count = ends.len() / core::mem::size_of::(); - let (ends, _) = object::slice_from_bytes::>(ends, count) + let (ends, _) = object::slice_from_bytes::>(ends, count) .expect("Invalid alignment of `ends` section"); let index = usize::try_from(index.as_u32()).unwrap(); Some(usize::try_from(ends[index].get(LittleEndian)).unwrap()) diff --git a/crates/wasmtime/src/runtime/native_debug.rs b/crates/wasmtime/src/runtime/native_debug.rs index e241b6617851..c3045db3424c 100644 --- a/crates/wasmtime/src/runtime/native_debug.rs +++ b/crates/wasmtime/src/runtime/native_debug.rs @@ -5,7 +5,7 @@ use object::endian::{BigEndian, Endian, Endianness, LittleEndian}; use object::read::elf::{FileHeader, SectionHeader}; use object::{ File, NativeEndian as NE, Object, ObjectSection, ObjectSymbol, RelocationEncoding, - RelocationKind, RelocationTarget, U64Bytes, + RelocationKind, RelocationTarget, U64, }; use wasmtime_environ::obj; @@ -67,7 +67,7 @@ fn relocate_dwarf_sections(bytes: &mut [u8], code_region: (*const u8, usize)) -> let (loc, _) = offset .try_into() .ok() - .and_then(|offset| object::from_bytes_mut::>(&mut bytes[offset..]).ok()) + .and_then(|offset| object::from_bytes_mut::>(&mut bytes[offset..]).ok()) .ok_or_else(|| format_err!("invalid dwarf relocations"))?; loc.set(NE, value); } diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 03bad6174cb5..ffcf8352de36 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -7048,6 +7048,12 @@ user-id = 359 # Sean McArthur (seanmonstar) start = "2019-06-10" end = "2026-10-10" +[[trusted.object]] +criteria = "safe-to-deploy" +user-id = 4415 # Philip Craig (philipc) +start = "2019-04-26" +end = "2027-03-30" + [[trusted.once_cell_polyfill]] criteria = "safe-to-deploy" user-id = 6743 # Ed Page (epage) diff --git a/supply-chain/config.toml b/supply-chain/config.toml index 1fada627e429..2be4b813f50e 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -384,10 +384,6 @@ criteria = "safe-to-deploy" version = "0.4.6" criteria = "safe-to-deploy" -[[exemptions.object]] -version = "0.36.0" -criteria = "safe-to-deploy" - [[exemptions.once_cell]] version = "1.12.0" criteria = "safe-to-deploy" diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 64280231235d..d3e6b7d39183 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -1302,6 +1302,20 @@ user-id = 359 user-login = "seanmonstar" user-name = "Sean McArthur" +[[publisher.object]] +version = "0.36.5" +when = "2024-10-04" +user-id = 4415 +user-login = "philipc" +user-name = "Philip Craig" + +[[publisher.object]] +version = "0.39.0" +when = "2026-03-29" +user-id = 4415 +user-login = "philipc" +user-name = "Philip Craig" + [[publisher.once_cell_polyfill]] version = "1.70.1" when = "2025-05-22"