Skip to content

Workaround LLD JUMP_SLOT relocation bugs in libPlayFabMultiplayer.so v1.26.x - #5

Closed
trasnake87 wants to merge 1 commit into
minecraft-linux:mainfrom
trasnake87:libplayfab-v126-plt-fixup
Closed

trasnake87 wants to merge 1 commit into
minecraft-linux:mainfrom
trasnake87:libplayfab-v126-plt-fixup

Conversation

@trasnake87

Copy link
Copy Markdown

Background

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 *GOT[i] lands at the lazy-binding stub's raw file offset (which isn't mapped in memory) and segfaults — well before libminecraftpe.so even loads. Symptom: SIGSEGV during library loading, called from libPlayFabMultiplayer.so + 0x3b0305 jumping to a low unmapped address like 0x3d7876 (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:

  1. Known-function table (known_plt_funcs_v126) — maps the 32 affected PLT indices in libPlayFabMultiplayer.so v1.26.x to glibc equivalents:

    • Memory: memset (4), memcpy (5), memmove (11), memcmp (12), malloc (66), calloc (69), realloc (108)
    • File I/O (with bionic FILE* unwrapping): fprintf (79), fwrite (145), fflush (148), fputc (192)
    • Threading: pthread_mutex_lock (109), pthread_mutex_unlock (110), pthread_cond_signal (130) — last uses a bionic-compatible shim
    • Locale: newlocale, uselocale, freelocale, strtoll_l, strtoull_l
    • Multibyte: mbsrtowcs, wcrtomb, mbrtowc, mbtowc, mbrlen
    • System: syscall
  2. plt_resolver_trampoline + plt_resolve_handler — for PLT entries not in the known table, attempts symbol resolution via .rela.plt and falls back to a no-op stub returning 0. Strictly better than the previous undefined-jump SIGSEGV.

  3. Also includes (related libPlayFab workarounds that landed alongside):

    • CFI dispatch patcher (909 call sites in libPlayFabMultiplayer; rewrites the 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* unwrappers for stdio (bionic::FILE wraps glibc FILE* at offset 24; the libc-shim sets that up but glibc's stdio functions need the inner FILE*)
    • Sanitizing wrapper for __emutls_get_address in libPlayFabMultiplayer (PairIP encrypts .data; controls have garbage index > 100 until sanitized)
    • Direct .data patches at known libPlayFabMultiplayer VAs for PubSub / HttpClient / AndroidJniHelper TLS vars and __cxa_eh_globals

The v1.21.x table from earlier work is preserved for backward compatibility.

How it gets selected

PLT count detection picks the table:

if (plt_count > 500) {
    // v1.21.x libPlayFabMultiplayer.so (523 PLT entries)
    active_table = known_plt_funcs;
} else if (plt_count >= 200 && plt_count <= 210) {
    // v1.26.x libPlayFabMultiplayer.so (205 PLT entries)
    active_table = known_plt_funcs_v126;
}

For other libraries with no unresolved PLT entries (plt_section_base == 0), the fixup short-circuits and does nothing.

Tested

  • Bedrock 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 runtime 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.
  • Logging examples observed at runtime:
    LLD PLT fixup: 205 PLT entries (plt_base=0x3d7190) in libPlayFabMultiplayer.so
    [ LLD PLT fixup ...: 32 resolved to known funcs, 139 using resolver ]
    [ CFI dispatch patched at ... with jmp *%r11 (909 call sites) in libPlayFabMultiplayer.so ]
    

Notes

  • x86_64 only (#if defined(__x86_64__)); aarch64 / armv7 fixups would need their own PLT layouts.
  • The PLT count heuristic for table selection is a fingerprint of the binary; if Bedrock 1.27+ ships a libPlayFabMultiplayer with a different entry count or layout, a new table is needed. The infrastructure (resolver trampoline, GOT patching) is reusable.
  • Companion PR: Generalize emutls corruption fix beyond v1.26.0.2 mcpelauncher-client#141.

🤖 Generated with Claude Code

…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>
@ChristopherHX

Copy link
Copy Markdown
Member

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"

  • Download Minecraft Trial x86_64 1.26.10 (chromeos) // You may cannot get that one, it is e.g. not available in USA
  • Load it
  • Notice libPlayfabMultiplayer.so loads

Why?

Minecraft Trial 1.26.10

  • has no DRM protection
  • has no pairipcore.so
  • contains unencrypted .so files

IMO This patch looks very adventurous and does not look to belong here.

@ChristopherHX

Copy link
Copy Markdown
Member

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.

@trasnake87

Copy link
Copy Markdown
Author

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 mcpelauncher-client (next to PR #132, which already targets PairIP encryption of the .data section) — I'll re-open there with the table, the resolver trampoline, and the CFI dispatch patcher relocated to launcher-side code that runs after libPlayFabMultiplayer.so is loaded, plus a corrected description that names PairIP rather than LLD.

Appreciate the review.

@trasnake87

Copy link
Copy Markdown
Author

Superseded — moving the workaround to mcpelauncher-client per #5 review.

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.

2 participants