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, Android] Runtime stack protector enabling for Android target


Let's try with this patch then. Is it ok for trunk after all
appropriate testing is done?

ChangeLog:

2012-07-09 Sergey Melnikov <sergey.melnikov@intel.com>

         * config/i386/i386.md (stack_protect_set): Disable the pattern
         for Android since Android libc (bionic) does not provide random
         value for stack protection guard at gs:0x14. Guard value
         will be provided from external symbol (default implementation).
         (stack_protect_set_<mode>): Likewise.
         (stack_protect_test): Likewise.
         (stack_protect_test_<mode>): Likewise.


diff --git a/gcc-4.6/gcc/config/i386/i386.md b/gcc-4.6/gcc/config/i386/i386.md
index b1d7e5e..c4dd6e3 100644
--- a/gcc-4.6/gcc/config/i386/i386.md
+++ b/gcc-4.6/gcc/config/i386/i386.md
@@ -17955,7 +17955,7 @@
 (define_expand "stack_protect_set"
   [(match_operand 0 "memory_operand" "")
    (match_operand 1 "memory_operand" "")]
-  ""
+  "!(flag_android && OPTION_BIONIC)"
 {
   rtx (*insn)(rtx, rtx);

@@ -17979,7 +17979,7 @@
 	(unspec:P [(match_operand:P 1 "memory_operand" "m")] UNSPEC_SP_SET))
    (set (match_scratch:P 2 "=&r") (const_int 0))
    (clobber (reg:CC FLAGS_REG))]
-  ""
+  "!(flag_android && OPTION_BIONIC)"
   "mov{<imodesuffix>}\t{%1, %2|%2, %1}\;mov{<imodesuffix>}\t{%2,
%0|%0, %2}\;xor{l}\t%k2, %k2"
   [(set_attr "type" "multi")])

@@ -17997,7 +17997,7 @@
   [(match_operand 0 "memory_operand" "")
    (match_operand 1 "memory_operand" "")
    (match_operand 2 "" "")]
-  ""
+  "!(flag_android && OPTION_BIONIC)"
 {
   rtx flags = gen_rtx_REG (CCZmode, FLAGS_REG);

@@ -18027,7 +18027,7 @@
 		     (match_operand:P 2 "memory_operand" "m")]
 		    UNSPEC_SP_TEST))
    (clobber (match_scratch:P 3 "=&r"))]
-  ""
+  "!(flag_android && OPTION_BIONIC)"
   "mov{<imodesuffix>}\t{%1, %3|%3, %1}\;xor{<imodesuffix>}\t{%2, %3|%3, %2}"
   [(set_attr "type" "multi")])

Thanks,
Igor


On Fri, Jul 6, 2012 at 4:54 PM, Igor Zamyatin <izamyatin@gmail.com> wrote:
> Right, flag_android looks better, thanks.
> Probably it's even better to check also bionic (OPTION_BIONIC)
>
> On Fri, Jul 6, 2012 at 12:13 PM, Andrew Pinski <pinskia@gmail.com> wrote:
>> On Fri, Jul 6, 2012 at 12:49 AM, Igor Zamyatin <izamyatin@gmail.com> wrote:
>>> Hi!
>>>
>>> For runtime stack protector enabling on x86 for Android we have to
>>> disable current glibc-based implementation and turn on default one
>>> since bionic doesn't use value from gs:0x14.
>>>
>>> Tested in android environment(x86_64-*-linux-android), also
>>> bootstrapped and regtested on x86_64-unknown-linux-gnu and i686-linux.
>>> Ok for trunk?
>>
>>
>>
>> I think you want flag_android and not ANDROID_DEFAULT since you could
>> use -mno-android .
>>
>> Thanks,
>> Andrew
>>
>>
>>
>>>
>>> Thanks,
>>> Igor
>>>
>>>


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