(
entry: &mut R,
binary_path: D,
)
| 342 | } |
| 343 | |
| 344 | fn read_binary<'a, R: Read, D: std::fmt::Debug>( |
| 345 | entry: &mut R, |
| 346 | binary_path: D, |
| 347 | ) -> Result<(Vec<u8>, &'a str)> { |
| 348 | let mut binary_data = Vec::new(); |
| 349 | |
| 350 | entry |
| 351 | .read_to_end(&mut binary_data) |
| 352 | .into_diagnostic() |
| 353 | .wrap_err_with(|| format!("failed to read binary file `{binary_path:?}`"))?; |
| 354 | |
| 355 | let object = ObjectFile::parse(&*binary_data) |
| 356 | .into_diagnostic() |
| 357 | .wrap_err("the provided function file is not a valid Linux binary")?; |
| 358 | |
| 359 | let arch = match object.architecture() { |
| 360 | Architecture::Aarch64 => "arm64", |
| 361 | Architecture::X86_64 => "x86_64", |
| 362 | other => return Err(BuildError::InvalidBinaryArchitecture(other).into()), |
| 363 | }; |
| 364 | |
| 365 | Ok((binary_data, arch)) |
| 366 | } |
| 367 | |
| 368 | fn zip_file_options(file: &File, path: &Path) -> Result<SimpleFileOptions> { |
| 369 | let meta = file |
no test coverage detected