Patchwork [PATCH/MIPS] Emit stack executable note

login
register
mail settings
Submitter Andrew Pinski
Date July 26, 2012, 12:52 a.m.
Message ID <CA+=Sn1=TbMGsZ-YUDxVyYXV_iuLDuhssiyfzO8MjL8qnRH4T_w@mail.gmail.com>
Download mbox | patch
Permalink /patch/173310/
State New
Headers show

Comments

Andrew Pinski - July 26, 2012, 12:52 a.m.
Hi,
  The Linux kernel already supports non-executable stack since around
February 2010.  This patch has GCC emit the notes that are associated
with non-executable stack.

OK?  Bootstrapped and tested on mips64-linux-gnu with kernel already
supporting the non-executable stack with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

* config/mips/linux-common.h (TARGET_ASM_FILE_END): Define.
Hans-Peter Nilsson - July 26, 2012, 8:53 a.m.
On Wed, 25 Jul 2012, Andrew Pinski wrote:
> Hi,
>   The Linux kernel already supports non-executable stack since around
> February 2010.  This patch has GCC emit the notes that are associated
> with non-executable stack.

What does the kernel do when the note isn't present?

> OK?  Bootstrapped and tested on mips64-linux-gnu with kernel already
> supporting the non-executable stack with no regressions.
>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
>
> * config/mips/linux-common.h (TARGET_ASM_FILE_END): Define.
>

I can't quote your non-inline patch so I'll copy-paste it.

+
+/* For MIPS, the default is to assume *no* executable stack, so output
+    an executable-stack-note only when needed.  */
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack

The comment is wrong, your patch is always emitting the note.
Besides IIRC, *glibc* defaults to an executable stack for MIPS,
so you need to emit it if (!trampolines_created) or something
like that.  See the CRIS cris_file_end from which the comment
seems copy-pasted, but the opposite condition. :)

If the kernel and glibc are in contradiction regarding the
default, you do need to use a slightly different expression,
checking too whether you're creating an executable, if you
really mean to emit the note only when needed.

brgds, H-P
Joseph S. Myers - July 26, 2012, 2:12 p.m.
On Wed, 25 Jul 2012, Andrew Pinski wrote:

> * config/mips/linux-common.h (TARGET_ASM_FILE_END): Define.

Do you also need to change libgcc/config/mips/*.S to include the 
appropriate note?

Patch

Index: config/mips/linux-common.h
===================================================================
--- config/mips/linux-common.h	(revision 189877)
+++ config/mips/linux-common.h	(working copy)
@@ -56,3 +56,7 @@  along with GCC; see the file COPYING3.  
 		       GNU_USER_TARGET_ENDFILE_SPEC,			\
 		       GNU_USER_TARGET_MATHFILE_SPEC " "		\
 		       ANDROID_ENDFILE_SPEC)
+
+/* For MIPS, the default is to assume *no* executable stack, so output
+    an executable-stack-note only when needed.  */
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack