Page MenuHomePhabricator

[Android] Use ELF TLS for Android API level 29+
Needs ReviewPublic

Authored by hctim on Jun 27 2019, 4:11 PM.



Use ELF TLS by default instead of emulated TLS for Android build targets when the API level is > 29.

Android Q features full TLS support. See release notes here and implementation details here.

Event Timeline

hctim created this revision.Jun 27 2019, 4:11 PM

Test please.

Android's ELF TLS requires lld, but the NDK doesn't default to lld yet. (I believe the NDK uses bfd on arm64 and gold everywhere else.) When the NDK Clang driver targets 29/Q+, the NDK could generate executables or shared objects using ELF TLS that don't load on 29/Q.

For reference, the linker quirks are:

  • x86-32 bfd uses an obsolete TLS relocation (R_386_TLS_TPOFF32) for relaxation
  • arm{32,64} bfd can discard the overalignment placeholder section from crtbegin.c
  • gold uses STB_LOCAL TLS/section symbols that need special handling in soinfo::relocate