[RFC] [PATCH, AARCH64] Machine descriptions to support stack smashing protection

Venkataramanan Kumar venkataramanan.kumar@linaro.org
Wed Nov 20 16:27:00 GMT 2013


Hi Joseph,

On 19 November 2013 21:53, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Tue, 19 Nov 2013, Jakub Jelinek wrote:
>
>> On Tue, Nov 19, 2013 at 04:30:21PM +0530, Venkataramanan Kumar wrote:
>> > This is RFC patch that adds machine descriptions to support stack
>> > smashing protection in AArch64.
>>
>> Most of the testsuite changes look wrong.  The fact that aarch64
>> gets stack protector support doesn't mean all other targets do as well.
>> So please leave all the changes that remove native or stack_protector
>> requirements out.
>
> The tests for "target native" look wrong for me ("native" conditionals
> only make sense for special cases such as guality tests that expect to
> exec another tool on the host) - so I think they should be removed, but
> that removal needs submitting as a separate patch.
>

Yes apologies for that, I will send another patch.

> I would like to see a clear description of what happens with all eight
> combinations of (glibc version does or doesn't support this, GCC building
> glibc does or doesn't support this, GCC building user program does or
> doesn't support this).  Which of the (GCC building glibc, glibc)
> combinations will successfully build glibc?  Will all such glibcs be
> binary-compatible?  Will both old and new GCC work for building user
> programs with both old and new glibc?

Can you please clarify why we need to consider "the gcc compiler that
builds the glibc" in the combinations you want me to describe. I am
not able to understand that.

I tested the below three GCC compiler versions for building user programs.

1) GCC trunk (without my patch) generates code for "stack protection
set/test" when -fstack-protector-all is enabled.
This is based on global variable  "__stack_chk_guard" access, which
glibc supports from version 2.4.

-----snip-----
         adrp    x0, __stack_chk_guard
         add     x0, x0, :lo12:__stack_chk_guard
         ldr     x0, [x0]
         str     x0, [x29,24]
-----snip-----

GCC has generic code emitted for stack protection, enabled for targets
where frame growth is downwards. The patch for frame growing downwards
in Aarch64 is recently committed in trunk.

2) Now with the patch, GCC compiler will generate TLS based access.

----snip-----
   mrs     x0, tpidr_el0
   ldr     x1, [x0,-8]
   str     x1, [x29,24]
-----snip-----

I need to check if target glibc for Aarch64 supports TLS based ssp
support. Currently some targets check and generate TLS based access
when glibc version is >=2.4.

3) GCC linaro compiler packaged with open embedded image and which I
boot in V8 foundation model as I don't have access to Aarch64 hardware
yet.

It will not emit any stack protection code.
test.c:1:0: warning: -fstack-protector not supported for this target
[enabled by default]

regards,
Venkat.



More information about the Gcc-patches mailing list