[swift-dev] Standard shared libraries with executable stack

김종수 kimjs29 at gmail.com
Thu Jun 16 05:54:32 CDT 2016


Hi, Han

The test code is as follows:

#include <stdio.h>
#include <dlfcn.h>

int main()
{
    if
(!dlopen("swift-3.0-preview-1-ubuntu14.04/usr/lib/swift/linux/libswiftCore.so",
RTLD_LAZY | RTLD_GLOBAL))
        fprintf(stderr, "%s\n", dlerror());
}

The executable stack flag is queried as follows:

sudo execstack -q
swift-3.0-preview-1-ubuntu14.04/usr/lib/swift/linux/libswiftCore.so

If the executable stack flag is set, the stderr output is as follows:

swift-3.0-preview-1-ubuntu14.04/usr/lib/swift/linux/libswiftCore.so: cannot
enable executable stack as shared object requires: Invalid argument

And strace ouput tail is as follows:

mprotect(0x7ffffe5c3000, 4096,
PROT_READ|PROT_WRITE|PROT_EXEC|PROT_GROWSDOWN) = -1 EINVAL (Invalid
argument)
close(3)                                = 0
write(2, "swift-3.0-preview-1-ubuntu14.04/"...,
144swift-3.0-preview-1-ubuntu14.04/usr/lib/swift/linux/libswiftCore.so:
cannot enable executable stack as shared object requires: Invalid argument)
= 144
exit_group(144)                         = ?
+++ exited with 144 +++

If the executable stack flag is cleared by using execstack -c option, there
is no error.

Of course on Ubuntu 14.04 there is no error with the executable stack flag
on.

To clarify my request, I don't know how the Swift shared libraries'
executable stack flag has been set since Febrary 25 snapshot because
Febrary 8 snapshot and Swift 2.X branches have no such executable stack
shared libraries.

I tested on WSL Build 14366.

Thanks.


On Wed, Jun 15, 2016 at 9:48 AM, Sangjin Han <tinysun.net at gmail.com> wrote:

> Hi, Kim.
>
> I have the WSL on Windows Preview.
>
> Could you show the test source/command ?
>
> -Han Sangjin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160616/1a1bd1cb/attachment.html>


More information about the swift-dev mailing list