This is an archive of the discontinued LLVM Phabricator instance.

Enable -pie and --enable-new-dtags by default on Android.
ClosedPublic

Authored by eugenis on Sep 29 2017, 2:50 PM.

Details

Summary

Also enable -no-pie on Gnu toolchain (previously available on Darwin only).

Non-PIE executables won't even start on recent Android, and DT_RPATH is ignored by the loader.

Event Timeline

eugenis created this revision.Sep 29 2017, 2:50 PM
srhines accepted this revision.Oct 24 2017, 11:49 PM
This revision is now accepted and ready to land.Oct 24 2017, 11:49 PM
This revision was automatically updated to reflect the committed changes.
pcc added a subscriber: pcc.Jan 15 2019, 2:51 PM
pcc added inline comments.
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
814 ↗(On Diff #120306)

Why only on API level >= 16? If I create an executable targeting an older API level, it should still work on higher API levels.

eugenis marked an inline comment as done.Jan 15 2019, 3:12 PM
eugenis added inline comments.
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
814 ↗(On Diff #120306)

Because it needs to work on lower API levels, too. I think at some point PIE was actually not supported, so there is no good default that works for everyone.

pcc added inline comments.Jan 15 2019, 3:31 PM
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
814 ↗(On Diff #120306)

I see. Looking at the tags in which https://github.com/aosp-mirror/platform_bionic/commit/d9ad62343c2db6b66a5fa597c9b20a6faabd7a9a was present, support was indeed added in Jelly Bean, which was API level 16. So this is correct.

danalbert added inline comments.Jan 15 2019, 4:06 PM
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
814 ↗(On Diff #120306)

Correct. Supported as of 16, required as of 21.

The NDK itself doesn't actually support pre-16 any more, but probably best for Clang to do the right thing anyway in case some user is trying to maintain their own sysroot for ICS that uses a modern Clang.