mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
Factor common string out to a constant.
This commit is contained in:
@@ -11,6 +11,8 @@ pub struct FuncTrampoline {
|
|||||||
ctx: Context,
|
ctx: Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const FUNCTION_SECTION: &'static str = "wasmer_trampoline";
|
||||||
|
|
||||||
impl FuncTrampoline {
|
impl FuncTrampoline {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -45,7 +47,7 @@ impl FuncTrampoline {
|
|||||||
let trampoline_func = module.add_function("", trampoline_ty, Some(Linkage::External));
|
let trampoline_func = module.add_function("", trampoline_ty, Some(Linkage::External));
|
||||||
trampoline_func
|
trampoline_func
|
||||||
.as_global_value()
|
.as_global_value()
|
||||||
.set_section("wasmer_trampoline");
|
.set_section(FUNCTION_SECTION);
|
||||||
generate_trampoline(trampoline_func, ty, &self.ctx, &intrinsics)?;
|
generate_trampoline(trampoline_func, ty, &self.ctx, &intrinsics)?;
|
||||||
|
|
||||||
// TODO: remove debugging
|
// TODO: remove debugging
|
||||||
@@ -84,7 +86,8 @@ impl FuncTrampoline {
|
|||||||
|
|
||||||
let mut bytes = vec![];
|
let mut bytes = vec![];
|
||||||
for section in object.get_sections() {
|
for section in object.get_sections() {
|
||||||
if section.get_name().map(std::ffi::CStr::to_bytes) == Some(b"wasmer_trampoline") {
|
if section.get_name().map(std::ffi::CStr::to_bytes) == Some(FUNCTION_SECTION.as_bytes())
|
||||||
|
{
|
||||||
bytes.extend(section.get_contents().to_vec());
|
bytes.extend(section.get_contents().to_vec());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user