Skip to content

Commit

Permalink
read/wasm: handle tag sections
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Mar 20, 2024
1 parent 25fdef3 commit 6b4adc8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/read/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ enum SectionId {
Code = 10,
Data = 11,
DataCount = 12,
Tag = 13,
}
// Update this constant when adding new section id:
const MAX_SECTION_ID: usize = SectionId::DataCount as usize;
const MAX_SECTION_ID: usize = SectionId::Tag as usize;

/// A WebAssembly object file.
#[derive(Debug)]
Expand Down Expand Up @@ -314,6 +315,9 @@ impl<'data, R: ReadRef<'data>> WasmFile<'data, R> {
wp::Payload::DataCountSection { range, .. } => {
file.add_section(SectionId::DataCount, range, "");
}
wp::Payload::TagSection(section) => {
file.add_section(SectionId::Tag, section.range(), "");
}
wp::Payload::CustomSection(section) => {
let name = section.name();
let size = section.data().len();
Expand Down Expand Up @@ -691,6 +695,7 @@ impl<'data, 'file, R: ReadRef<'data>> ObjectSection<'data> for WasmSection<'data
SectionId::Code => "<code>",
SectionId::Data => "<data>",
SectionId::DataCount => "<data_count>",
SectionId::Tag => "<tag>",
})
}

Expand Down Expand Up @@ -723,6 +728,7 @@ impl<'data, 'file, R: ReadRef<'data>> ObjectSection<'data> for WasmSection<'data
SectionId::Code => SectionKind::Text,
SectionId::Data => SectionKind::Data,
SectionId::DataCount => SectionKind::UninitializedData,
SectionId::Tag => SectionKind::Data,
}
}

Expand Down

0 comments on commit 6b4adc8

Please sign in to comment.