-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Milestone
Description
NDK version: r18b
Architecture: tested on aarch64 (probably others as well)
Host OS: tested on Linux (probably others as well)
This bug is most probably caused by https://sourceware.org/bugzilla/show_bug.cgi?id=22829
To reproduce, compile an executable (or shared library) with lld and relro enabled then strip or objcopy it. This last step will disable relro by deleting the GNU_RELRO segment.
Possible solutions:
- update objcopy and strip to binutils >= 2.31
- cherry-pick the fix from https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f
- do not use objcopy and strip at all (provide llvm-objcopy and llvm-strip instead which do not have this problem)
Example file and command to reproduce:
// hello.c
#include <stdio.h>
int main(void)
{
puts("Hello world!");
return 0;
}nggpc% $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-none-linux-android --sysroot $NDK/platforms/android-21/arch-arm64 -L$NDK/sources/cxx-stl/llvm-libc++/libs/arm64-v8a -isystem $NDK/sysroot/usr/include -isystem $NDK/sysroot/usr/include/aarch64-linux-android -gcc-toolchain $NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 -fuse-ld=lld -o original hello.c
nggpc% $NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/objcopy original copied
nggpc% cp original stripped
nggpc% $NDK/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/strip stripped
nggpc% readelf -We original |grep RELRO
GNU_RELRO 0x030000 0x0000000000030000 0x0000000000030000 0x000200 0x001000 R 0x1
nggpc% readelf -We copied |grep RELRO
[1] 15327 done readelf -We copied |
15328 exit 1 grep --color=auto RELRO
nggpc% readelf -We stripped |grep RELRO
[1] 15406 done readelf -We stripped |
15407 exit 1 grep --color=auto RELROReactions are currently unavailable