Bug 12143 - Support PIE
Summary: Support PIE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: 6.4 (async)
Assignee: Zoltan Varga
Depends on:
Reported: 2013-05-07 16:39 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2013-07-23 07:03 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Rolf Bjarne Kvinge [MSFT] 2013-05-07 16:39:32 UTC
Right now we don't support PIE because of this:

warning MT5303: Native linking warning: ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in method_addresses from (...)/System.Xml.Linq.dll.armv7.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

The problem is that Apple has started warning about executables that doesn't have PIE enabled when publishing to the App Store, so we'll have to fix this sooner rather than later.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-05-07 16:40:25 UTC
Zoltan, would it be possible to fix method_addresses to be PIE-compatible?
Comment 2 Zoltan Varga 2013-05-07 19:43:55 UTC
The old approach of storing offsets into the method_addresses table was position independent, but didn't work because the linker was reordering stuff, so we switched to absolute addresses, which are not position independent.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-05-08 19:07:33 UTC
Does that mean there is no way to fix both cases simultaneously?
Comment 4 Zoltan Varga 2013-05-08 19:53:23 UTC
We might be able to do it by using the old method and exposing the symbols to the linker so it does the offset calculations.
How can see that PIE warning ?
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-05-09 09:39:15 UTC
* Search for "-Wl,-no_pie" in monotouch/tools/mtouch/mtouch.cs and remove that code.
* Rebuild MonoTouch.
* Create a new project from a template, select a device configuration, disable the linker, add "-v -v -v" to the additional mtouch arguments and build.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2013-05-13 06:34:56 UTC
If you instead of removing "-Wl,-no_pie" replace it with "-Wl,-pie", the warning seems to reproduce reliably on both 6.2 and 6.3.
Comment 7 Zoltan Varga 2013-05-13 16:08:25 UTC
Committed a possible fix to master-3.0, we could backport it if turns out to be stable.
Comment 10 Zoltan Varga 2013-06-24 17:34:21 UTC
Should be fixed now.
Comment 12 Zoltan Varga 2013-06-25 11:56:01 UTC
That should be fixed.
Comment 13 narayanp 2013-07-23 07:03:30 UTC
Today we have checked this issue with following builds:

Mac lion 10.7.4
X.S 4.0.10 (Build 7)
Mono 3.1.2
Xamarin.iOS 6.4.0-2

To verify this issue we have created a iOS project template and run the application in release mode after selection Linker as Don't link and option LLVM. We are successfully able to run the application on device.

Also we have tried it only selecting Linker as Don't Link and use -v -v -v in mtouch argument and the build the application, Application builds successfully this is the gist for the same: https://gist.github.com/saurabh360/d5512f2f22cfdd9381a7

Changing the status to Verified.