Repository navigation
Fix proot TLS underalignment for all ABIs and rebuild the four proot binaries - #27
GlobalTechInfo wants to merge 4 commits into
Conversation
…1.107.101 - Update proot to v5.1.107.101 (commit 968ae1be) with link2symlink fix - Patch PT_TLS p_align 8->64 for arm64-v8a to satisfy bionic's TLS alignment requirement - Build with NDK r27c for arm64-v8a - This fixes the 'TLS segment underaligned' abort on Android 14+ devices
…for arm64 - Update proot to v5.1.107.101 (commit 968ae1be) with link2symlink fix - Fix TLS alignment for arm64-v8a: patch PT_TLS p_align 8->64 - armv7 binary built with linker script for TLS alignment (known issue: TLS alignment not fully fixed) - All 4 architectures built with proot v5.1.107.101 - Proot binaries updated in jniLibs for all 4 architectures
…ries bionic's ARM32 static-TLS check (StaticTlsLayout in bionic_elf_tls.cpp) gates on p_align AND the vaddr skew together: a plain NDK link emits p_align 8 with a 16-aligned vaddr, which aborts on-device with "executable's TLS segment is underaligned ... needs to be at least 32 for ARM Bionic". Patching the program header alone cannot fix the vaddr half, because p_vaddr also feeds init_ptr, the address bionic copies the TLS template from. Re-link armv7 and i686 with a linker script that START-aligns .tdata at 32 (PT_TLS p_align 32, skew 0); the previous scripts only end-aligned .tdata and their ld.bfd re-link was a no-op (the NDK ships no ld.bfd). 64-bit keeps the p_align 64 program-header patch, which now actually writes the file back. build-proot.sh: the -T script is baked into the main link, the 32-bit branch verifies instead of the dead re-link, the ABI case is fixed (i686's ABI is "x86"), and the loader page-size injection is idempotent. All four ABIs rebuilt from d4d2a19: arm64 p_align 64 / armv7 32 / i686 32 / x86_64 64, every LOAD 16 KB aligned, entry at bionic's static _start.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
32-bit TLS linker layouts native/proot-tls-align-armv7a.ld, native/proot-tls-align-i686.ld |
The ARMv7-A and i386 linker layouts align the data segment to 16 KB. Both place .tdata and the end of BSS at 32-byte boundaries. |
ABI-specific build and TLS handling native/build-proot.sh |
build_proot selects the 32-bit linker scripts and adds them to the link flags. It injects loader page-size flags only when absent. After installation, it patches eligible 64-bit PT_TLS entries and verifies 32-bit alignment. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Merge Risk: 
Minimal · up to f1e5c
-
The identified issue is an inaccurate build-script comment, not a demonstrated failure of the rebuilt binaries. Normal validation, including the pending on-device checks, remains appropriate.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: fixing proot TLS underalignment across all ABIs. It also names the rebuild of the four proot binaries. The changeset matches this. The linker scripts and build-proot.sh change the TLS alignment for each ABI. The jniLibs binaries are excluded from the diff by the path filter, but the title still describes the intent of the PR. The title is specific and uses no vague terms. Its length (77 characters, 13 words) is slightly long, but it is still one clear sentence.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Summary
Fixes the on-device abort when starting a distro session on 32-bit (armv7)
hardware:
executable's TLS segment is underaligned ... needs to be at least 32 for ARM Bionic. Bionic's ARM32/ARM64 static-TLS layout checkgates on
p_alignand the vaddr skew together, and a plain NDK linkemits
p_align 8with a 16-aligned vaddr. This re-links the 32-bit ABIswith a script that start-aligns
.tdataat 32 (skew 0), and keeps thep_align 64program-header patch for the 64-bit ABIs (their vaddr isalready 64-aligned, so the patch is safe). All four
libproot.sobinaries were rebuilt from the
d4d2a19proot baseline (the one alreadyconfirmed working on aarch64).
Changes
native/proot-tls-align-armv7a.ld,native/proot-tls-align-i686.ld:full layout scripts;
.tdata/.tbssstart-aligned at 32, 16 KB datasegment alignment, lld-compatible
native/build-proot.sh: the-Wl,-Tscript is baked into the mainlink; the 32-bit branch verifies
p_align/vaddr instead of a deadld.bfdre-link (the NDK ships nold.bfd); ABI case fixed (i686'sABI is
x86, so the oldi686)pattern never matched); the 64-bitpatch now actually writes the file back; loader page-size injection is
idempotent
app/src/main/jniLibs/*/: all four ABIs rebuilt and verifiedarm64-v8a: PT_TLS p_align 64, vaddr 0x2a8ec0 (64-aligned)armeabi-v7a: PT_TLS p_align 32, vaddr 0x84000 (skew 0)x86: PT_TLS p_align 32, vaddr 0x4b8000 (skew 0; i386 has no bionicTLS gate, kept uniform with armv7)
x86_64: PT_TLS p_align 64, vaddr 0x2af400 (64-aligned)All ET_EXEC, every LOAD 16 KB-page aligned, entry at bionic's static
_start;.tdatatemplate bytes identical before/after the re-linkHow it was tested
(
StaticTlsLayout::reserve_exe_segment_and_tcbinbionic/libc/bionic/bionic_elf_tls.cpp):p_align 8fails onARM32/ARM64; 32 (i386/x86_64 have no gate); 32/64 with skew 0 pass
./gradlew clean assembleDebug(39/39 tasks, zerocompiler warnings); the APK's four
libproot.soare md5-identical tojniLibs
the pre-change binary; armv7/x86/x86_64 to be verified on real devices
before merge)
Checklist
./gradlew assembleDebug lintDebug(clean
assembleDebugdone;lintDebugnot run in this pass)## [Unreleased]if user-visible(deliberately untouched until the on-device verification lands,
per project convention)
Summary by CodeRabbit