diff --git a/syncthing/build-syncthing.py b/syncthing/build-syncthing.py index 06ad9f04..308c3ded 100644 --- a/syncthing/build-syncthing.py +++ b/syncthing/build-syncthing.py @@ -22,12 +22,14 @@ BUILD_TARGETS = [ 'goarch': 'arm', 'jni_dir': 'armeabi', 'cc': 'arm-linux-androideabi-clang', + 'patch_underaligned_tls': 'yes', }, { 'arch': 'arm64', 'goarch': 'arm64', 'jni_dir': 'arm64-v8a', 'cc': 'aarch64-linux-android-clang', + 'patch_underaligned_tls': 'yes', 'min_sdk': 21, }, { @@ -247,6 +249,55 @@ def install_ndk(): os.environ["ANDROID_NDK_HOME"] = ndk_home_path +def artifact_patch_underaligned_tls(artifact_fullfn): + import struct + + with open(artifact_fullfn, 'r+b') as f: + f.seek(0) + hdr = struct.unpack('16c', f.read(16)) + if hdr[0] != b'\x7f' or hdr[1] != b'E' or hdr[2] != b'L' or hdr[3] != b'F': + print('artifact_patch_underaligned_tls: Not an ELF file') + return None + + if hdr[4] == b'\x01': + # 32 bit code + f.seek(28) + offset = struct.unpack('