Hello! > Bionic in Android 4.2 starts to support stack-protector canary at TLS for x86. > > Android prior to 4.2 still looks at a global variable for stack > canary. To maintain backward compatibility, I propose to add a new > option -mstack-protector-guard={global,tls} for i386 back-end to use > canary at global or per-thread at %gs:20, respectively. > > "global" is the default for bionic (*1); otherwise "tls" is the default
(define_expand "stack_protect_set" [(match_operand 0 "memory_operand") (match_operand 1 "memory_operand")] - "!TARGET_HAS_BIONIC" + "ix86_stack_protector_guard == SSP_TLS" Please introduce TARGET_SSP_GLOBAL_GUARD and TARGET_SSP_TLS_GUARD defines to i386.h (please follow an example of TARGET_GNU_TLS). target_option_default_node = target_option_current_node = build_target_option_node (); + + /* Handle stack protector */ + if (!global_options_set.x_ix86_stack_protector_guard) + { + ix86_stack_protector_guard = TARGET_HAS_BIONIC? SSP_GLOBAL : SSP_TLS; + } } You should not need this part, JoinedVar directive should handle this functionality by itself. Again, please see ix86_tls_dialect handling. Uros.