Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustc produces shared objects rather than executables #19688

Closed
mitchelldm opened this Issue Dec 10, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@mitchelldm
Copy link

mitchelldm commented Dec 10, 2014

Running file on Rust executables produces this output:

/usr/local/bin/rustc: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

Executables produced by other compilers, such as Clang and GCC, have a different result:

/usr/lib/llvm-3.5/bin/clang: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=28da30b6a880213e65f2b23b6ff53776a35d35cb, stripped
/usr/bin/gcc-4.9: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=d182242d47da0d32e551a92278787b7b4375c417, stripped

The result of this difference is that while executing Rust programs from the command line works fine, opening them through GUI file managers produces this error, which is the same as when you try to open shared libraries (.so):
There is no application to open "shared library".

This issue is present in all Rust executables I have encountered, including those obtained from rustup.sh.

@thestinger

This comment has been minimized.

Copy link
Contributor

thestinger commented Dec 10, 2014

Your file manager is buggy and doesn't know how to run executables with ASLR support. It's using the output of file or libmagic which will detect relocatable executables as shared objects. There's nothing Rust can do about that.

Rust defaults to producing position independent executables to enable ASLR. This can be enabled with gcc or clang by using -fPIE to build object files and -pie to link them and is the default on some distributions. The gcc and clang default can be replicated with rustc using -C dynamic-no-pic but it's not likely that you want that.

@thestinger

This comment has been minimized.

Copy link
Contributor

thestinger commented Dec 10, 2014

Here's the file / libmagic bug:

http://bugs.gw.com/view.php?id=404

@mitchelldm

This comment has been minimized.

Copy link
Author

mitchelldm commented Dec 10, 2014

Thanks for the link. Hopefully this issue will be resolved soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.