FRV and Blackfin PT_GNU_STACK

Jie Zhang jzhang918@gmail.com
Tue Jun 20 11:43:00 GMT 2006
On 6/19/06, Alan Modra <amodra@bigpond.net.au> wrote:
> When testing SIZEOF_HEADERS relaxation, I noticed that a fix in
> http://sources.redhat.com/ml/binutils/2006-05/msg00318.html for PT_NOTE
> p_memsz broke PT_GNU_STACK p_memsz for frv and bfin.  To get this field
> set, these ports create an output .stack section with the desired stack
> size (and alignment) and tack it on to the PT_GNU_STACK header using
> elf_backend_modify_segment_map.  It's very much a hack, since you're not
> supposed to create sections like this in the output bfd.  One
> consequence is that the .stack section header doesn't get its type
> correct (you'd expect NOBITS) or size set (which is fortunate in a way,
> because otherwise you'd end up with a large useless PROGBITS section in
> the object file).
>
> The question I have is this:  Do you want a .stack section in the output
> file?  Or should this section really be attached as an input section
> that extends the .bss output section?  Or do without the section
> entirely and just magically tweak PT_GNU_STACK?
>
[Replying from my ADI address failed. So I use my Gmail account. ]

>From the code of binfmt_elf_fdpic.c in linux kernel, it seems the
.stack section is not needed. The kernel gets the stack size for the
FDPIC ELF application is from p_memsz of the PT_GNU_STACK segment.

I'm not sure if my thought is right on why a .stack section is used
here, since I'm not the original writer of the code. The .stack
section is used to help set the PT_GNU_STACK segment size, since
segment size is calculated by sum up the size of all the sections of
it. If we want to eliminate the use of the section entirely, where can
we magically tweak PT_GNU_STACK? Is there already a hook we can use or
we have to add one?

Jie



More information about the Binutils mailing list