[CMAKE] Disable PIE when fixing Box64 load address - #4362
Merged
Conversation
Owner
|
Android builds are broken, because they need PIE... |
VoltrexKeyva
force-pushed
the
addnopie
branch
from
September 6, 2026 15:51
feb3d54 to
246cf3a
Compare
Contributor
Author
Added a condition to keep PIE when targeting Android. |
--image-base does not disable PIE with Clang/LLD, allowing Box64 to be relocated above the 32-bit address range used by Box32. Pass -no-pie whenever the fixed Box64 image base is used unless the target is Android.
VoltrexKeyva
force-pushed
the
addnopie
branch
from
September 6, 2026 15:57
246cf3a to
9da2b80
Compare
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.
When Box64 is built with Clang on distributions where PIE is enabled by default, the current CMake configuration can produce a PIE executable even though Box64 is linked with
--image-base=0x34800000.--image-basedoes not disable PIE with Clang/LLD, so the resultingET_DYNexecutable can be relocated to a high address at runtime.This breaks Box32 because some Box32 data structures must be addressable through 32-bit pointers. For example,
wrappedlibcconverts the address of its ctype tables withto_ptrv(), which rejects host pointers above 32 bits and aborts.For reproduction I tested on Debian 13 Arm64 with Clang/LLD:
Both Box64 v0.4.4 branch and latest
mainbranch with-DARM_DYNAREC=ON -DBOX32=ON -DBOX32_BINFMT=ON -DCMAKE_BUILD_TYPE=RelWithDebInfoand the resulting executable is
Type: DYN (Shared object file)with a preferred load address of0x34800000, but is relocated to a high0xaaaa...address at runtime. Box32 then aborts duringwrappedlibc_init32():[BOX32] Warning, pointer 0xaaaa... is not a 32bits valueThe failure was localized with LLDB to:
box64_abort->
to_ptrv()->
ctSetup()->
wrappedlibc_init32()Adding
-no-pieto the link flags changes the executable toType: EXEC (Executable file)and keeps it at the intended0x34800000load address, SteamCMD then starts successfully.So pass
-no-piewhenever the Clang/mold link path uses the fixed Box64 image base.NOLOADADDR=ONremains an explicit opt-out, so builds that request an unfixed load address are unaffected.Android is explicitly excluded because Android 5.0 and later require position-independent executables. The existing
--image-baseoption remains unchanged for Android builds.Verified as working with Clang/LLD and GCC + ld (GNU ld part is unchanged).