diff --git a/README.md b/README.md index 77defec..94a54f0 100644 --- a/README.md +++ b/README.md @@ -46,4 +46,5 @@ Compiled executables should run properly on Android 8 and above. - Patches from [its-pointless](https://github.com/its-pointless) - Patches from [Android GCC 4.9](https://android.googlesource.com/toolchain/gcc) - Sysroot from [NDK](https://github.com/android/ndk) +- Align fix script from [termux-ndk](https://github.com/Lzhiyong/termux-ndk/blob/master/patches/align_fix.py) - Wiki pages from [Termux](https://github.com/termux) diff --git a/bin/emerald-alignfix b/bin/emerald-alignfix new file mode 100755 index 0000000..95429ff --- /dev/null +++ b/bin/emerald-alignfix @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import struct +import sys +import os + +if len(sys.argv) < 2: + print('Usage: ' + os.path.basename(sys.argv[0]) + ' input_file') + exit() + +with open(sys.argv[1], 'r+b') as f: + f.seek(0) + hdr = f.read(16) + if hdr[0] != 0x7f or hdr[1] != ord('E') or hdr[2] != ord('L') or hdr[3] != ord('F'): + raise Exception('Not an elf file') + + if hdr[4] == 1: + # 32 bit code + f.seek(28) + offset = struct.unpack('