Skip to content

Commit 273a53f

Browse files
committed
fix: undo objcopy API changes
1 parent 962e524 commit 273a53f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/commands/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ pub async fn build(path: &Utf8Path, opts: CargoOpts) -> miette::Result<Option<Bu
8282
for message in Message::parse_stream(reader) {
8383
if let Message::CompilerArtifact(artifact) = message? {
8484
if let Some(elf_artifact_path) = artifact.executable {
85-
let elf_data = std::fs::read(&elf_artifact_path)?;
86-
let elf = object::File::parse(elf_data.as_slice())?;
87-
let binary = objcopy(elf)?;
85+
let binary = objcopy(&std::fs::read(&elf_artifact_path)?)?;
8886
let binary_path = elf_artifact_path.with_extension("bin");
8987

9088
// Write the binary to a file.
@@ -111,7 +109,9 @@ pub async fn build(path: &Utf8Path, opts: CargoOpts) -> miette::Result<Option<Bu
111109
}
112110

113111
/// Implementation of `objcopy -O binary`.
114-
pub fn objcopy(elf: object::File<'_>) -> Result<Vec<u8>, CliError> {
112+
pub fn objcopy(elf: &[u8]) -> Result<Vec<u8>, CliError> {
113+
let elf = object::File::parse(elf)?; // parse ELF file
114+
115115
// First we need to find the loadable sections of the program
116116
// (the parts of the ELF that will be actually loaded into memory)
117117
let mut loadable_sections = elf

0 commit comments

Comments
 (0)