Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Commit eca48fb

Browse files
review comments
1 parent 0ad737c commit eca48fb

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

lucet-module/src/version_info.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ pub struct VersionInfo {
1313
minor: u16,
1414
patch: u16,
1515
reserved: u16,
16+
/// `version_hash` is either all nulls or the first eight ascii characters of the git commit
17+
/// hash of wherever this Version is coming from. In the case of a compiled lucet module, this
18+
/// hash will come from the git commit that the lucetc producing it came from. In a runtime
19+
/// context, it will be the git commit of lucet-runtime built into the embedder.
20+
///
21+
/// The version hash will typically populated only in release builds, but may blank even in
22+
/// that case: if building from a packagd crate, or in a build environment that does not have
23+
/// "git" installed, `lucetc` and `lucet-runtime` will fall back to an empty hash.
1624
version_hash: [u8; 8],
1725
}
1826

lucetc/src/output.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::error::LucetcErrorKind;
22
use crate::function_manifest::{write_function_manifest, FUNCTION_MANIFEST_SYM};
33
use crate::name::Name;
4-
use crate::pointer::NATIVE_POINTER_SIZE;
54
use crate::stack_probe;
65
use crate::table::{link_tables, TABLE_SYM};
76
use crate::traps::write_trap_tables;
@@ -10,7 +9,9 @@ use cranelift_codegen::{ir, isa};
109
use cranelift_faerie::FaerieProduct;
1110
use faerie::{Artifact, Decl, Link};
1211
use failure::{format_err, Error, ResultExt};
13-
use lucet_module::{FunctionSpec, VersionInfo, LUCET_MODULE_SYM, MODULE_DATA_SYM};
12+
use lucet_module::{
13+
FunctionSpec, SerializedModule, VersionInfo, LUCET_MODULE_SYM, MODULE_DATA_SYM,
14+
};
1415
use std::collections::HashMap;
1516
use std::fs::File;
1617
use std::io::{Cursor, Write};
@@ -136,7 +137,7 @@ fn write_module(
136137
function_manifest_len: usize,
137138
obj: &mut Artifact,
138139
) -> Result<(), Error> {
139-
let mut native_data = Cursor::new(Vec::with_capacity(16 + NATIVE_POINTER_SIZE * 4));
140+
let mut native_data = Cursor::new(Vec::with_capacity(std::mem::size_of::<SerializedModule>()));
140141
obj.declare(LUCET_MODULE_SYM, Decl::data().global())
141142
.context(format!("declaring {}", LUCET_MODULE_SYM))?;
142143

0 commit comments

Comments
 (0)