This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Enable -zexecstack on Solaris


On Thu, May 07, 2009 at 01:36:18AM -0700, David Bartley wrote:
> Ping?
> 
> On Sat, May 2, 2009 at 10:55 PM, David Bartley
> <dtbartle@csclub.uwaterloo.ca> wrote:
> > On Sat, May 2, 2009 at 8:10 PM, Alan Modra <amodra@bigpond.net.au> wrote:
> >> On Sat, May 02, 2009 at 04:11:28PM -0700, David Bartley wrote:
> >>> The attached patch enabled executable stacks on Solaris (via
> >>> -zexecstack). On Solaris, this is achieved by setting the final
> >>> PT_LOAD section to be executable.
> >> [snip]
> >>> + ? ? * bfd/elf.c: Enable -zexecstack on Solaris.
> >>> + ? ? * bfd/configure.in: Likewise.
> >>> + ? ? * bfd/configure: Regenerate.
> >>> + ? ? * bfd/config.in: Likewise.
> >>
> >> I think bfd is the wrong place to implement this feature. ?Instead,
> >> you should arrange for ld to set SEC_CODE on .bss, which I think will
> >> result in PF_X on the PT_LOAD header covering .bss. ?Do this in a new
> >> .em file for solaris (grep for EXTRA_EM_FILE examples), probably best

Adding target hacks to elf32.em isn't quite as tidy as a new solaris
.em file, but I guess is acceptable.  Hmm, especially given that
powerpc already uses EXTRA_EM_FILE.

> >> done in ldemul_before_allocation so that you have the option of
> >> turning off link_info.execstack and noexecstack to not emit
> >> PT_GNU_STACK, which I imagine isn't much use to you.
> >
> > Thanks for the suggestion. How does this patch look?

Was there a reason why you patched after_open rather than
before_allocation?  If you make the change in the latter function then
you can set flags on the output .bss section rather than looping over
input files.  Also, I forgot one corner case:  You need to set
SEC_KEEP on the output .bss, otherwise ld will remove an empty .bss
section and the SEC_CODE flag be ignored.

> +  # GNU/kOpenSolaris uses glibc, which uses PT_GNU_STACK, but we don't need to
> +  # emit PT_GNU_STACK for Solaris proper.
> +  case ${target} in
> +    *-*-solaris2*)
> +  fragment <<EOF
> +  link_info.execstack = 0;
> +EOF

Clear noexecstack too.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]