@@ -116,21 +116,34 @@ def test_MACHO(self):
116
116
executable = 'test1'
117
117
cc = determine_wellknown_cmd ('CC' , 'clang' )
118
118
write_testcode (source )
119
+ arch = get_arch (cc , source , executable )
120
+
121
+ if arch == lief .ARCHITECTURES .X86 :
122
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-Wl,-allow_stack_execute' ,'-fno-stack-protector' ]),
123
+ (1 , executable + ': failed NOUNDEFS LAZY_BINDINGS Canary PIE NX CONTROL_FLOW' ))
124
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-Wl,-allow_stack_execute' ,'-fstack-protector-all' ]),
125
+ (1 , executable + ': failed NOUNDEFS LAZY_BINDINGS PIE NX CONTROL_FLOW' ))
126
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-fstack-protector-all' ]),
127
+ (1 , executable + ': failed NOUNDEFS LAZY_BINDINGS PIE CONTROL_FLOW' ))
128
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-fstack-protector-all' ]),
129
+ (1 , executable + ': failed LAZY_BINDINGS PIE CONTROL_FLOW' ))
130
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-bind_at_load' ,'-fstack-protector-all' ]),
131
+ (1 , executable + ': failed PIE CONTROL_FLOW' ))
132
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-bind_at_load' ,'-fstack-protector-all' , '-fcf-protection=full' ]),
133
+ (1 , executable + ': failed PIE' ))
134
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-pie' ,'-Wl,-bind_at_load' ,'-fstack-protector-all' , '-fcf-protection=full' ]),
135
+ (0 , '' ))
136
+ else :
137
+ # arm64 darwin doesn't support non-PIE binaries, control flow or executable stacks
138
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-flat_namespace' ,'-fno-stack-protector' ]),
139
+ (1 , executable + ': failed NOUNDEFS LAZY_BINDINGS Canary' ))
140
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-flat_namespace' ,'-fstack-protector-all' ]),
141
+ (1 , executable + ': failed NOUNDEFS LAZY_BINDINGS' ))
142
+ self .assertEqual (call_security_check (cc , source , executable , ['-fstack-protector-all' ]),
143
+ (1 , executable + ': failed LAZY_BINDINGS' ))
144
+ self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-bind_at_load' ,'-fstack-protector-all' ]),
145
+ (0 , '' ))
119
146
120
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-Wl,-allow_stack_execute' ,'-fno-stack-protector' ]),
121
- (1 , executable + ': failed PIE NOUNDEFS NX LAZY_BINDINGS Canary CONTROL_FLOW' ))
122
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-Wl,-allow_stack_execute' ,'-fstack-protector-all' ]),
123
- (1 , executable + ': failed PIE NOUNDEFS NX LAZY_BINDINGS CONTROL_FLOW' ))
124
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-flat_namespace' ,'-fstack-protector-all' ]),
125
- (1 , executable + ': failed PIE NOUNDEFS LAZY_BINDINGS CONTROL_FLOW' ))
126
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-fstack-protector-all' ]),
127
- (1 , executable + ': failed PIE LAZY_BINDINGS CONTROL_FLOW' ))
128
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-bind_at_load' ,'-fstack-protector-all' ]),
129
- (1 , executable + ': failed PIE CONTROL_FLOW' ))
130
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-no_pie' ,'-Wl,-bind_at_load' ,'-fstack-protector-all' , '-fcf-protection=full' ]),
131
- (1 , executable + ': failed PIE' ))
132
- self .assertEqual (call_security_check (cc , source , executable , ['-Wl,-pie' ,'-Wl,-bind_at_load' ,'-fstack-protector-all' , '-fcf-protection=full' ]),
133
- (0 , '' ))
134
147
135
148
clean_files (source , executable )
136
149
0 commit comments