File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,16 +61,7 @@ impl EpochCheckSection {
6161 SectionKind :: ReadOnlyData ,
6262 ) ;
6363
64- // Append length.
65- obj. append_section_data (
66- section,
67- & u32:: try_from ( self . return_offsets . len ( ) )
68- . unwrap ( )
69- . to_le_bytes ( ) ,
70- 1 ,
71- ) ;
72-
7364 // Append offsets.
74- obj. append_section_data ( section, object:: bytes_of_slice ( & self . return_offsets ) , 1 ) ;
65+ obj. append_section_data ( section, object:: bytes_of_slice ( & self . return_offsets ) , 4 ) ;
7566 }
7667}
Original file line number Diff line number Diff line change @@ -104,17 +104,13 @@ pub const ELF_WASMTIME_TRAPS: &str = ".wasmtime.traps";
104104/// The contents are examined at runtime by the signal handler to determine
105105/// whether a segfault is due to an epoch ending (vs. a legitimate crash).
106106///
107- /// This section has a custom binary encoding:
107+ /// This section is a sorted array of 32-bit unsigned little-endian integers
108+ /// which represent offsets from the beginning of the text section to the
109+ /// instruction following the load which triggers epoch-ending segfaults. TODO:
110+ /// We may point elsewhere if it's more useful to the signal handler. Be careful
111+ /// if this could end up pointing off the end of the text section.
108112///
109- /// * The section starts with a 32-bit little-endian integer which tell the
110- /// number of items in the following array.
111- /// * Next comes a sorted array of 32-bit unsigned little-endian integers which
112- /// represent offsets from the beginning of the text section to the
113- /// instruction following the load which triggers epoch-ending segfaults.
114- /// TODO: We may point elsewhere if it's more useful to the signal handler. Be
115- /// careful if this could end up pointing off the end of the text section.
116- ///
117- /// The 32-bit encodings herein mean that >=4gb text sections are not supported.
113+ /// The 32-bit encodings herein mean >=4gb text sections are not supported.
118114pub const ELF_WASMTIME_EPOCH_CHECKS : & str = ".wasmtime.epochchecks" ;
119115
120116/// A custom binary-encoded section of the wasmtime compilation
Original file line number Diff line number Diff line change @@ -35,14 +35,7 @@ fn epoch_check_offsets() {
3535 "{ELF_WASMTIME_EPOCH_CHECKS} section should be present"
3636 ) ) ;
3737 let data = section. data ( ) . unwrap ( ) ;
38- assert ! ( data. len( ) >= 4 , "section should at least contain a count" ) ;
39- let count = u32:: from_le_bytes ( data[ ..4 ] . try_into ( ) . unwrap ( ) ) as usize ;
40- assert_eq ! (
41- data. len( ) ,
42- 4 + count * 4 ,
43- "section should be the right size to hold the offsets it claims to contain"
44- ) ;
45- let offsets: Vec < u32 > = data[ 4 ..]
38+ let offsets: Vec < u32 > = data
4639 . chunks_exact ( 4 )
4740 . map ( |c| u32:: from_le_bytes ( c. try_into ( ) . unwrap ( ) ) )
4841 . collect ( ) ;
You can’t perform that action at this time.
0 commit comments