diff mbox

[Android] Stack protector enabling for Android target

Message ID CAKdSQZk2D8X70U5RJHWYSQQoY1RUwm=iNPS6PDp7hzjzLtE_mw@mail.gmail.com
State New
Headers show

Commit Message

Igor Zamyatin May 6, 2012, 7:02 a.m. UTC
Hi!

The patch enables stack protector for Android.
Android targets don't contain necessary information in features.h so
we explicitly enable stack protector for Android.

Bootstrapped and regtested on x86_64. Ok to commit?

Thanks,
Igor

2012-05-06  Igor Zamyatin  <igor.zamyatin@intel.com>

        * configure.ac: Stack protector enabling for Android targets.
        * configure: Regenerate.

Comments

Maxim Kuvyrkov May 7, 2012, 6:04 p.m. UTC | #1
On 6/05/2012, at 7:02 PM, Igor Zamyatin wrote:

> Hi!
> 
> The patch enables stack protector for Android.
> Android targets don't contain necessary information in features.h so
> we explicitly enable stack protector for Android.
> 
> Bootstrapped and regtested on x86_64. Ok to commit?
> 
> Thanks,
> Igor
> 
> 2012-05-06  Igor Zamyatin  <igor.zamyatin@intel.com>
> 
>        * configure.ac: Stack protector enabling for Android targets.
>        * configure: Regenerate.
> 
> 
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 86b4bea..c1012d6 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -4545,6 +4545,8 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
>       gcc_cv_libc_provides_ssp,
>       [gcc_cv_libc_provides_ssp=no
>     case "$target" in
> +       *-android*)
> +         gcc_cv_libc_provides_ssp=yes;;
>        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
>       [# glibc 2.4 and later provides __stack_chk_fail and
>       # either __stack_chk_guard, or TLS access to stack guard canary.


What you really want is to enable stack protector for Bionic libc, which is often synonymous with -android* target, but not always.  Let's enable ssp based on whether __BIONIC__ is defined in the libc headers (i.e., add a grep test for __BIONIC__ in <sys/cdefs.h>)

Also please add a comment along the lines of "all versions of Bionic support stack protector".

Which exact target did you test this on?  X86_64-*-* is a pretty broad definition.

Thank you,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics
H.J. Lu May 7, 2012, 6:08 p.m. UTC | #2
On Mon, May 7, 2012 at 11:04 AM, Maxim Kuvyrkov <maxim@codesourcery.com> wrote:
> On 6/05/2012, at 7:02 PM, Igor Zamyatin wrote:
>
>> Hi!
>>
>> The patch enables stack protector for Android.
>> Android targets don't contain necessary information in features.h so
>> we explicitly enable stack protector for Android.
>>
>> Bootstrapped and regtested on x86_64. Ok to commit?
>>
>> Thanks,
>> Igor
>>
>> 2012-05-06  Igor Zamyatin  <igor.zamyatin@intel.com>
>>
>>        * configure.ac: Stack protector enabling for Android targets.
>>        * configure: Regenerate.
>>
>>
>> diff --git a/gcc/configure.ac b/gcc/configure.ac
>> index 86b4bea..c1012d6 100644
>> --- a/gcc/configure.ac
>> +++ b/gcc/configure.ac
>> @@ -4545,6 +4545,8 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
>>       gcc_cv_libc_provides_ssp,
>>       [gcc_cv_libc_provides_ssp=no
>>     case "$target" in
>> +       *-android*)
>> +         gcc_cv_libc_provides_ssp=yes;;
>>        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
>>       [# glibc 2.4 and later provides __stack_chk_fail and
>>       # either __stack_chk_guard, or TLS access to stack guard canary.
>
>
> What you really want is to enable stack protector for Bionic libc, which is often synonymous with -android* target, but not always.  Let's enable ssp based on whether __BIONIC__ is defined in the libc headers (i.e., add a grep test for __BIONIC__ in <sys/cdefs.h>)
>
> Also please add a comment along the lines of "all versions of Bionic support stack protector".
>
> Which exact target did you test this on?  X86_64-*-* is a pretty broad definition.
>

We are working on x86_64-*-linux-android target,
which uses x32.
Igor Zamyatin May 11, 2012, 9:03 p.m. UTC | #3
Hi!

Please look at the modified patch in the attachment. ChangeLog remains the same.

Tested in android environment(x86_64-*-linux-android), also
bootstrapped on x86_64-unknown-linux-gnu.
I also started regtesting on linux. Is it ok after successfull regtesting?

Thanks,
Igor

On Mon, May 7, 2012 at 10:08 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, May 7, 2012 at 11:04 AM, Maxim Kuvyrkov <maxim@codesourcery.com> wrote:
>> On 6/05/2012, at 7:02 PM, Igor Zamyatin wrote:
>>
>>> Hi!
>>>
>>> The patch enables stack protector for Android.
>>> Android targets don't contain necessary information in features.h so
>>> we explicitly enable stack protector for Android.
>>>
>>> Bootstrapped and regtested on x86_64. Ok to commit?
>>>
>>> Thanks,
>>> Igor
>>>
>>> 2012-05-06  Igor Zamyatin  <igor.zamyatin@intel.com>
>>>
>>>        * configure.ac: Stack protector enabling for Android targets.
>>>        * configure: Regenerate.
>>>
>>>
>>> diff --git a/gcc/configure.ac b/gcc/configure.ac
>>> index 86b4bea..c1012d6 100644
>>> --- a/gcc/configure.ac
>>> +++ b/gcc/configure.ac
>>> @@ -4545,6 +4545,8 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
>>>       gcc_cv_libc_provides_ssp,
>>>       [gcc_cv_libc_provides_ssp=no
>>>     case "$target" in
>>> +       *-android*)
>>> +         gcc_cv_libc_provides_ssp=yes;;
>>>        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
>>>       [# glibc 2.4 and later provides __stack_chk_fail and
>>>       # either __stack_chk_guard, or TLS access to stack guard canary.
>>
>>
>> What you really want is to enable stack protector for Bionic libc, which is often synonymous with -android* target, but not always.  Let's enable ssp based on whether __BIONIC__ is defined in the libc headers (i.e., add a grep test for __BIONIC__ in <sys/cdefs.h>)
>>
>> Also please add a comment along the lines of "all versions of Bionic support stack protector".
>>
>> Which exact target did you test this on?  X86_64-*-* is a pretty broad definition.
>>
>
> We are working on x86_64-*-linux-android target,
> which uses x32.
>
> --
> H.J.
diff mbox

Patch

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 86b4bea..c1012d6 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4545,6 +4545,8 @@  AC_CACHE_CHECK(__stack_chk_fail in target C library,
       gcc_cv_libc_provides_ssp,
       [gcc_cv_libc_provides_ssp=no
     case "$target" in
+       *-android*)
+         gcc_cv_libc_provides_ssp=yes;;
        *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
       [# glibc 2.4 and later provides __stack_chk_fail and
       # either __stack_chk_guard, or TLS access to stack guard canary.