[swift-dev] Standard shared libraries with executable stack
Sangjin Han
tinysun.net at gmail.com
Fri Jun 17 09:31:26 CDT 2016
Hi,
When linking libswiftCore.so, gold linker with --warn-execstack option
generates following messages.
/usr/bin/ld.gold: warning: lib/swift/linux/x86_64/swift_begin.o: missing
.note.GNU-stack section implies executable stack
/usr/bin/ld.gold: warning: lib/swift/linux/x86_64/swift_end.o: missing
.note.GNU-stack section implies executable stack
I found the web page about the GNU-stack section.
http://en.chys.info/2010/12/note-gnu-stack/
After quick testing in my build system (Linux + execstack -q), I think we
should append one line to stdlib/public/runtime/swift_sections.S, or pass
the proper option to the linker.
The line is
.section .note.GNU-stack,"", at progbits
and the option is
'-z noexecstack' (or -Wl,-z -Wl,noexecstack for clang++).
I don't know which method is better, to patch swift_section.S or to patch
linking option.
-Han Sangjin
2016-06-17 16:27 GMT+09:00 Dmitri Gribenko <gribozavr at gmail.com>:
> Hi,
>
> While there wight be an issue in WSL with executable stacks, Swift
> does not really need one. If the binary is actually asking for one,
> it would be great if we could figure out a way to ask the gold linker
> to not mark stacks as executable.
>
> Dmitri
>
> On Thu, Jun 16, 2016 at 11:39 PM, Sangjin Han <tinysun.net at gmail.com>
> wrote:
> > Hi, Kim.
> >
> > The test result is same on WSL build 14342.
> >
> > There is similar report in
> > https://github.com/Microsoft/BashOnWindows/issues/286 .
> > MS engineer recognized this and replied that give them feedback on the
> > uservoice for prioritizing, currently it has only 3 votes.
> >
> > -Han Sangjin
> >
> > 2016-06-16 21:17 GMT+09:00 Jongsu Kim via swift-dev <swift-dev at swift.org
> >:
> >>
> >> Hi,
> >>
> >>> This could have been caused by our switch from the BFD linker to gold.
> >>> Could you try linking a hello world program using gold linker and
> >>> running it in WSL?
> >>
> >>
> >> I tried to build Swift by not using -fuse-gold option and the result was
> >> same.
> >>
> >>
> >>> Are you sure that PROT_GROWSDOWN is the flag that enables executable
> >>> stack? I thought that's what PROT_EXEC is for. I'm not sure what
> >>> PROT_GROWSDOWN actually changes, if I were to speculate, I'd say it
> >>> could be a marker that means "this is a stack" or maybe even be just a
> >>> performance hint.
> >>
> >>
> >> You are right. The executable stack is enabled by PROT_EXEC.
> >>
> >> But Swift shared library's executable stack seems to set PROT_EXEC AND
> >> PROT_GROWSDOWN according to strace.
> >>
> >> I don't know what causes Swift shared library to have executable stack
> >> since Febrary 25 snapshot. Febrary 8 snapshot and Swift 2.X branches
> have no
> >> such executable stack shared library.
> >>
> >> Thanks,
> >>
> >>
> >> -Kim, Jongsu
> >>
> >> _______________________________________________
> >> swift-dev mailing list
> >> swift-dev at swift.org
> >> https://lists.swift.org/mailman/listinfo/swift-dev
> >>
> >
>
>
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160617/062f7d5f/attachment.html>
More information about the swift-dev
mailing list