17
17
convert:: TryInto ,
18
18
io:: Read ,
19
19
iter:: FromIterator ,
20
- ops:: Deref ,
21
20
path:: { Path , PathBuf } ,
22
21
} ,
23
22
} ;
@@ -111,8 +110,38 @@ const PE_ALLOWED_LIBRARIES: &[&str] = &[
111
110
"tk86t.dll" ,
112
111
] ;
113
112
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
+ } ) ;
116
145
117
146
static ELF_ALLOWED_LIBRARIES_BY_TRIPLE : Lazy < HashMap < & ' static str , Vec < & ' static str > > > =
118
147
Lazy :: new ( || {
@@ -342,6 +371,10 @@ fn validate_elf(
342
371
}
343
372
}
344
373
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
+
345
378
let mut undefined_symbols = tugger_binary_analysis:: find_undefined_elf_symbols ( & bytes, elf) ;
346
379
undefined_symbols. sort ( ) ;
347
380
@@ -354,7 +387,7 @@ fn validate_elf(
354
387
let v =
355
388
version_compare:: Version :: from ( parts[ 1 ] ) . expect ( "unable to parse version" ) ;
356
389
357
- if & v > GLIBC_MAX_VERSION . deref ( ) {
390
+ if & v > wanted_glibc_max_version {
358
391
errors. push ( format ! (
359
392
"{} references too new glibc symbol {:?}" ,
360
393
path. display( ) ,
0 commit comments