Address concerns in pullrequests.
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -489,6 +489,7 @@ dependencies = [
|
|||||||
name = "cranelift-object"
|
name = "cranelift-object"
|
||||||
version = "0.64.0"
|
version = "0.64.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"cranelift-module",
|
"cranelift-module",
|
||||||
"object",
|
"object",
|
||||||
|
|||||||
@@ -211,10 +211,12 @@ impl Backend for FaerieBackend {
|
|||||||
ref data_decls,
|
ref data_decls,
|
||||||
ref function_relocs,
|
ref function_relocs,
|
||||||
ref data_relocs,
|
ref data_relocs,
|
||||||
section: ref datasection,
|
ref custom_segment_section,
|
||||||
} = data_ctx.description();
|
} = data_ctx.description();
|
||||||
|
|
||||||
assert!(datasection.is_none(), "Custom sections not supported");
|
if let Some((segment, section)) = custom_segment_section {
|
||||||
|
return Err(cranelift_module::ModuleError::Backend(anyhow::anyhow!("Custom section not supported by cranelift-faerie: `{}:{}`", segment, section)));
|
||||||
|
}
|
||||||
|
|
||||||
for &(offset, id) in function_relocs {
|
for &(offset, id) in function_relocs {
|
||||||
let to = &namespace.get_function_decl(&function_decls[id]).name;
|
let to = &namespace.get_function_decl(&function_decls[id]).name;
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
use cranelift_codegen::binemit::{Addend, CodeOffset};
|
use cranelift_codegen::binemit::{Addend, CodeOffset};
|
||||||
use cranelift_codegen::entity::PrimaryMap;
|
use cranelift_codegen::entity::PrimaryMap;
|
||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
|
use std::borrow::ToOwned;
|
||||||
use std::boxed::Box;
|
use std::boxed::Box;
|
||||||
|
use std::string::String;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
/// This specifies how data is to be initialized.
|
/// This specifies how data is to be initialized.
|
||||||
@@ -47,7 +49,7 @@ pub struct DataDescription {
|
|||||||
/// Data addresses to write at specified offsets.
|
/// Data addresses to write at specified offsets.
|
||||||
pub data_relocs: Vec<(CodeOffset, ir::GlobalValue, Addend)>,
|
pub data_relocs: Vec<(CodeOffset, ir::GlobalValue, Addend)>,
|
||||||
/// Object file section
|
/// Object file section
|
||||||
pub section: Option<(std::string::String, std::string::String)>,
|
pub custom_segment_section: Option<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is to data objects what cranelift_codegen::Context is to functions.
|
/// This is to data objects what cranelift_codegen::Context is to functions.
|
||||||
@@ -65,7 +67,7 @@ impl DataContext {
|
|||||||
data_decls: PrimaryMap::new(),
|
data_decls: PrimaryMap::new(),
|
||||||
function_relocs: vec![],
|
function_relocs: vec![],
|
||||||
data_relocs: vec![],
|
data_relocs: vec![],
|
||||||
section: None,
|
custom_segment_section: None,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,10 +96,10 @@ impl DataContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Override the segment/section for data, only supported on Object backend
|
/// Override the segment/section for data, only supported on Object backend
|
||||||
pub fn set_section(&mut self, seg: &str, sec: &str) {
|
pub fn set_segment_section(&mut self, seg: &str, sec: &str) {
|
||||||
self.description.section = Some((
|
self.description.custom_segment_section = Some((
|
||||||
std::string::String::from(seg),
|
seg.to_owned(),
|
||||||
std::string::String::from(sec),
|
sec.to_owned(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ cranelift-module = { path = "../module", version = "0.64.0" }
|
|||||||
cranelift-codegen = { path = "../codegen", version = "0.64.0", default-features = false, features = ["std"] }
|
cranelift-codegen = { path = "../codegen", version = "0.64.0", default-features = false, features = ["std"] }
|
||||||
object = { version = "0.18", default-features = false, features = ["write"] }
|
object = { version = "0.18", default-features = false, features = ["write"] }
|
||||||
target-lexicon = "0.10"
|
target-lexicon = "0.10"
|
||||||
|
anyhow = "1.0"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
maintenance = { status = "experimental" }
|
maintenance = { status = "experimental" }
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ impl Backend for ObjectBackend {
|
|||||||
ref data_decls,
|
ref data_decls,
|
||||||
ref function_relocs,
|
ref function_relocs,
|
||||||
ref data_relocs,
|
ref data_relocs,
|
||||||
section: ref datasection,
|
ref custom_segment_section,
|
||||||
} = data_ctx.description();
|
} = data_ctx.description();
|
||||||
|
|
||||||
let reloc_size = match self.isa.triple().pointer_width().unwrap() {
|
let reloc_size = match self.isa.triple().pointer_width().unwrap() {
|
||||||
@@ -265,7 +265,7 @@ impl Backend for ObjectBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let symbol = self.data_objects[data_id].unwrap();
|
let symbol = self.data_objects[data_id].unwrap();
|
||||||
let section = if datasection.is_none() {
|
let section = if custom_segment_section.is_none() {
|
||||||
let section_kind = if let Init::Zeros { .. } = *init {
|
let section_kind = if let Init::Zeros { .. } = *init {
|
||||||
if tls {
|
if tls {
|
||||||
StandardSection::UninitializedTls
|
StandardSection::UninitializedTls
|
||||||
@@ -283,8 +283,10 @@ impl Backend for ObjectBackend {
|
|||||||
};
|
};
|
||||||
self.object.section_id(section_kind)
|
self.object.section_id(section_kind)
|
||||||
} else {
|
} else {
|
||||||
assert!(!tls, "Tls data cannot be in named section");
|
if tls {
|
||||||
let (seg, sec) = &datasection.as_ref().unwrap();
|
return Err(cranelift_module::ModuleError::Backend(anyhow::anyhow!("Custom section not supported for TLS")));
|
||||||
|
}
|
||||||
|
let (seg, sec) = &custom_segment_section.as_ref().unwrap();
|
||||||
self.object.add_section(
|
self.object.add_section(
|
||||||
seg.clone().into_bytes(),
|
seg.clone().into_bytes(),
|
||||||
sec.clone().into_bytes(),
|
sec.clone().into_bytes(),
|
||||||
|
|||||||
@@ -361,11 +361,9 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend {
|
|||||||
ref data_decls,
|
ref data_decls,
|
||||||
ref function_relocs,
|
ref function_relocs,
|
||||||
ref data_relocs,
|
ref data_relocs,
|
||||||
section: ref datasection,
|
custom_segment_section: _,
|
||||||
} = data.description();
|
} = data.description();
|
||||||
|
|
||||||
assert!(datasection.is_none(), "Custom sections not supported");
|
|
||||||
|
|
||||||
let size = init.size();
|
let size = init.size();
|
||||||
let storage = if writable {
|
let storage = if writable {
|
||||||
self.memory
|
self.memory
|
||||||
|
|||||||
Reference in New Issue
Block a user