This is an archive of the discontinued LLVM Phabricator instance.

simplify pie/pic handling for android
AbandonedPublic

Authored by rafael on Apr 29 2014, 7:27 AM.

Details

Reviewers
pcc
Summary

Android is quiet peculiar in that it default to PIC, not PIE. To enable PIE only optimizations on has to explicitly pass -fPIE. I just checked that behaviour with r9d sdk using gcc 4.8 -E -dM.

Currently that is implemented with some custom logic in the driver. The attached patch moves some of that to isPICDefault and isPIEDefault. The changes are

  • Declare that android isPIEDefault and isPICDefault
  • For running -cc1, give preference to isPICDefault over isPIEDefault, since that is the most restrictive.

The main behaviour is unchanged:

  • clang -target arm-linux-android -S test.c -> -mrelocation-model pic -pic-level 1
  • clang -target arm-linux-android -S test.c -fPIC -> -mrelocation-model pic -pic-level 2
  • clang -target arm-linux-android -S test.c -fPIE -> -mrelocation-model pic -pic-level 2 -pie-level 2

The one change (which is reflected in the tests) is that enabling sanitizers doesn't force PIE. It is quiet surprising that currently enabling the sanitizers moves us from PIC to PIE.

Diff Detail

Event Timeline

rafael updated this revision to Diff 8921.Apr 29 2014, 7:27 AM
rafael retitled this revision from to simplify pie/pic handling for android.
rafael updated this object.
rafael edited the test plan for this revision. (Show Details)
rafael added reviewers: chandlerc, pcc.
rafael added a subscriber: Unknown Object (MLST).
chandlerc resigned from this revision.Mar 29 2015, 12:00 PM
chandlerc removed a reviewer: chandlerc.

Resigning as this patch has gotten quite stale. If someone is still interested, update or send a new patch.

rafael abandoned this revision.Mar 29 2015, 8:10 PM

I can't even remember why I wrote this.

It was probably a drive by cleanup, so lets just delete it if it is stale.