[PATCH] PT_GNU_STACK

Andrew Cagney ac131313@redhat.com
Mon May 26 21:57:00 GMT 2003


> Hi!
> 
> This patch introduces PT_GNU_STACK segment header, which tells the kernel or
> dynamic linker whether the binary or library needs executable stack or not.
> GCC would need to create
> .section .note.GNU-stack, ""
> in each object which does not require executable stack and
> .section .note.GNU-stack, "x"
> in each object which requires executable stack.
> For backwards compatibility, objects without this section are considered
> as needing executable stack, unless all input objects don't have this
> section, in which case no PT_GNU_STACK segment header is created.
> During linking, this can be overridden with -z execstack or -z noexecstack.
> 
Wouldn't two note sections work better:

	if (.note.GNU-stack.rwx)
	  stack read-write-executable
	else if (.note.GNU-stack.rw)
	  stack read-write
	else
	  stack $KERNEL_CONFIG_VARIABLE

gcc generating one or the other (all empty).

I also think it is wrong to assume that the kernel's default is 
read-write-execute.  Look at Solaris, it was made a kernel configuration 
option and defaulted to no-exec.

Finally, some OSs brand the executible with the OS/ABI so that the 
loader knows how to handle it.

I don't think any of these involve binutils changes.

enjoy,
Andrew




More information about the Binutils mailing list