From b16fceb9d3688d20bf6658403d082ddb42d53829 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Tue, 13 Nov 2018 19:42:36 -0800 Subject: [PATCH] Added emscripten abort function # Conflicts: # src/linkers/emscripten/mod.rs --- src/linkers/emscripten/abort.rs | 9 +++++++++ src/linkers/emscripten/mod.rs | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 src/linkers/emscripten/abort.rs diff --git a/src/linkers/emscripten/abort.rs b/src/linkers/emscripten/abort.rs new file mode 100644 index 000000000..bb4cfa117 --- /dev/null +++ b/src/linkers/emscripten/abort.rs @@ -0,0 +1,9 @@ + +use crate::webassembly::Instance; +use std::process; + + +pub extern "C" fn abort(_code: i32, _instance: &Instance) { + process::abort(); + // abort!("Aborted") +} \ No newline at end of file diff --git a/src/linkers/emscripten/mod.rs b/src/linkers/emscripten/mod.rs index 0d55f87f6..5994b4c77 100644 --- a/src/linkers/emscripten/mod.rs +++ b/src/linkers/emscripten/mod.rs @@ -2,11 +2,14 @@ use crate::webassembly::{ImportObject, ImportValue}; mod printf; mod putchar; +mod abort; pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> { let mut import_object = ImportObject::new(); import_object.set("env", "printf", ImportValue::Func(printf::printf as *const u8)); import_object.set("env", "putchar", ImportValue::Func(putchar::putchar as *const u8)); + import_object.set("env", "abort", ImportValue::Func(abort::abort as *const u8)); + import_object.set("env", "_abort", ImportValue::Func(abort::abort as *const u8)); import_object }