@@ -120,27 +120,21 @@ def test_MACHO(self):
120
120
arch = get_arch (cxx , source , executable )
121
121
122
122
if arch == lief .ARCHITECTURES .X86 :
123
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-fno-stack-protector' , '-Wl,-no_fixup_chains' ]),
124
- (1 , executable + ': failed NOUNDEFS Canary FIXUP_CHAINS PIE CONTROL_FLOW' ))
125
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-flat_namespace' ,'-fno-stack-protector' , '-Wl,-fixup_chains' ]),
126
- (1 , executable + ': failed NOUNDEFS Canary CONTROL_FLOW' ))
127
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-flat_namespace' ,'-fstack-protector-all' , '-Wl,-fixup_chains' ]),
128
- (1 , executable + ': failed NOUNDEFS CONTROL_FLOW' ))
129
- self .assertEqual (call_security_check (cxx , source , executable , ['-fstack-protector-all' , '-Wl,-fixup_chains' ]),
130
- (1 , executable + ': failed CONTROL_FLOW' ))
131
- self .assertEqual (call_security_check (cxx , source , executable , ['-fstack-protector-all' , '-fcf-protection=full' , '-Wl,-fixup_chains' ]),
132
- (0 , '' ))
123
+ pass_flags = ['-Wl,-pie' , '-fstack-protector-all' , '-fcf-protection=full' , '-Wl,-fixup_chains' ]
124
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-no_pie' , '-Wl,-no_fixup_chains' ]), (1 , executable + ': failed FIXUP_CHAINS PIE' )) # -fixup_chains is incompatible with -no_pie
125
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-no_fixup_chains' ]), (1 , executable + ': failed FIXUP_CHAINS' ))
126
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-fno-stack-protector' ]), (1 , executable + ': failed CANARY' ))
127
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-flat_namespace' ]), (1 , executable + ': failed NOUNDEFS' ))
128
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-fcf-protection=none' ]), (1 , executable + ': failed CONTROL_FLOW' ))
129
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags ), (0 , '' ))
133
130
else :
134
- # arm64 darwin doesn't support non-PIE binaries, control flow or executable stacks
135
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-flat_namespace' ,'-fno-stack-protector' , '-Wl,-no_fixup_chains' ]),
136
- (1 , executable + ': failed NOUNDEFS Canary FIXUP_CHAINS BRANCH_PROTECTION' ))
137
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-flat_namespace' ,'-fno-stack-protector' , '-Wl,-fixup_chains' , '-mbranch-protection=bti' ]),
138
- (1 , executable + ': failed NOUNDEFS Canary' ))
139
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-flat_namespace' ,'-fstack-protector-all' , '-Wl,-fixup_chains' , '-mbranch-protection=bti' ]),
140
- (1 , executable + ': failed NOUNDEFS' ))
141
- self .assertEqual (call_security_check (cxx , source , executable , ['-fstack-protector-all' , '-Wl,-fixup_chains' , '-mbranch-protection=bti' ]),
142
- (0 , '' ))
143
-
131
+ # arm64 darwin doesn't support non-PIE binaries or executable stacks
132
+ pass_flags = ['-fstack-protector-all' , '-Wl,-fixup_chains' , '-mbranch-protection=bti' ]
133
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-mbranch-protection=none' ]), (1 , executable + ': failed BRANCH_PROTECTION' ))
134
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-no_fixup_chains' ]), (1 , executable + ': failed FIXUP_CHAINS' ))
135
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-fno-stack-protector' ]), (1 , executable + ': failed CANARY' ))
136
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-flat_namespace' ]), (1 , executable + ': failed NOUNDEFS' ))
137
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags ), (0 , '' ))
144
138
145
139
clean_files (source , executable )
146
140
0 commit comments