Repository navigation
Workaround LLD JUMP_SLOT relocation bugs in libPlayFabMultiplayer.so v1.26.x - #5
trasnake87 wants to merge 1 commit into
Conversation
…v1.26.x
Bedrock Edition's NDK build of libPlayFabMultiplayer.so (v1.26.x family)
has several PLT entries left without JUMP_SLOT relocations because of an
LLD compiler bug. When the game calls those PLT slots at runtime, the
indirect jmp lands at the lazy-binding stub's raw file offset (which
isn't mapped) and segfaults — well before libminecraftpe.so even loads.
This patch teaches the linker to fix up those entries on x86_64 by
mapping known PLT indices to their glibc equivalents (the v1.26 table
covers 32 functions: pthread_mutex_*, memcpy/memset/memmove, libc fopen/
fwrite/fflush/etc, locale_t functions, syscall, mb*/wc* conversions).
For PLT entries not in the table, a plt_resolver_trampoline +
plt_resolve_handler attempt symbol resolution from .rela.plt and fall
back to a no-op stub — strictly better than the previous SIGSEGV.
Adds along the way:
* CFI dispatch patcher (909 call sites in libPlayFabMultiplayer; rewrites
CFI vtable check to a plain `jmp *%r11` so PairIP-protected dispatches
don't trip)
* Bionic-compatible pthread_cond shims (glibc condvar layout differs
from bionic's; we re-implement the futex-based protocol bionic uses)
* Bionic FILE* unwrapping wrappers for stdio (bionic::FILE wraps glibc
FILE* at offset 24)
* Sanitizing wrapper for libPlayFabMultiplayer's __emutls_get_address
(PairIP encrypts .data, leaving control structs with garbage; sanitize
index>100 cases to {size=8, align=8, index=0, templ=NULL})
Also includes some direct .data control-struct patches at known
libPlayFabMultiplayer VAs (PubSub, HttpClient, AndroidJniHelper TLS vars
plus __cxa_eh_globals).
Tested: 1.21.x and 1.26.x families both reach `libminecraftpe.so`
loading without the libPlayFab SIGSEGV. With the companion PR to
mcpelauncher-client (generalized __emutls_get_address hook for
libminecraftpe.so), 1.26.20.4 boots all the way to main menu and
Microsoft sign-in works.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I am 100% certain that this is caused on purpose by pairipcore, not by any lld bug. Steps I did some weeks ago due to "Animation Bug/Feature on x86_64"
Why? Minecraft Trial 1.26.10
IMO This patch looks very adventurous and does not look to belong here. |
|
Sounds like you figured out with claude code, that google does not stop at the encrypting static data and modifies the plt table as well in some cases. |
|
You're right on both counts and thanks for taking the time to test against the unencrypted Trial 1.26.10 ChromeOS build — that's much stronger evidence than I had. I was treating it as an LLD bug because the symptoms (unrelocated GOT slots pointing at PLT fallback stubs) match what an LLD bug would look like, but if the same libPlayFabMultiplayer.so loads cleanly in the no-DRM trial then PairIP is clearly doing it deliberately as part of its protection. Closing this PR. The right home for the workaround is Appreciate the review. |
|
Superseded — moving the workaround to mcpelauncher-client per #5 review. |
Background
Bedrock Edition's NDK build of
libPlayFabMultiplayer.so(v1.26.x family) has several PLT entries left withoutJUMP_SLOTrelocations because of an LLD compiler bug. When the game calls those PLT slots at runtime, the indirectjmp *GOT[i]lands at the lazy-binding stub's raw file offset (which isn't mapped in memory) and segfaults — well beforelibminecraftpe.soeven loads. Symptom:SIGSEGVduring library loading, called fromlibPlayFabMultiplayer.so + 0x3b0305jumping to a low unmapped address like0x3d7876(the file-offset of the PLT stub, never relocated to runtime address).PLT slot 109 in particular is the show-stopper for 1.26.x — that's
pthread_mutex_lock. Without resolution, every cold-start of v1.26.x crashes here.What this PR does
Teaches the linker to fix up unrelocated PLT entries on x86_64 by:
Known-function table (
known_plt_funcs_v126) — maps the 32 affected PLT indices in libPlayFabMultiplayer.so v1.26.x to glibc equivalents:memset(4),memcpy(5),memmove(11),memcmp(12),malloc(66),calloc(69),realloc(108)fprintf(79),fwrite(145),fflush(148),fputc(192)pthread_mutex_lock(109),pthread_mutex_unlock(110),pthread_cond_signal(130) — last uses a bionic-compatible shimnewlocale,uselocale,freelocale,strtoll_l,strtoull_lmbsrtowcs,wcrtomb,mbrtowc,mbtowc,mbrlensyscallplt_resolver_trampoline+plt_resolve_handler— for PLT entries not in the known table, attempts symbol resolution via.rela.pltand falls back to a no-op stub returning 0. Strictly better than the previous undefined-jump SIGSEGV.Also includes (related libPlayFab workarounds that landed alongside):
jmp *%r11so PairIP-protected dispatches don't trip)pthread_cond_*shims (glibc condvar layout differs from bionic's; we re-implement the futex-based protocol bionic uses)FILE*unwrappers for stdio (bionic::FILE wraps glibcFILE*at offset 24; the libc-shim sets that up but glibc's stdio functions need the inner FILE*)__emutls_get_addressin libPlayFabMultiplayer (PairIP encrypts .data; controls have garbageindex > 100until sanitized)__cxa_eh_globalsThe v1.21.x table from earlier work is preserved for backward compatibility.
How it gets selected
PLT count detection picks the table:
For other libraries with no unresolved PLT entries (
plt_section_base == 0), the fixup short-circuits and does nothing.Tested
libminecraftpe.soloading without the libPlayFab SIGSEGV.mcpelauncher-client(generalized__emutls_get_addressruntime hook for libminecraftpe.so corruption), 1.26.20.4 boots all the way to main menu and Microsoft sign-in via the Qt WebView works. Cross-play with PS5 reachable.Notes
#if defined(__x86_64__)); aarch64 / armv7 fixups would need their own PLT layouts.🤖 Generated with Claude Code