This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH,i386] Add -mstack-protector-guard= for i386


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]