Skip to content

Commit 9306f67

Browse files
committed
rust: define a per-target max glibc version
The ARM builds (so far) appear to use glibc 2.17. So we need a way to distinguish versions between builds.
1 parent e3b3c21 commit 9306f67

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

src/main.rs

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use {
1717
convert::TryInto,
1818
io::Read,
1919
iter::FromIterator,
20-
ops::Deref,
2120
path::{Path, PathBuf},
2221
},
2322
};
@@ -111,8 +110,38 @@ const PE_ALLOWED_LIBRARIES: &[&str] = &[
111110
"tk86t.dll",
112111
];
113112

114-
static GLIBC_MAX_VERSION: Lazy<version_compare::Version<'static>> =
115-
Lazy::new(|| version_compare::Version::from("2.19").unwrap());
113+
static GLIBC_MAX_VERSION_BY_TRIPLE: Lazy<HashMap<&'static str, version_compare::Version<'static>>> =
114+
Lazy::new(|| {
115+
let mut versions = HashMap::new();
116+
117+
versions.insert(
118+
"aarch64-unknown-linux-gnu",
119+
version_compare::Version::from("2.17").unwrap(),
120+
);
121+
versions.insert(
122+
"armv7-unknown-linux-gnueabi",
123+
version_compare::Version::from("2.17").unwrap(),
124+
);
125+
versions.insert(
126+
"armv7-unknown-linux-gnueabihf",
127+
version_compare::Version::from("2.17").unwrap(),
128+
);
129+
versions.insert(
130+
"i686-unknown-linux-gnu",
131+
version_compare::Version::from("2.17").unwrap(),
132+
);
133+
versions.insert(
134+
"x86_64-unknown-linux-gnu",
135+
version_compare::Version::from("2.17").unwrap(),
136+
);
137+
// musl shouldn't link against glibc.
138+
versions.insert(
139+
"x86_64-unknown-linux-musl",
140+
version_compare::Version::from("1").unwrap(),
141+
);
142+
143+
versions
144+
});
116145

117146
static ELF_ALLOWED_LIBRARIES_BY_TRIPLE: Lazy<HashMap<&'static str, Vec<&'static str>>> =
118147
Lazy::new(|| {
@@ -342,6 +371,10 @@ fn validate_elf(
342371
}
343372
}
344373

374+
let wanted_glibc_max_version = GLIBC_MAX_VERSION_BY_TRIPLE
375+
.get(target_triple)
376+
.expect("max glibc version not defined for target triple");
377+
345378
let mut undefined_symbols = tugger_binary_analysis::find_undefined_elf_symbols(&bytes, elf);
346379
undefined_symbols.sort();
347380

@@ -354,7 +387,7 @@ fn validate_elf(
354387
let v =
355388
version_compare::Version::from(parts[1]).expect("unable to parse version");
356389

357-
if &v > GLIBC_MAX_VERSION.deref() {
390+
if &v > wanted_glibc_max_version {
358391
errors.push(format!(
359392
"{} references too new glibc symbol {:?}",
360393
path.display(),

0 commit comments

Comments
 (0)