use crate::{object_file, platform_detection::is_wasm, target_info::RustcTargetInfo};
pub fn create_binary_file(
target_info: &RustcTargetInfo,
target_triple: &str,
contents: &[u8],
symbol_name: &str,
) -> Option<Vec<u8>> {
if is_wasm(target_info) {
Some(create_wasm_file(target_info, contents))
} else {
object_file::create_metadata_file(target_info, target_triple, contents, symbol_name)
}
}
pub fn create_wasm_file(
target_info: &RustcTargetInfo,
contents: &[u8],
) -> Vec<u8> {
assert!(is_wasm(target_info));
let mut result: Vec<u8> = vec![0, b'a', b's', b'm', 1, 0, 0, 0];
wasm_gen::write_custom_section(&mut result, "linking", &[2]);
wasm_gen::write_custom_section(&mut result, ".dep-v0", contents);
result
}