Skip to content

Explicitly pass -no-pie #43693

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

Closed
wants to merge 1 commit into from
Closed

Conversation

sfackler
Copy link
Member

@sfackler sfackler commented Aug 6, 2017

Some linkers (e.g. Debian and Arch's) that are configured to make PIEs
by default will make dynamically linked executables that don't actually
dynamically link to anything. Fix that by explicitly passing -no-pie in
those cases.

Closes #43647

I wasn't able to test this out manually - is there an easy way to make a suitable musl root?

@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@sfackler
Copy link
Member Author

sfackler commented Aug 6, 2017

r? @alexcrichton

@mattico
Copy link
Contributor

mattico commented Aug 6, 2017

https://github.com/emk/rust-musl-builder could help test this.

@sfackler
Copy link
Member Author

sfackler commented Aug 6, 2017

Is that setup to build rustc itself? It needs a somewhat specialized setup with a libunwind.a as well as just MUSL.

@mattico
Copy link
Contributor

mattico commented Aug 6, 2017

Ah, well the old rust buildbot images may still work: https://github.com/rust-lang/rust-buildbot/blob/master/slaves/linux/Dockerfile

@alexcrichton
Copy link
Member

Looks good to me! There's a bunch of conditions that lead up to passing -pie, and shouldn't we always pass -no-pie if we don't hit the -pie path?

r=me w/ that tweak (if ok) and once you're happy with some testing

Some linkers (e.g. Debian and Arch's) that are configured to make PIEs
by default will make dynamically linked executables that don't actually
dynamically link to anything. Fix that by explicitly passing -no-pie in
those cases.

Closes rust-lang#43647
@aidanhs
Copy link
Member

aidanhs commented Aug 7, 2017

This is not going to interact well with PR #40113, where pie is enabled all the time.

However, there's something interesting in #40113 (comment), where pie is enabled but it actually does produce 'statically linked dynamic binaries'. For comparison, first the output from the issue that motivated this PR (#43647):

$ file ./target/x86_64-unknown-linux-musl/debug/bla
./target/x86_64-unknown-linux-musl/debug/bla: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8c6e0c77c39c031c76d95379bfe2593165b13a70, with debug_info, not stripped

And from the 'native musl' PR:

~ $ file hello
hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped, with debug_info

Note there's no interpreter in the latter.

Since this is something we're going to have to do anyway, it'd be nice if we could figure out how to actually generate static binaries with pie enabled. cc @shizmob

@sfackler
Copy link
Member Author

sfackler commented Aug 7, 2017

Ah, this PR may not be needed at all then, right?

@aidanhs
Copy link
Member

aidanhs commented Aug 7, 2017

Potentially, but I'm not sure what about the arch linker is causing it to generate binaries like that so I've no idea if it'll be fixed. Worth a shot though I suppose.

@sfackler
Copy link
Member Author

sfackler commented Aug 7, 2017

I think I'll close this for now and check back in after #40113 lands.

@sfackler
Copy link
Member Author

Reopening - r? @alexcrichton

@sfackler
Copy link
Member Author

Oh, nevermind github seems unhappy with that - opening a new PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants