|
10 | 10 | anyhow::{anyhow, Context, Result},
|
11 | 11 | clap::{App, AppSettings, Arg, ArgMatches, SubCommand},
|
12 | 12 | goblin::mach::load_command::CommandVariant,
|
13 |
| - lazy_static::lazy_static, |
| 13 | + once_cell::sync::Lazy, |
14 | 14 | scroll::Pread,
|
15 | 15 | std::{
|
16 | 16 | collections::{BTreeSet, HashMap},
|
@@ -113,19 +113,28 @@ const PE_ALLOWED_LIBRARIES: &[&str] = &[
|
113 | 113 | "tk86t.dll",
|
114 | 114 | ];
|
115 | 115 |
|
116 |
| -lazy_static! { |
117 |
| - static ref GLIBC_MAX_VERSION: version_compare::Version<'static> = |
118 |
| - version_compare::Version::from("2.19").unwrap(); |
| 116 | +static GLIBC_MAX_VERSION: Lazy<version_compare::Version<'static>> = |
| 117 | + Lazy::new(|| version_compare::Version::from("2.19").unwrap()); |
119 | 118 |
|
120 |
| - static ref ELF_ALLOWED_LIBRARIES_BY_TRIPLE: HashMap<&'static str, Vec<&'static str>> = { |
| 119 | +static ELF_ALLOWED_LIBRARIES_BY_TRIPLE: Lazy<HashMap<&'static str, Vec<&'static str>>> = |
| 120 | + Lazy::new(|| { |
121 | 121 | [
|
122 |
| - ("armv7-unknown-linux-gnueabi", vec!["ld-linux.so.3", "libgcc_s.so.1"]), |
123 |
| - ("armv7-unknown-linux-gnueabihf", vec!["ld-linux-armhf.so.3", "libgcc_s.so.1"]), |
124 |
| - ].iter().cloned().collect() |
125 |
| - }; |
| 122 | + ( |
| 123 | + "armv7-unknown-linux-gnueabi", |
| 124 | + vec!["ld-linux.so.3", "libgcc_s.so.1"], |
| 125 | + ), |
| 126 | + ( |
| 127 | + "armv7-unknown-linux-gnueabihf", |
| 128 | + vec!["ld-linux-armhf.so.3", "libgcc_s.so.1"], |
| 129 | + ), |
| 130 | + ] |
| 131 | + .iter() |
| 132 | + .cloned() |
| 133 | + .collect() |
| 134 | + }); |
126 | 135 |
|
127 |
| - static ref DARWIN_ALLOWED_DYLIBS: Vec<MachOAllowedDylib> = { |
128 |
| - [ |
| 136 | +static DARWIN_ALLOWED_DYLIBS: Lazy<Vec<MachOAllowedDylib>> = Lazy::new(|| { |
| 137 | + [ |
129 | 138 | MachOAllowedDylib {
|
130 | 139 | name: "@executable_path/../lib/libpython3.8.dylib".to_string(),
|
131 | 140 | max_compatibility_version: "3.8.0".try_into().unwrap(),
|
@@ -230,56 +239,60 @@ lazy_static! {
|
230 | 239 | },
|
231 | 240 | ]
|
232 | 241 | .to_vec()
|
233 |
| - }; |
234 |
| - static ref IOS_ALLOWED_DYLIBS: Vec<MachOAllowedDylib> = { |
235 |
| - [ |
236 |
| - MachOAllowedDylib { |
237 |
| - name: "@executable_path/../lib/libpython3.9.dylib".to_string(), |
238 |
| - max_compatibility_version: "3.9.0".try_into().unwrap(), |
239 |
| - required: false, |
240 |
| - }, |
241 |
| - MachOAllowedDylib { |
242 |
| - name: "@executable_path/../lib/libpython3.9d.dylib".to_string(), |
243 |
| - max_compatibility_version: "3.9.0".try_into().unwrap(), |
244 |
| - required: false, |
245 |
| - }, |
246 |
| - // For some reason, CoreFoundation is present in debug/noopt builds but not |
247 |
| - // LTO builds. |
248 |
| - MachOAllowedDylib { |
249 |
| - name: "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation".to_string(), |
250 |
| - max_compatibility_version: "150.0.0".try_into().unwrap(), |
251 |
| - required: false, |
252 |
| - }, |
253 |
| - MachOAllowedDylib { |
254 |
| - name: "/usr/lib/libSystem.B.dylib".to_string(), |
255 |
| - max_compatibility_version: "1.0.0".try_into().unwrap(), |
256 |
| - required: true, |
257 |
| - }, |
258 |
| - MachOAllowedDylib { |
259 |
| - name: "/usr/lib/libz.1.dylib".to_string(), |
260 |
| - max_compatibility_version: "1.0.0".try_into().unwrap(), |
261 |
| - required: true, |
262 |
| - }, |
263 |
| - ].to_vec() |
264 |
| - }; |
265 |
| - |
266 |
| - static ref PLATFORM_TAG_BY_TRIPLE: HashMap<&'static str, &'static str> = { |
267 |
| - [ |
268 |
| - ("aarch64-apple-darwin", "macosx-11.0-arm64"), |
269 |
| - ("aarch64-apple-ios", "iOS-aarch64"), |
270 |
| - ("aarch64-unknown-linux-gnu", "linux-aarch64"), |
271 |
| - ("armv7-unknown-linux-gnueabi", "linux-arm"), |
272 |
| - ("armv7-unknown-linux-gnueabihf", "linux-arm"), |
273 |
| - ("i686-pc-windows-msvc", "win32"), |
274 |
| - ("i686-unknown-linux-gnu", "linux-i686"), |
275 |
| - ("x86_64-apple-darwin", "macosx-10.9-x86_64"), |
276 |
| - ("x86_64-apple-ios", "iOS-x86_64"), |
277 |
| - ("x86_64-pc-windows-msvc", "win-amd64"), |
278 |
| - ("x86_64-unknown-linux-gnu", "linux-x86_64"), |
279 |
| - ("x86_64-unknown-linux-musl", "linux-x86_64"), |
280 |
| - ].iter().cloned().collect() |
281 |
| - }; |
282 |
| -} |
| 242 | +}); |
| 243 | + |
| 244 | +static IOS_ALLOWED_DYLIBS: Lazy<Vec<MachOAllowedDylib>> = Lazy::new(|| { |
| 245 | + [ |
| 246 | + MachOAllowedDylib { |
| 247 | + name: "@executable_path/../lib/libpython3.9.dylib".to_string(), |
| 248 | + max_compatibility_version: "3.9.0".try_into().unwrap(), |
| 249 | + required: false, |
| 250 | + }, |
| 251 | + MachOAllowedDylib { |
| 252 | + name: "@executable_path/../lib/libpython3.9d.dylib".to_string(), |
| 253 | + max_compatibility_version: "3.9.0".try_into().unwrap(), |
| 254 | + required: false, |
| 255 | + }, |
| 256 | + // For some reason, CoreFoundation is present in debug/noopt builds but not |
| 257 | + // LTO builds. |
| 258 | + MachOAllowedDylib { |
| 259 | + name: "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation".to_string(), |
| 260 | + max_compatibility_version: "150.0.0".try_into().unwrap(), |
| 261 | + required: false, |
| 262 | + }, |
| 263 | + MachOAllowedDylib { |
| 264 | + name: "/usr/lib/libSystem.B.dylib".to_string(), |
| 265 | + max_compatibility_version: "1.0.0".try_into().unwrap(), |
| 266 | + required: true, |
| 267 | + }, |
| 268 | + MachOAllowedDylib { |
| 269 | + name: "/usr/lib/libz.1.dylib".to_string(), |
| 270 | + max_compatibility_version: "1.0.0".try_into().unwrap(), |
| 271 | + required: true, |
| 272 | + }, |
| 273 | + ] |
| 274 | + .to_vec() |
| 275 | +}); |
| 276 | + |
| 277 | +static PLATFORM_TAG_BY_TRIPLE: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| { |
| 278 | + [ |
| 279 | + ("aarch64-apple-darwin", "macosx-11.0-arm64"), |
| 280 | + ("aarch64-apple-ios", "iOS-aarch64"), |
| 281 | + ("aarch64-unknown-linux-gnu", "linux-aarch64"), |
| 282 | + ("armv7-unknown-linux-gnueabi", "linux-arm"), |
| 283 | + ("armv7-unknown-linux-gnueabihf", "linux-arm"), |
| 284 | + ("i686-pc-windows-msvc", "win32"), |
| 285 | + ("i686-unknown-linux-gnu", "linux-i686"), |
| 286 | + ("x86_64-apple-darwin", "macosx-10.9-x86_64"), |
| 287 | + ("x86_64-apple-ios", "iOS-x86_64"), |
| 288 | + ("x86_64-pc-windows-msvc", "win-amd64"), |
| 289 | + ("x86_64-unknown-linux-gnu", "linux-x86_64"), |
| 290 | + ("x86_64-unknown-linux-musl", "linux-x86_64"), |
| 291 | + ] |
| 292 | + .iter() |
| 293 | + .cloned() |
| 294 | + .collect() |
| 295 | +}); |
283 | 296 |
|
284 | 297 | fn allowed_dylibs_for_triple(triple: &str) -> Vec<MachOAllowedDylib> {
|
285 | 298 | match triple {
|
|
0 commit comments