public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix up libffi linux64*.S for ppc32-linux
@ 2014-09-10 14:48 Jakub Jelinek
  2014-09-11  0:12 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2014-09-10 14:48 UTC (permalink / raw)
  To: Alan Modra, libffi-discuss, gcc-patches

Hi!

I've noticed that on 4.8 branch libgo recently (in the last few months)
started being linked with
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x10
i.e. requiring executable stack on powerpc-linux (32-bit).

The problem is that we link into libffi linux64.o and linux64_closure.o
unconditionally, both for 32-bit and 64-bit compilations, just for 32-bit
ones all the assembly is ifdefed out, so they have just empty sections.
The .note.GNU-stack section isn't emitted in that case either, which means
that the linker conservatively treats those as possibly needing executable
stack.

The following patch should fix that, ok for trunk/4.9/4.8?

BTW, I wonder if e.g. libffi/src/arm/trampoline.S or
libffi/src/aarch64/sysv.S shouldn't have those notes too (note, both of
those were added after 2008 when most of the *.S files were marked that
way).

2014-09-10  Jakub Jelinek  <jakub@redhat.com>

	* src/powerpc/linux64.S: Emit .note.GNU-stack even when
	POWERPC64 is not defined.
	* src/powerpc/linux64_closure.S: Likewise.  Also test _CALL_ELF == 2.

--- libffi/src/powerpc/linux64.S.jj	2013-12-10 08:52:16.000000000 +0100
+++ libffi/src/powerpc/linux64.S	2014-09-10 16:36:23.881137722 +0200
@@ -254,7 +254,8 @@ ffi_call_LINUX64:
 	.align 3
 .LEFDE1:
 
-# if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
+#endif
+
+#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
 	.section	.note.GNU-stack,"",@progbits
-# endif
 #endif
--- libffi/src/powerpc/linux64_closure.S.jj	2013-12-10 08:52:16.000000000 +0100
+++ libffi/src/powerpc/linux64_closure.S	2014-09-10 16:37:38.104747027 +0200
@@ -381,7 +381,8 @@ ffi_closure_LINUX64:
 	.align 3
 .LEFDE1:
 
-# if defined __ELF__ && defined __linux__
+#endif
+
+#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
 	.section	.note.GNU-stack,"",@progbits
-# endif
 #endif

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix up libffi linux64*.S for ppc32-linux
  2014-09-10 14:48 [PATCH] Fix up libffi linux64*.S for ppc32-linux Jakub Jelinek
@ 2014-09-11  0:12 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2014-09-11  0:12 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: libffi-discuss, gcc-patches

On Wed, Sep 10, 2014 at 04:48:33PM +0200, Jakub Jelinek wrote:
> 	* src/powerpc/linux64.S: Emit .note.GNU-stack even when
> 	POWERPC64 is not defined.
> 	* src/powerpc/linux64_closure.S: Likewise.  Also test _CALL_ELF == 2.

Looks reasononable to me, and oops, I think I introduced this problem
when adding ELFv2 support by moving those notes.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-11  0:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10 14:48 [PATCH] Fix up libffi linux64*.S for ppc32-linux Jakub Jelinek
2014-09-11  0:12 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).