Skip to content

Fix proot TLS underalignment and build proot 3c6aa6f with the link2symlink/fake_id0 fixes - #28

Merged
GlobalTechInfo merged 5 commits into
mainfrom
proot/fix
Oct 25, 2026
Merged

GlobalTechInfo merged 5 commits into
mainfrom
proot/fix

Conversation

@GlobalTechInfo

Copy link
Copy Markdown
Owner

Summary

Two proot fixes, both needed before distro sessions work on 32-bit devices
and before rm -rf works in .git trees:

  1. TLS underalignment crash — bionic's ARM32/ARM64 static-TLS layout
    check (StaticTlsLayout::reserve_exe_segment_and_tcb in
    bionic_elf_tls.cpp) aborts executables whose PT_TLS is underaligned;
    it gates on p_align and the vaddr skew together. A plain NDK
    link emits p_align 8 with a 16-aligned vaddr, so armv7 sessions died
    at proot startup ("executable's TLS segment is underaligned ... needs
    to be at least 32 for ARM Bionic").
  2. rm -rf .git/objects/pack → EPERM — a link2symlink/fake_id0
    issue fixed only in the commit series between d4d2a19 and
    3c6aa6f (notably 968ae1b "link symbolic links as symbolic links", the fake_id0 statx/chmod-record series, 32-bit getdents
    parsing). The previous binaries were built from d4d2a19, which
    predates all of it.

All four libproot.so are now built from proot 3c6aa6f with the
TLS alignment applied.

Changes

  • native/proot-tls-align-armv7a.ld, native/proot-tls-align-i686.ld:
    full lld-compatible layout scripts; .tdata/.tbss start-aligned at
    32 (skew 0), 16 KB data-segment alignment
  • native/build-proot.sh: PROOT_VERSION bumped to 3c6aa6f; the
    -Wl,-T script is baked into the main link; 32-bit branch verifies
    p_align/vaddr instead of a dead ld.bfd re-link (the NDK ships no
    ld.bfd); ABI case fixed (i686's ABI is x86); the 64-bit p_align
    patch writes the file back and its vaddr-64 hard guard now applies to
    arm64 only (i386/x86_64 have no bionic TLS gate; x86_64 links with a
    32-aligned vaddr and is stamped p_align 64 without aborting); loader
    page-size injection is idempotent
  • app/src/main/jniLibs/*/ — all four ABIs rebuilt and verified:
    • arm64-v8a: PT_TLS p_align 64, vaddr 64-aligned
    • armeabi-v7a: PT_TLS p_align 32, vaddr skew 0
    • x86: PT_TLS p_align 32, vaddr skew 0
    • x86_64: PT_TLS p_align 64 (vaddr 32-aligned; no gate on i386/x86_64)
      All ET_EXEC, every LOAD 16 KB-page aligned, entry at bionic's static
      _start, .tdata template bytes preserved

How it was tested

  • TLS check cross-referenced against bionic platform source; .tdata
    contents byte-identical before/after the re-link; clean
    ./gradlew clean assembleDebug with zero compiler warnings; APK
    libproot.so md5-identical to jniLibs for all four ABIs
  • Pending: on-device verification of rm -rf on the affected device
    (the TLS crash itself is already confirmed gone on the rebuilt
    arm64 binary)

Checklist

  • ./gradlew assembleDebug clean build passes; lintDebug not run
    in this pass
  • CHANGELOG.md updated under ## [Unreleased] if user-visible
    (deliberately untouched until the on-device verification lands,
    per project convention)
  • No unrelated changes included

…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.
… binaries

The rm -rf .git/objects/pack EPERM in a distro session is a link2symlink
issue, fixed in the commit series between d4d2a19 and 3c6aa6f (968ae1b
'link symbolic links as symbolic links', the fake_id0 statx/chmod record
series, 32-bit getdents parsing). The previous binaries were built from
d4d2a19, which predates all of it, so the TLS fix alone could not heal
it. Bump PROOT_VERSION to 3c6aa6f and rebuild all four ABIs:
arm64 p_align 64 (vaddr 64-aligned), armv7 p_align 32 (skew 0),
i686 p_align 32 (skew 0), x86_64 p_align 64 (no bionic gate there, so
the vaddr-64 hard guard now applies to arm64 only). 16 KB aligned
throughout.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@GlobalTechInfo
GlobalTechInfo merged commit 3d510cb into main Oct 25, 2026
1 of 2 checks passed
@GlobalTechInfo
GlobalTechInfo deleted the proot/fix branch October 25, 2026 19:43
@GlobalTechInfo GlobalTechInfo mentioned this pull request Oct 25, 2026
1 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant