File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,25 @@ fn validate_elf(
312
312
) -> Result < Vec < String > > {
313
313
let mut errors = vec ! [ ] ;
314
314
315
+ let wanted_cpu_type = match target_triple {
316
+ "aarch64-unknown-linux-gnu" => goblin:: elf:: header:: EM_AARCH64 ,
317
+ "armv7-unknown-linux-gnueabi" => goblin:: elf:: header:: EM_ARM ,
318
+ "armv7-unknown-linux-gnueabihf" => goblin:: elf:: header:: EM_ARM ,
319
+ "i686-unknown-linux-gnu" => goblin:: elf:: header:: EM_386 ,
320
+ "x86_64-unknown-linux-gnu" => goblin:: elf:: header:: EM_X86_64 ,
321
+ "x86_64-unknown-linux-musl" => goblin:: elf:: header:: EM_X86_64 ,
322
+ _ => panic ! ( "unhandled target triple: {}" , target_triple) ,
323
+ } ;
324
+
325
+ if elf. header . e_machine != wanted_cpu_type {
326
+ errors. push ( format ! (
327
+ "invalid ELF machine type in {}; wanted {}, got {}" ,
328
+ path. display( ) ,
329
+ wanted_cpu_type,
330
+ elf. header. e_machine
331
+ ) ) ;
332
+ }
333
+
315
334
let mut allowed_libraries = ELF_ALLOWED_LIBRARIES . to_vec ( ) ;
316
335
if let Some ( extra) = ELF_ALLOWED_LIBRARIES_BY_TRIPLE . get ( target_triple) {
317
336
allowed_libraries. extend ( extra. iter ( ) ) ;
You can’t perform that action at this time.
0 commit comments