only position independent executables pie are supported как исправить
Running a native library on Android L. error: only position independent executables (PIE) are supported
When I run native code on Android L (Nexus 5), I get the error.
error: only position independent executables (PIE) are supported.
The same code is executed correctly on my Samsung Galaxy S3 (Android 4.3).
Here is my Application.mk
However when I replace APP_PLATFORM := android-9 with APP_PLATFORM := android-16 (As I read here, PIE support appeared in Jelly Been (API level 16)), the same executable file works fine on Android L.
Is there a way to compile native code using APP_PLATFORM := android-9 and run it on Android L?
3 Answers 3
If you also need to support lower SDK levels, you’ll need to create two binaries. Some other answers I’ve seen have recommended maintaining two separate source trees with different APP_PLATFORMs, but you don’t need to do that. It’s possible to make a single Android.mk output both a PIE and a non-PIE binary.
NDK 10c and later:
The following Android.mk then creates a PIE and a non-PIE binary, but has a caveat (see below):
You’ll then have to add some sort of logic to invoke the correct binary in your code.
Unfortunately, this means you’ll have to compile the executable module twice, which can be slow. You also need to specify LOCAL_SRC_FILES and any libraries twice, which can be frustrating and difficult to keep track of. What you can do is to compile the main executable as a static library, and build executables from nothing but that static library. Static libraries do not require PIE.
This seems to work quite nicely, although a certain amount of boilerplate is still required.
NDK 10b:
NDK 10b enables PIE by default and doesn’t let you disable it, except with terrible hacks. Really, just update to 10c. I’m leaving my old answer here for reference but I wouldn’t recommend it to anyone.
Android 5.0 «error: only position independent executables (PIE) are supported.» #1
Comments
wikijm commented Oct 24, 2016
PIE is a useful security feature, as randomizing the address space makes it significantly more difficult for an attacker to exploit bugs in a program.
I get this error after:
Starting Responder.py, Ctrl-C to exit
The text was updated successfully, but these errors were encountered:
We are unable to convert the task to an issue at this time. Please try again.
The issue was successfully created but we are unable to update the comment at this time.
nvssks commented Oct 24, 2016
can you give me the output of these commands:
pm list packages qpython
getprop ro.build.version.release
Seems like the check I have for the version is not working.
qPython has a different script (with no PIE) for android >5
wikijm commented Oct 24, 2016
pm list packages qpython
nvssks commented Oct 24, 2016
You’re using qPython3, I haven’t tested Responder with Python version 3.
Quick solution would be to install qPython for Python 2.7 (until I test and update the code)
wikijm commented Oct 24, 2016 •
Thanks for your quick answer.
Same issue on QPython.
pm list packages qpython
3ntr0phy commented Oct 24, 2016
I have this issue: only PIE are supported.
How do you run the script?
pm list packages qpython
nvssks commented Oct 24, 2016
One of each should give the same error or a Python interpreter.
Seems that the version of android is not adequate for this check
3ntr0phy commented Oct 24, 2016
It doesn’t produce any error and does not open a python interpreter, it just produce me this:
127|
Nothing changes. :/
3ntr0phy commented Oct 24, 2016
Which Android version did you use for testing it?
nvssks commented Oct 24, 2016
I’m testing it on Android 6.0.1
and I had tested it on 4.7 as well.
Can you open qPython from the icon and select console?
The first line should be one of the above
3ntr0phy commented Oct 24, 2016
nvssks commented Oct 24, 2016
Pushed a new commit in https://github.com/nvssks/Android-Responder/tree/dev-1
It will try with the PIE/non-PIE version of qPython’s script if the first fails
Could you please test this version and let me know if it works
wikijm commented Oct 25, 2016
Result with the new commit:
nvssks commented Oct 25, 2016
Can you open qPython, go to console and post a screenshot?
wikijm commented Oct 25, 2016
nvssks commented Oct 25, 2016
I think I have fixed it in the latest update in dev-1
Not sure which interface Android 5.0 uses (usb0 or rndis0)
wikijm commented Jan 13, 2017
It seems to work like a charm.
Thanks a lot 🙂
OZZ-MAN commented Mar 13, 2018
Why would I be getting a Lolipop error in Nouget? I was having the understanding that «pie» was an Android 5 issue.
[GUIDE] Bypassing PIE security check (Android 5.0 up)
Hi all pretty new to alphagamers, been checking out the site as I am aspiring to increase my programming/hacking knowledge esp. when it comes to Android so thought I’d join. I had a request from a member to bring over a tutorial I wrote for fixing a new issue on Android 5.0 and up. A few modders ran into this issue using gdb and I recently solved this issue myself after some research, and as I will be trying to gain knowledge here as well, in spirit of the old Scene mantra «no leeching!» will also share knowledge whenever I can.
Specifically, 3a12: d007 beq.n 3a24 // change to e007 (b.n)
So, I decided to dig into it myself and see if I could do anythiung.
What I used:
IDA Pro 32 bit (I used the paid version, its not necessary here, free version can do as well)
Any good hex editor (my fav is Ultraedit, but Winhex, etc. don’t matter)
Rooted phone, you need to move files and change permissions
A file explorer WITH root access (ES file explorer, Root Explorer)
Step 2:
Fire up IDA Pro 32 bit. When you load the linker file for disassembly, leave default settings (ELF file, metapc engine). Let it do its thing.
that’s it for IDA, exit (no need to save database unless you want to)
Step 4:
Open your hex editor. Search for the data anyway you want, either by the address (my example 00003890), in my case I just searched the values «07 D0 D2 49» to find the spot (put enough hex values in your search to find the unique spot, don’t just put D0 even though thats what we’re editing or you may edit the wrong address). Once you’re sure you’re at the right spot, simply change it to read
Only the «D0» to «E0»? Yes it’s really that simple 😉
You should now be able to use gdb, gdbserver, and any old busybox executables that give you the PIE error.
Happy modding!
EDIT #1: added additional info in post below, link: https://boards.libre.io/posts/2819196/
EDIT #2: People have been posting questions that makes me concerned that people are modifying their file without understanding the severity of what they are doing should they mess up. PSA: MESSING WITH LINKER CAN RENDER YOUR PHONE UNUSABLE, KNOW WHAT YOU ARE DOING!!
Reference links: https://en.m.wikipedia.org/wiki/GNU_linker ftp.gnu.org/old-gnu/Manuals/ld-2.9.1
(ld basically same idea as androids linker)
Think of it this way : APK stands for android package, its a zip file, nothing more. So you are simply doing the same as double clicking a zip file on Windows and expecting it to run the program inside it (not winzip/rar but the program inside) when you tap on a program app on your Android. So try it on Windows right now, I’ll wait
. doesn’t work does it? So why does it work on Android. will finish this post today, have to leave home for a bit
ok im tired of breaking this down so Google will help if you have any other questions about linker, tl;dr don’t fk that file up lol
[FIX] [Android ‘L’] Bypassing the new PIE security check
Breadcrumb
cernekee
Senior Member
Last month, Chainfire posted a nice writeup on several new security changes happening upstream in AOSP. There has been much discussion of the SELinux changes and what that means for root apps, but I’d like to touch on another change that can affect even garden variety non-root apps: mandatory PIE (position-independent executables).
If you’re running the Android «L» developer preview image, you may have noticed that some of your native binaries no longer execute:
PIE is a useful security feature, as randomizing the address space makes it significantly more difficult for an attacker to exploit bugs in a program. However, in this case, one must trade off compatibility for security: PIE is only available in JB 4.1 and above, so most app developers targeting a wide range of Android versions have disabled PIE in their builds. The new PIE check in «L» will cause breakage for most apps that ship native executables.
As it turns out, even some of the precompiled binaries shipped with Android itself are affected, and Google has temporarily disabled PIE enforcement. It is not clear whether they will re-enable it at a later date.
Since the Android «L» preview images were built prior to Google’s latest change, they still have PIE enabled. I am attaching a flashable «bypass-pie.zip» which overwrites one byte in /system/bin/linker to bypass the PIE check:
Use this at your own risk. It works for me. The same non-PIE curl binary now runs correctly with the patched linker:
This was tested on hammerhead-lpv79-preview-ac1d8a8e.tgz. If somebody wants to test on razor-lpv79-preview-d0ddf8ce.tgz and post the result, that would be helpful.
It is not necessary to wipe any caches after flashing, although you may want to «clear data» for any apps that were crashing prior to applying the change so that they can start fresh.
Update 2014/07/21: AOSP has re-enabled the PIE check after recompiling their last non-PIE binary. I filed a ticket asking Google to revert this change in order to avoid breaking ABI compatibility.
Comments
RunasSudo commented Nov 29, 2014
Clicking Recovery/Install gives ‘There was an error installing Superuser. Please send a log of the error to the developer.’ Manually installing the su binary and attempting to run it gives:
error: only position independent executables (PIE) are supported.
The text was updated successfully, but these errors were encountered:
We are unable to convert the task to an issue at this time. Please try again.
The issue was successfully created but we are unable to update the comment at this time.
RunasSudo commented Dec 1, 2014
I’ll leave this one to the experts.
jazzrz86 commented Dec 4, 2014
The problem is, even if you are root, you are still effectively running in the shell or untrusted_app context. SElinux will stop you from doing anything. SU will need to have the policy adjustments alongside root- and it is a huge effort compared to previous Android.
The current root solution (SuperSU from ChainsDD) spawns from the zygote context and still requires a supporting binary to adjust the SElinux policies.
leesah commented Feb 8, 2015
Does this mean Lollipop cannot be rooted as previous versions and it’s pointless to install any of the three alternatives in Play store?
sparkym3 commented Feb 8, 2015
No that is not what it means. Lollipop is rootable and superSU is a great working version (though not open source).