From fb5a7eb324ba37a1f936bf3d8232edad34a8a940 Mon Sep 17 00:00:00 2001 From: Koutheir Attouchi Date: Sun, 25 Feb 2024 15:26:30 -0500 Subject: [PATCH] Find libc by parsing dynamic loader cache. --- .cargo/config.toml | 6 + Cargo.lock | 140 ++++++++++++++-------- Cargo.toml | 25 ++-- src/elf/needed_libc.rs | 164 +++++++++++++++----------- src/errors.rs | 12 ++ src/main.rs | 3 +- src/options.rs | 6 +- src/parser.rs | 1 - tools/x86_64-unknown-freebsd-clang.sh | 9 ++ 9 files changed, 233 insertions(+), 133 deletions(-) create mode 100755 tools/x86_64-unknown-freebsd-clang.sh diff --git a/.cargo/config.toml b/.cargo/config.toml index b4d41e8..5d908f0 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,3 +14,9 @@ linker = "ld.lld" [target.x86_64-pc-windows-gnu] linker = "x86_64-w64-mingw32-gcc" runner = "wine-stable" + +# rustup target add x86_64-unknown-freebsd +# cargo build --release --target=x86_64-unknown-freebsd +[target.x86_64-unknown-freebsd] +linker = "tools/x86_64-unknown-freebsd-clang.sh" +rustflags = ["-Clink-arg=--target=x86_64-unknown-freebsd"] diff --git a/Cargo.lock b/Cargo.lock index 1d77a6d..caba92e 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,9 +28,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ "anstyle", "anstyle-parse", @@ -74,6 +74,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "autocfg" version = "1.1.0" @@ -82,9 +88,10 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "binary-security-check" -version = "1.2.15" +version = "1.3.0" dependencies = [ "clap", + "dynamic-loader-cache", "flexi_logger", "goblin", "log", @@ -100,18 +107,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc" [[package]] name = "cfg-if" @@ -121,21 +125,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.33" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] name = "clap" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", "clap_derive", @@ -143,9 +147,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", @@ -208,6 +212,20 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "dynamic-loader-cache" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "663d1212827ee3016f4cdd8efa5bae8e00e7eff58c9c52a36d40d61afa3e714f" +dependencies = [ + "arrayvec", + "memmap2", + "memoffset", + "nom", + "static_assertions", + "thiserror", +] + [[package]] name = "either" version = "1.10.0" @@ -255,9 +273,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" +checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60" [[package]] name = "iana-time-zone" @@ -344,6 +362,22 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "nu-ansi-term" version = "0.49.0" @@ -461,6 +495,12 @@ dependencies = [ "syn", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.11.0" @@ -469,9 +509,9 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", @@ -489,18 +529,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -610,7 +650,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -628,7 +668,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.3", ] [[package]] @@ -648,17 +688,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.3", + "windows_aarch64_msvc 0.52.3", + "windows_i686_gnu 0.52.3", + "windows_i686_msvc 0.52.3", + "windows_x86_64_gnu 0.52.3", + "windows_x86_64_gnullvm 0.52.3", + "windows_x86_64_msvc 0.52.3", ] [[package]] @@ -669,9 +709,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6" [[package]] name = "windows_aarch64_msvc" @@ -681,9 +721,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f" [[package]] name = "windows_i686_gnu" @@ -693,9 +733,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb" [[package]] name = "windows_i686_msvc" @@ -705,9 +745,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58" [[package]] name = "windows_x86_64_gnu" @@ -717,9 +757,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614" [[package]] name = "windows_x86_64_gnullvm" @@ -729,9 +769,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c" [[package]] name = "windows_x86_64_msvc" @@ -741,6 +781,6 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6" diff --git a/Cargo.toml b/Cargo.toml index ead479a..22cca77 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ [package] name = "binary-security-check" -version = "1.2.15" +version = "1.3.0" authors = ["Koutheir Attouchi "] license = "MIT" description = "Analyzer of security features in executable binaries" @@ -37,17 +37,18 @@ incremental = false overflow-checks = true [dependencies] -thiserror = { version = "1.0" } -goblin = { version = "0.8" } -once_cell = { version = "1.19" } -log = { version = "0.4" } -memmap2 = { version = "0.9" } -rayon = { version = "1.8" } -regex = { version = "1.10" } -scroll = { version = "0.12" } -flexi_logger = { version = "0.27" } -termcolor = { version = "1.4" } -memoffset = { version = "0.9" } +thiserror = { version = "1.0" } +goblin = { version = "0.8" } +once_cell = { version = "1.19" } +log = { version = "0.4" } +memmap2 = { version = "0.9" } +rayon = { version = "1.8" } +regex = { version = "1.10" } +scroll = { version = "0.12" } +flexi_logger = { version = "0.27" } +termcolor = { version = "1.4" } +memoffset = { version = "0.9" } +dynamic-loader-cache = { version = "0.1" } clap = { version = "4.5", features = [ "color", diff --git a/src/elf/needed_libc.rs b/src/elf/needed_libc.rs index 33cdad2..368b29c 100755 --- a/src/elf/needed_libc.rs +++ b/src/elf/needed_libc.rs @@ -5,8 +5,8 @@ // or distributed except according to those terms. use std::collections::HashSet; -use std::ffi::OsStr; use std::path::{Path, PathBuf}; +use std::sync::OnceLock; use log::{debug, log_enabled}; use regex::{Regex, RegexBuilder}; @@ -16,6 +16,99 @@ use crate::cmdline::LibCSpec; use crate::errors::{Error, Result}; use crate::parser::BinaryParser; +#[derive(Debug)] +pub(crate) struct LibCResolver { + sys_root: PathBuf, + ld_so_cache: Option, +} + +static LIBC_RESOLVER: OnceLock> = OnceLock::new(); + +impl LibCResolver { + pub(crate) fn get(options: &crate::cmdline::Options) -> Result<&'static Self> { + let mut first_err = None; + + let r = LIBC_RESOLVER.get_or_init(|| match Self::new(options) { + Ok(r) => Some(r), + + Err(err) => { + first_err = Some(err); + None + } + }); + + if let Some(err) = first_err { + Err(err) + } else { + r.as_ref().ok_or_else(|| { + let err = std::io::ErrorKind::InvalidData.into(); + Error::from_io1(err, "load linker cache", "") + }) + } + } + + fn new(options: &crate::cmdline::Options) -> Result { + let ld_so_cache = if options.sysroot.is_none() { + Some(dynamic_loader_cache::Cache::load()?) + } else { + None + }; + + let sys_root = options.sysroot.as_deref().unwrap_or_else(|| Path::new("/")); + + Ok(Self { + sys_root: sys_root.into(), + ld_so_cache, + }) + } + + pub(crate) fn find_needed_by_executable(&self, elf: &goblin::elf::Elf) -> Result { + elf.libraries + .iter() + // Only consider libraries whose pattern is known. + .filter(|needed_lib| KNOWN_LIBC_PATTERN.is_match(needed_lib)) + // Parse the library. + .map(|&lib| self.open_compatible_libc(elf, Path::new(lib))) + // Return the first that can be successfully parsed. + .find(Result::is_ok) + // Or return an error in case nothing is found or nothing can be parsed. + .unwrap_or(Err(Error::UnrecognizedNeededLibC)) + } + + fn open_compatible_libc(&self, elf: &goblin::elf::Elf, file_name: &Path) -> Result { + debug!("Looking for libc '{}'.", file_name.display()); + + if let Some(ld_so_cache) = self.ld_so_cache.as_ref() { + let found_in_ld_so_cache = ld_so_cache + .iter()? + .filter_map(dynamic_loader_cache::Result::ok) + .filter_map(|e| (e.file_name == file_name).then_some(e.full_path)) + // For each known libc file location, parse the libc file. + .map(|path| NeededLibC::open_elf_for_architecture(path, elf)) + // Return the first that can be successfully parsed. + .find(Result::is_ok); + + if let Some(libc) = found_in_ld_so_cache { + return libc; + } + } + + KNOWN_LIB_DIRS + .iter() + .flat_map(|&lib| { + KNOWN_PREFIXES + .iter() + .map(move |&prefix| self.sys_root.join(prefix).join(lib).join(file_name)) + }) + // For each known libc file location, parse the libc file. + .map(|path| NeededLibC::open_elf_for_architecture(path, elf)) + // Return the first that can be successfully parsed. + .find(Result::is_ok) + // Or return an error in case nothing is found or nothing can be parsed. + .unwrap_or_else(|| Err(Error::NotFoundNeededLibC(file_name.into()))) + } +} + pub(crate) struct NeededLibC { checked_functions: HashSet, } @@ -52,64 +145,7 @@ impl NeededLibC { } } - pub(crate) fn find_needed_by_executable( - elf: &goblin::elf::Elf, - options: &crate::cmdline::Options, - ) -> Result { - if let Some(path) = &options.libc { - Self::open_elf_for_architecture(path, elf) - } else { - elf.libraries - .iter() - // Only consider libraries whose pattern is known. - .filter(|needed_lib| KNOWN_LIBC_PATTERN.is_match(needed_lib)) - // Parse the library. - .map(|lib| Self::open_compatible_libc(lib, elf, options)) - // Return the first that can be successfully parsed. - .find(Result::is_ok) - // Or return an error in case nothing is found or nothing can be parsed. - .unwrap_or(Err(Error::UnrecognizedNeededLibC)) - } - } - - fn open_compatible_libc( - file_name: impl AsRef, - elf: &goblin::elf::Elf, - options: &crate::cmdline::Options, - ) -> Result { - KNOWN_LIBC_FILE_LOCATIONS - .iter() - // For each known libc file location, parse the libc file. - .map(|known_location| { - Self::open_elf_for_architecture( - Self::get_libc_path(known_location, &file_name, options), - elf, - ) - }) - // Return the first that can be successfully parsed. - .find(Result::is_ok) - // Or return an error in case nothing is found or nothing can be parsed. - .unwrap_or_else(|| Err(Error::NotFoundNeededLibC(file_name.as_ref().into()))) - } - - fn get_libc_path( - location: impl AsRef, - file_name: impl AsRef, - options: &crate::cmdline::Options, - ) -> PathBuf { - let mut path = if let Some(sysroot) = options.sysroot.as_ref() { - let mut p = PathBuf::from(sysroot).into_os_string(); - p.push(location.as_ref()); - PathBuf::from(p) - } else { - PathBuf::from(location.as_ref()) - }; - - path.push(&file_name); - path - } - - fn open_elf_for_architecture( + pub(crate) fn open_elf_for_architecture( path: impl AsRef, other_elf: &goblin::elf::Elf, ) -> Result { @@ -201,14 +237,8 @@ impl NeededLibC { } // If this changes, then update the command line reference. -static KNOWN_LIBC_FILE_LOCATIONS: &[&str] = &[ - "/lib", - "/usr/lib", - "/lib64", - "/usr/lib64", - "/lib32", - "/usr/lib32", -]; +static KNOWN_PREFIXES: &[&str] = &["", "usr"]; +static KNOWN_LIB_DIRS: &[&str] = &["lib", "lib64", "lib32"]; static KNOWN_LIBC_PATTERN: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { RegexBuilder::new(r"\blib(c|bionic)\b[^/]+$") diff --git a/src/errors.rs b/src/errors.rs index 8397509..1afd5b6 100755 --- a/src/errors.rs +++ b/src/errors.rs @@ -60,6 +60,18 @@ pub(crate) enum Error { #[error("dependent C runtime library '{0}' was not found")] NotFoundNeededLibC(PathBuf), + + #[error(transparent)] + FromBytesWithNul(#[from] core::ffi::FromBytesWithNulError), + + #[error(transparent)] + FromBytesUntilNul(#[from] core::ffi::FromBytesUntilNulError), + + #[error(transparent)] + Scroll(#[from] scroll::Error), + + #[error(transparent)] + DynamicLoaderCache(#[from] dynamic_loader_cache::Error), } impl Error { diff --git a/src/main.rs b/src/main.rs index fe04a6b..6501748 100755 --- a/src/main.rs +++ b/src/main.rs @@ -24,7 +24,8 @@ clippy::min_ident_chars, clippy::single_char_lifetime_names, clippy::single_call_fn, - clippy::absolute_paths + clippy::absolute_paths, + clippy::similar_names )] mod archive; diff --git a/src/options.rs b/src/options.rs index 2a9fcd7..d0bc98f 100755 --- a/src/options.rs +++ b/src/options.rs @@ -6,7 +6,7 @@ pub(crate) mod status; -use crate::elf::needed_libc::NeededLibC; +use crate::elf::needed_libc::{LibCResolver, NeededLibC}; use crate::errors::Result; use crate::parser::BinaryParser; use crate::{archive, cmdline, elf, pe}; @@ -341,8 +341,10 @@ impl<'t> BinarySecurityOption<'t> for ELFFortifySourceOption { if let goblin::Object::Elf(elf) = parser.object() { let libc = if let Some(spec) = self.libc_spec { NeededLibC::from_spec(spec) + } else if let Some(path) = &options.libc { + NeededLibC::open_elf_for_architecture(path, elf)? } else { - NeededLibC::find_needed_by_executable(elf, options)? + LibCResolver::get(options)?.find_needed_by_executable(elf)? }; let result = ELFFortifySourceStatus::new(libc, elf)?; diff --git a/src/parser.rs b/src/parser.rs index 22d01ec..8204a7f 100755 --- a/src/parser.rs +++ b/src/parser.rs @@ -27,7 +27,6 @@ impl BinaryParser { let file = fs::File::open(&path).map_err(|r| Error::from_io1(r, "open file", path.as_ref()))?; - debug!("Mapping binary file '{}'.", path.as_ref().display()); let bytes = unsafe { MmapOptions::new().map(&file) } .map_err(|r| Error::from_io1(r, "map file", path.as_ref()))?; diff --git a/tools/x86_64-unknown-freebsd-clang.sh b/tools/x86_64-unknown-freebsd-clang.sh new file mode 100755 index 0000000..81c0a72 --- /dev/null +++ b/tools/x86_64-unknown-freebsd-clang.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SYS_ROOT="$TOOLCHAINS_ROOT/x86_64-unknown-freebsd/sysroot" +if [ ! -d "$SYS_ROOT" ]; then + >&2 echo "Toolchain root not found: $TOOLCHAINS_ROOT" + exit 1 +fi + +exec clang "--sysroot=$SYS_ROOT" "$@"