[PATCH] PT_GNU_STACK

Andrew Cagney ac131313@redhat.com
Sun Jun 1 22:16:00 GMT 2003


> On Sun, Jun 01, 2003 at 05:34:00PM -0400, Andrew Cagney wrote:
> 
>> >Hi Andrew,
>> >
>> >
> 
>> >>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
> 
>> 
>> Having empty sections would let binutils ignore the problem entirely. 
>> Instead it could just pass the sections through.
> 
> 
> That's not true. If ld doesn't handle them specially
> during ld -r and final link, then there is no way to differentiate between
> all input files .note.GNU-stack.rw and some input files .note.GNU-stack.rw
> and some input files without any note section (in the former case
> non-exec stack can be used, in the latter case most probably shouldn't,
> as no assumptions can be made on whether the remaining objects need
> or don't need exec stack).

That's true.  But is it reasonable to assume that a non-branded .o file 
should be rwx?  It's going to make it too easy to accidently create 
programs with an executible stack.

> Another thing is efficiency. If there is more than one PT_ segment for this
> stack or if kernel/ld.so has to read some segment and analyze it to find
> out whether exec stack is needed or not, it means more runtime overhead.
> And IMHO the default should be clear from what the ABI allows or doesn't
> allow. If say i?86-*-linux* so far could assume executable stack, then the
> default for old .o files must be executable stack.

The intent was names, not contents, could be used to make the decision 
and that would avoid the double read.

Andrew




More information about the Binutils mailing list