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

Commit 39a5658

Browse files
Pat Hickeyfroydnj
authored andcommitted
move faerie-related code from table to output
1 parent 4bfef0a commit 39a5658

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

lucetc/src/output.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::Error;
22
use crate::name::Name;
33
use crate::stack_probe;
4-
use crate::table::{link_tables, TABLE_SYM};
4+
use crate::table::{TABLE_SYM, TABLE_REF_SIZE};
55
use crate::traps::{translate_trapcode, trap_sym_for_func};
66
use byteorder::{LittleEndian, WriteBytesExt};
77
use cranelift_codegen::{ir, isa, binemit::TrapSink};
@@ -90,7 +90,7 @@ impl ObjectFile {
9090

9191
obj.write_trap_tables(&trap_manifest)?;
9292
obj.write_function_manifest(function_manifest.as_slice())?;
93-
link_tables(table_manifest.as_slice(), &mut obj.artifact)?;
93+
obj.link_tables(table_manifest.as_slice())?;
9494

9595
// And now write out the actual structure tying together all the data in this module.
9696
write_module(
@@ -251,6 +251,18 @@ impl ObjectFile {
251251
Ok(())
252252
}
253253

254+
fn link_tables(&mut self, tables: &[Name]) -> Result<(), Error> {
255+
for (idx, table) in tables.iter().enumerate() {
256+
self.artifact.link(Link {
257+
from: TABLE_SYM,
258+
to: table.symbol(),
259+
at: (TABLE_REF_SIZE * idx) as u64,
260+
})
261+
.map_err(|source| Error::Failure(source, "Table error".to_owned()))?;
262+
}
263+
Ok(())
264+
}
265+
254266
pub fn write<P: AsRef<Path>>(&self, path: P) -> Result<(), Error> {
255267
let _ = path.as_ref().file_name().ok_or(|| {
256268
let message = format!("Path must be filename {:?}", path.as_ref());

lucetc/src/table.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use byteorder::{LittleEndian, WriteBytesExt};
77
use cranelift_codegen::entity::EntityRef;
88
use cranelift_module::{Backend as ClifBackend, DataContext, Module as ClifModule};
99
use cranelift_wasm::{TableElementType, TableIndex};
10-
use faerie::{Artifact, Link};
1110
use std::io::Cursor;
1211

1312
/// This symbol will be used to reference the `tables` field in `Module` - a sequence of tables.
@@ -51,18 +50,6 @@ fn table_elements(decl: &TableDecl<'_>) -> Result<Vec<Elem>, Error> {
5150
Ok(elems)
5251
}
5352

54-
pub fn link_tables(tables: &[Name], obj: &mut Artifact) -> Result<(), Error> {
55-
for (idx, table) in tables.iter().enumerate() {
56-
obj.link(Link {
57-
from: TABLE_SYM,
58-
to: table.symbol(),
59-
at: (TABLE_REF_SIZE * idx) as u64,
60-
})
61-
.map_err(|source| Error::Failure(source, "Table error".to_owned()))?;
62-
}
63-
Ok(())
64-
}
65-
6653
pub fn write_table_data<B: ClifBackend>(
6754
clif_module: &mut ClifModule<B>,
6855
decls: &ModuleDecls<'_>,

0 commit comments

Comments
 (0)