Skip to content
Snippets Groups Projects
Commit 54bfdd10 authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Add crt0 binary export

parent fb3dc5a8
No related branches found
No related tags found
1 merge request!1Add a new `link` subcommand
...@@ -25,6 +25,7 @@ use std::io::Write; ...@@ -25,6 +25,7 @@ use std::io::Write;
const PADDING_SIZE: usize = 32; const PADDING_SIZE: usize = 32;
const PADDING_BUFFER: [u8; PADDING_SIZE] = [0xff; PADDING_SIZE]; const PADDING_BUFFER: [u8; PADDING_SIZE] = [0xff; PADDING_SIZE];
const PIP_EXPORT_SECTIONS: &'static [&str] = &[".vector_table", ".text", ".data"]; const PIP_EXPORT_SECTIONS: &'static [&str] = &[".vector_table", ".text", ".data"];
const CRT0_EXPORT_SECTIONS: &'static [&str] = &[".text", ".rodata", ".ARM.exidx"];
/// Options for the link subcommand /// Options for the link subcommand
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
...@@ -80,7 +81,7 @@ pub fn link(opts: Opts) -> Result<()> { ...@@ -80,7 +81,7 @@ pub fn link(opts: Opts) -> Result<()> {
let crt0_elf_file = std::fs::read(&opts.crt0_elf)?; let crt0_elf_file = std::fs::read(&opts.crt0_elf)?;
let crt0_elf_data = crt0_elf_file.as_slice(); let crt0_elf_data = crt0_elf_file.as_slice();
let _crt0_elf = elf::ElfBytes::<AnyEndian>::minimal_parse(crt0_elf_data)?; let crt0_elf = elf::ElfBytes::<AnyEndian>::minimal_parse(crt0_elf_data)?;
let user_code_elf_file = std::fs::read(&opts.user_code_elf)?; let user_code_elf_file = std::fs::read(&opts.user_code_elf)?;
let user_code_elf_data = user_code_elf_file.as_slice(); let user_code_elf_data = user_code_elf_file.as_slice();
...@@ -109,6 +110,10 @@ pub fn link(opts: Opts) -> Result<()> { ...@@ -109,6 +110,10 @@ pub fn link(opts: Opts) -> Result<()> {
output.write_all(&PADDING_BUFFER[0..pad_bytes])?; output.write_all(&PADDING_BUFFER[0..pad_bytes])?;
} }
} }
// Then, dump crt0
// no need for output size here, padding is not necessary for crt0
dump_sections(&crt0_elf, CRT0_EXPORT_SECTIONS, &mut output)?;
Ok(()) Ok(())
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment