uclibc-compat: split .so and .a to fix segfault from symbol interposition#2000
Merged
uclibc-compat: split .so and .a to fix segfault from symbol interposition#2000
Conversation
libuclibc-compat.so was exporting stat/mmap which overrode musl's implementations for ALL code in the process, including musl's own internal calls. This caused segfaults because musl expects 64-bit off_t but the shim's mmap takes uint32_t. Split into two libraries: - libuclibc-compat.so: only symbols MISSING from musl (__ctype_b, __assert, __fgetc_unlocked, memcpy_s, etc). Safe as shared lib. - libuclibc-compat-static.a: stat/mmap wrappers with uclibc-compatible ABI. Must be statically linked into the executable so overrides only affect vendor .so lookups through the executable's symbol scope. BUNDLE_SDK now builds and includes both in the toolchain tarball. Fixes: segfault in majestic on hi3516cv100 at hisi_free_mem_ex (mmap) Ref: #1992 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
|
/rerun |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
libuclibc-compat.soexportedstat/mmapwhich overrode musl's implementations process-wide, causing segfaults. musl expects 64-bitoff_tfor mmap but the shim's version takesuint32_t— when musl's own internal code called mmap, it hit the wrong implementation.Confirmed crash: majestic segfaults at
hisi_free_mem_ex(MMZ memory allocation via mmap) on hi3516cv100 nightly build.Fix
Split into two libraries:
libuclibc-compat.so: only symbols MISSING from musl (__ctype_b,__assert,__fgetc_unlocked,memcpy_s, etc). Safe as shared lib — no conflict.libuclibc-compat-static.a:stat/mmapwrappers. Must be statically linked into the executable, so overrides only affect vendor.solookups through the executable's symbol scope, not musl internally.BUNDLE_SDKupdated to build and include both in the toolchain tarball.Test plan
.sohas no stat/mmap,.ahas them-luclibc-compat(dynamic) +-luclibc-compat-static(static)Ref: #1992