<div dir="ltr">Hi,<div><br></div><div>When linking libswiftCore.so, gold linker with --warn-execstack option generates following messages.</div><div><div>/usr/bin/ld.gold: warning: lib/swift/linux/x86_64/swift_begin.o: missing .note.GNU-stack section implies executable stack</div><div>/usr/bin/ld.gold: warning: lib/swift/linux/x86_64/swift_end.o: missing .note.GNU-stack section implies executable stack</div></div><div><br></div><div>I found the web page about the GNU-stack section. <a href="http://en.chys.info/2010/12/note-gnu-stack/">http://en.chys.info/2010/12/note-gnu-stack/</a> </div><div><br></div><div>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.</div><div>The line is </div><div> .section<span class="" style="white-space:pre">        </span>.note.GNU-stack,"",@progbits </div><div>and the option is </div><div> '-z noexecstack' (or -Wl,-z -Wl,noexecstack for clang++).</div><div><br></div><div>I don't know which method is better, to patch swift_section.S or to patch linking option.</div><div><br></div><div>-Han Sangjin</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-17 16:27 GMT+09:00 Dmitri Gribenko <span dir="ltr"><<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
While there wight be an issue in WSL with executable stacks, Swift<br>
does not really need one. If the binary is actually asking for one,<br>
it would be great if we could figure out a way to ask the gold linker<br>
to not mark stacks as executable.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dmitri<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Thu, Jun 16, 2016 at 11:39 PM, Sangjin Han <<a href="mailto:tinysun.net@gmail.com">tinysun.net@gmail.com</a>> wrote:<br>
> Hi, Kim.<br>
><br>
> The test result is same on WSL build 14342.<br>
><br>
> There is similar report in<br>
> <a href="https://github.com/Microsoft/BashOnWindows/issues/286" rel="noreferrer" target="_blank">https://github.com/Microsoft/BashOnWindows/issues/286</a> .<br>
> MS engineer recognized this and replied that give them feedback on the<br>
> uservoice for prioritizing, currently it has only 3 votes.<br>
><br>
> -Han Sangjin<br>
><br>
> 2016-06-16 21:17 GMT+09:00 Jongsu Kim via swift-dev <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>>:<br>
>><br>
>> Hi,<br>
>><br>
>>> This could have been caused by our switch from the BFD linker to gold.<br>
>>> Could you try linking a hello world program using gold linker and<br>
>>> running it in WSL?<br>
>><br>
>><br>
>> I tried to build Swift by not using -fuse-gold option and the result was<br>
>> same.<br>
>><br>
>><br>
>>> Are you sure that PROT_GROWSDOWN is the flag that enables executable<br>
>>> stack? I thought that's what PROT_EXEC is for. I'm not sure what<br>
>>> PROT_GROWSDOWN actually changes, if I were to speculate, I'd say it<br>
>>> could be a marker that means "this is a stack" or maybe even be just a<br>
>>> performance hint.<br>
>><br>
>><br>
>> You are right. The executable stack is enabled by PROT_EXEC.<br>
>><br>
>> But Swift shared library's executable stack seems to set PROT_EXEC AND<br>
>> PROT_GROWSDOWN according to strace.<br>
>><br>
>> I don't know what causes Swift shared library to have executable stack<br>
>> since Febrary 25 snapshot. Febrary 8 snapshot and Swift 2.X branches have no<br>
>> such executable stack shared library.<br>
>><br>
>> Thanks,<br>
>><br>
>><br>
>> -Kim, Jongsu<br>
>><br>
>> _______________________________________________<br>
>> swift-dev mailing list<br>
>> <a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
>> <a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-dev</a><br>
>><br>
><br>
<br>
<br>
<br>
</div></div><div class="HOEnZb"><div class="h5">--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
</div></div></blockquote></div><br></div>