Skip to content

Commit a2cc11f

Browse files
Update object to 0.39.0 (#12866)
* Update object to 0.39.0 * Add vets for `object` --------- Co-authored-by: Alex Crichton <alex@alexcrichton.com>
1 parent 856fb27 commit a2cc11f

17 files changed

Lines changed: 168 additions & 165 deletions

File tree

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ backtrace = "0.3.75"
368368
bumpalo = "3.20.0"
369369
mutatis = {version = "0.3.2", features = ["alloc"] }
370370
cc = "1.2.41"
371-
object = { version = "0.38.1", default-features = false, features = ['read_core', 'elf'] }
371+
object = { version = "0.39.0", default-features = false, features = ['read_core', 'elf'] }
372372
gimli = { version = "0.33.0", default-features = false, features = ['read'] }
373373
addr2line = { version = "0.26.0", default-features = false }
374374
anyhow = { version = "1.0.100", default-features = false }

crates/environ/src/address_map.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Data structures to provide transformation of the source
22
3-
use object::{Bytes, LittleEndian, U32Bytes};
3+
use object::{Bytes, LittleEndian, U32};
44
use serde_derive::{Deserialize, Serialize};
55

66
/// Single source location to generated address mapping.
@@ -63,18 +63,16 @@ impl Default for FilePos {
6363

6464
/// Parse an `ELF_WASMTIME_ADDRMAP` section, returning the slice of code offsets
6565
/// and the slice of associated file positions for each offset.
66-
fn parse_address_map(
67-
section: &[u8],
68-
) -> Option<(&[U32Bytes<LittleEndian>], &[U32Bytes<LittleEndian>])> {
66+
fn parse_address_map(section: &[u8]) -> Option<(&[U32<LittleEndian>], &[U32<LittleEndian>])> {
6967
let mut section = Bytes(section);
7068
// NB: this matches the encoding written by `append_to` in the
7169
// `compile::address_map` module.
72-
let count = section.read::<U32Bytes<LittleEndian>>().ok()?;
70+
let count = section.read::<U32<LittleEndian>>().ok()?;
7371
let count = usize::try_from(count.get(LittleEndian)).ok()?;
7472
let (offsets, section) =
75-
object::slice_from_bytes::<U32Bytes<LittleEndian>>(section.0, count).ok()?;
73+
object::slice_from_bytes::<U32<LittleEndian>>(section.0, count).ok()?;
7674
let (positions, section) =
77-
object::slice_from_bytes::<U32Bytes<LittleEndian>>(section, count).ok()?;
75+
object::slice_from_bytes::<U32<LittleEndian>>(section, count).ok()?;
7876
debug_assert!(section.is_empty());
7977
Some((offsets, positions))
8078
}

crates/environ/src/compile/address_map.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::InstructionAddressMap;
44
use crate::obj::ELF_WASMTIME_ADDRMAP;
55
use crate::prelude::*;
66
use object::write::{Object, StandardSegment};
7-
use object::{LittleEndian, SectionKind, U32Bytes};
7+
use object::{LittleEndian, SectionKind, U32};
88
use std::ops::Range;
99

1010
/// Builder for the address map section of a wasmtime compilation image.
@@ -14,8 +14,8 @@ use std::ops::Range;
1414
/// into an `Object`.
1515
#[derive(Default)]
1616
pub struct AddressMapSection {
17-
offsets: Vec<U32Bytes<LittleEndian>>,
18-
positions: Vec<U32Bytes<LittleEndian>>,
17+
offsets: Vec<U32<LittleEndian>>,
18+
positions: Vec<U32<LittleEndian>>,
1919
last_offset: u32,
2020
}
2121

@@ -58,8 +58,8 @@ impl AddressMapSection {
5858
}
5959
last_srcloc = Some(srcloc);
6060

61-
self.offsets.push(U32Bytes::new(LittleEndian, pos));
62-
self.positions.push(U32Bytes::new(LittleEndian, srcloc));
61+
self.offsets.push(U32::new(LittleEndian, pos));
62+
self.positions.push(U32::new(LittleEndian, srcloc));
6363
}
6464
self.last_offset = func_end;
6565
}

crates/environ/src/compile/frame_table.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
FrameInstPos, FrameStackShape, FrameStateSlotOffset, FrameTableDescriptorIndex, FrameValType,
1313
FuncKey, WasmHeapTopType, WasmValType, prelude::*,
1414
};
15-
use object::{LittleEndian, U32Bytes};
15+
use object::{LittleEndian, U32};
1616
use std::collections::{HashMap, hash_map::Entry};
1717

1818
/// Builder for a stackslot descriptor.
@@ -230,19 +230,19 @@ impl FrameStateSlotBuilder {
230230
pub struct FrameTableBuilder {
231231
/// (offset, length) pairs into `frame_descriptor_data`, indexed
232232
/// by frame descriptor number.
233-
frame_descriptor_ranges: Vec<U32Bytes<LittleEndian>>,
233+
frame_descriptor_ranges: Vec<U32<LittleEndian>>,
234234
frame_descriptor_data: Vec<u8>,
235235

236236
/// Offset from frame slot up to FP for each frame descriptor.
237-
frame_descriptor_fp_offsets: Vec<U32Bytes<LittleEndian>>,
237+
frame_descriptor_fp_offsets: Vec<U32<LittleEndian>>,
238238

239-
progpoint_pcs: Vec<U32Bytes<LittleEndian>>,
240-
progpoint_descriptor_offsets: Vec<U32Bytes<LittleEndian>>,
241-
progpoint_descriptor_data: Vec<U32Bytes<LittleEndian>>,
239+
progpoint_pcs: Vec<U32<LittleEndian>>,
240+
progpoint_descriptor_offsets: Vec<U32<LittleEndian>>,
241+
progpoint_descriptor_data: Vec<U32<LittleEndian>>,
242242

243-
breakpoint_pcs: Vec<U32Bytes<LittleEndian>>,
244-
breakpoint_patch_offsets: Vec<U32Bytes<LittleEndian>>,
245-
breakpoint_patch_data_ends: Vec<U32Bytes<LittleEndian>>,
243+
breakpoint_pcs: Vec<U32<LittleEndian>>,
244+
breakpoint_patch_offsets: Vec<U32<LittleEndian>>,
245+
breakpoint_patch_data_ends: Vec<U32<LittleEndian>>,
246246

247247
breakpoint_patch_data: Vec<u8>,
248248
}
@@ -264,11 +264,11 @@ impl FrameTableBuilder {
264264
u32::try_from(self.frame_descriptor_fp_offsets.len()).unwrap(),
265265
);
266266
self.frame_descriptor_fp_offsets
267-
.push(U32Bytes::new(LittleEndian, slot_to_fp_offset));
267+
.push(U32::new(LittleEndian, slot_to_fp_offset));
268268
self.frame_descriptor_ranges
269-
.push(U32Bytes::new(LittleEndian, start));
269+
.push(U32::new(LittleEndian, start));
270270
self.frame_descriptor_ranges
271-
.push(U32Bytes::new(LittleEndian, end));
271+
.push(U32::new(LittleEndian, end));
272272

273273
index
274274
}
@@ -295,34 +295,32 @@ impl FrameTableBuilder {
295295
}
296296

297297
let start = u32::try_from(self.progpoint_descriptor_data.len()).unwrap();
298-
self.progpoint_pcs
299-
.push(U32Bytes::new(LittleEndian, pc_and_pos));
298+
self.progpoint_pcs.push(U32::new(LittleEndian, pc_and_pos));
300299
self.progpoint_descriptor_offsets
301-
.push(U32Bytes::new(LittleEndian, start));
300+
.push(U32::new(LittleEndian, start));
302301

303302
for (i, &(wasm_pc, frame_descriptor, stack_shape)) in frames.iter().enumerate() {
304303
debug_assert!(wasm_pc < 0x8000_0000);
305304
let not_last = i < (frames.len() - 1);
306305
let wasm_pc = wasm_pc | if not_last { 0x8000_0000 } else { 0 };
307306
self.progpoint_descriptor_data
308-
.push(U32Bytes::new(LittleEndian, wasm_pc));
307+
.push(U32::new(LittleEndian, wasm_pc));
309308
self.progpoint_descriptor_data
310-
.push(U32Bytes::new(LittleEndian, frame_descriptor.0));
309+
.push(U32::new(LittleEndian, frame_descriptor.0));
311310
self.progpoint_descriptor_data
312-
.push(U32Bytes::new(LittleEndian, stack_shape.0));
311+
.push(U32::new(LittleEndian, stack_shape.0));
313312
}
314313
}
315314

316315
/// Add one breakpoint patch.
317316
pub fn add_breakpoint_patch(&mut self, wasm_pc: u32, patch_start_native_pc: u32, patch: &[u8]) {
318-
self.breakpoint_pcs
319-
.push(U32Bytes::new(LittleEndian, wasm_pc));
317+
self.breakpoint_pcs.push(U32::new(LittleEndian, wasm_pc));
320318
self.breakpoint_patch_offsets
321-
.push(U32Bytes::new(LittleEndian, patch_start_native_pc));
319+
.push(U32::new(LittleEndian, patch_start_native_pc));
322320
self.breakpoint_patch_data.extend(patch.iter().cloned());
323321
let end = u32::try_from(self.breakpoint_patch_data.len()).unwrap();
324322
self.breakpoint_patch_data_ends
325-
.push(U32Bytes::new(LittleEndian, end));
323+
.push(U32::new(LittleEndian, end));
326324
}
327325

328326
/// Serialize the framd-table data section, taking a closure to

crates/environ/src/compile/stack_maps.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::obj::ELF_WASMTIME_STACK_MAP;
22
use crate::prelude::*;
33
use cranelift_bitset::CompoundBitSet;
44
use object::write::{Object, StandardSegment};
5-
use object::{LittleEndian, SectionKind, U32Bytes};
5+
use object::{LittleEndian, SectionKind, U32};
66

77
/// Builder for the `ELF_WASMTIME_STACK_MAP` section in compiled executables.
88
///
@@ -71,9 +71,9 @@ use object::{LittleEndian, SectionKind, U32Bytes};
7171
/// more.
7272
#[derive(Default)]
7373
pub struct StackMapSection {
74-
pcs: Vec<U32Bytes<LittleEndian>>,
75-
pointers_to_stack_map: Vec<U32Bytes<LittleEndian>>,
76-
stack_map_data: Vec<U32Bytes<LittleEndian>>,
74+
pcs: Vec<U32<LittleEndian>>,
75+
pointers_to_stack_map: Vec<U32<LittleEndian>>,
76+
stack_map_data: Vec<U32<LittleEndian>>,
7777
last_offset: u32,
7878
}
7979

@@ -103,16 +103,15 @@ impl StackMapSection {
103103
}
104104

105105
// Record parallel entries in `pcs`/`pointers_to_stack_map`.
106-
self.pcs.push(U32Bytes::new(LittleEndian, code_offset));
107-
self.pointers_to_stack_map.push(U32Bytes::new(
106+
self.pcs.push(U32::new(LittleEndian, code_offset));
107+
self.pointers_to_stack_map.push(U32::new(
108108
LittleEndian,
109109
u32::try_from(self.stack_map_data.len()).unwrap(),
110110
));
111111

112112
// The frame data starts with the frame size and is then followed by
113113
// `offsets` represented as a bit set.
114-
self.stack_map_data
115-
.push(U32Bytes::new(LittleEndian, frame_size));
114+
self.stack_map_data.push(U32::new(LittleEndian, frame_size));
116115

117116
let mut bits = CompoundBitSet::<u32>::default();
118117
for offset in frame_offsets {
@@ -121,10 +120,9 @@ impl StackMapSection {
121120
}
122121
let count = bits.iter_scalars().count();
123122
self.stack_map_data
124-
.push(U32Bytes::new(LittleEndian, count as u32));
123+
.push(U32::new(LittleEndian, count as u32));
125124
for scalar in bits.iter_scalars() {
126-
self.stack_map_data
127-
.push(U32Bytes::new(LittleEndian, scalar.0));
125+
self.stack_map_data.push(U32::new(LittleEndian, scalar.0));
128126
}
129127
}
130128

crates/environ/src/compile/trap_encoding.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::TrapInformation;
22
use crate::obj::ELF_WASMTIME_TRAPS;
33
use crate::prelude::*;
44
use object::write::{Object, StandardSegment};
5-
use object::{LittleEndian, SectionKind, U32Bytes};
5+
use object::{LittleEndian, SectionKind, U32};
66
use std::ops::Range;
77

88
/// A helper structure to build the custom-encoded section of a wasmtime
@@ -13,7 +13,7 @@ use std::ops::Range;
1313
/// `lookup_trap_code` below with the resulting section.
1414
#[derive(Default)]
1515
pub struct TrapEncodingBuilder {
16-
offsets: Vec<U32Bytes<LittleEndian>>,
16+
offsets: Vec<U32<LittleEndian>>,
1717
traps: Vec<u8>,
1818
last_offset: u32,
1919
}
@@ -45,7 +45,7 @@ impl TrapEncodingBuilder {
4545
for info in traps {
4646
let pos = func_start + info.code_offset;
4747
assert!(pos >= self.last_offset);
48-
self.offsets.push(U32Bytes::new(LittleEndian, pos));
48+
self.offsets.push(U32::new(LittleEndian, pos));
4949
self.traps.push(info.trap_code as u8);
5050
self.last_offset = pos;
5151
}

0 commit comments

Comments
 (0)