@@ -10,8 +10,8 @@ use std::process::{Command, Stdio};
10
10
use object:: elf:: SHF_EXECINSTR ;
11
11
use object:: read:: archive:: { ArchiveFile , ArchiveMember } ;
12
12
use object:: {
13
- File as ObjFile , Object , ObjectSection , ObjectSymbol , SectionFlags , Symbol , SymbolKind ,
14
- SymbolScope ,
13
+ BinaryFormat , File as ObjFile , Object , ObjectSection , ObjectSymbol , SectionFlags , Symbol ,
14
+ SymbolKind , SymbolScope ,
15
15
} ;
16
16
use serde_json:: Value ;
17
17
@@ -309,6 +309,9 @@ fn verify_core_symbols(archive: &Archive) {
309
309
/// - A `.note.GNU-stack` section without the exe flag means there is no executable stack needed
310
310
/// - Without the section, behavior is target-specific and on some targets means an executable
311
311
/// stack is required.
312
+ ///
313
+ /// Now says
314
+ /// deprecated <https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0d38576a34ec64a1b4500c9277a8e9d0f07e6774>.
312
315
fn verify_no_exec_stack ( archive : & Archive ) {
313
316
let mut problem_objfiles = Vec :: new ( ) ;
314
317
@@ -327,7 +330,7 @@ fn verify_no_exec_stack(archive: &Archive) {
327
330
328
331
fn obj_requires_exe_stack ( obj : & ObjFile ) -> bool {
329
332
// Files other than elf likely do not use the same convention.
330
- if ! matches ! ( obj, ObjFile :: Elf32 ( _ ) | ObjFile :: Elf64 ( _ ) ) {
333
+ if obj. format ( ) != BinaryFormat :: Elf {
331
334
return false ;
332
335
}
333
336
@@ -395,9 +398,18 @@ impl Archive {
395
398
}
396
399
}
397
400
401
+ #[ test]
402
+ fn check_no_gnu_stack_obj ( ) {
403
+ // Should be supported on all Unix platforms
404
+ let p = env ! ( "NO_GNU_STACK_OBJ" ) ;
405
+ let f = fs:: read ( p) . unwrap ( ) ;
406
+ let obj = ObjFile :: parse ( f. as_slice ( ) ) . unwrap ( ) ;
407
+ assert ! ( obj_requires_exe_stack( & obj) ) ;
408
+ }
409
+
398
410
#[ test]
399
411
fn check_obj ( ) {
400
- let p = option_env ! ( "HAS_WX_OBJ " ) . expect ( "this platform should support the wx test build " ) ;
412
+ let p = option_env ! ( "HAS_EXE_STACK_OBJ " ) . expect ( "has_exe_stack.o not present " ) ;
401
413
let f = fs:: read ( p) . unwrap ( ) ;
402
414
let obj = ObjFile :: parse ( f. as_slice ( ) ) . unwrap ( ) ;
403
415
assert ! ( obj_requires_exe_stack( & obj) ) ;
0 commit comments