@@ -10,8 +10,8 @@ use std::process::{Command, Stdio};
1010use object:: elf:: SHF_EXECINSTR ;
1111use object:: read:: archive:: { ArchiveFile , ArchiveMember } ;
1212use 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 ,
1515} ;
1616use serde_json:: Value ;
1717
@@ -309,6 +309,9 @@ fn verify_core_symbols(archive: &Archive) {
309309/// - A `.note.GNU-stack` section without the exe flag means there is no executable stack needed
310310/// - Without the section, behavior is target-specific and on some targets means an executable
311311/// stack is required.
312+ ///
313+ /// Now says
314+ /// deprecated <https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0d38576a34ec64a1b4500c9277a8e9d0f07e6774>.
312315fn verify_no_exec_stack ( archive : & Archive ) {
313316 let mut problem_objfiles = Vec :: new ( ) ;
314317
@@ -327,7 +330,7 @@ fn verify_no_exec_stack(archive: &Archive) {
327330
328331fn obj_requires_exe_stack ( obj : & ObjFile ) -> bool {
329332 // 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 {
331334 return false ;
332335 }
333336
@@ -395,9 +398,18 @@ impl Archive {
395398 }
396399}
397400
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+
398410#[ test]
399411fn 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 " ) ;
401413 let f = fs:: read ( p) . unwrap ( ) ;
402414 let obj = ObjFile :: parse ( f. as_slice ( ) ) . unwrap ( ) ;
403415 assert ! ( obj_requires_exe_stack( & obj) ) ;
0 commit comments