ARMJIT_Linkage.S: add .note.GNU-stack to the JIT linkage - #218
Open
veralvx wants to merge 1 commit into
Open
Conversation
files Without the note, the linker marks the whole core as requiring an executable stack. glibc 2.41 and newer refuse to dlopen such objects instead of granting the request, so RetroArch cannot load the core: Failed to open libretro core: .../melonds_libretro.so Error(s): .../melonds_libretro.so: cannot enable executable stack as shared object requires: Invalid argument The requirement is spurious. The JIT allocates its executable memory with mmap (ARMJIT_Memory.cpp), never on the stack. Upstream melonDS added the same note to both files in 3ab752b and refined the guards in 2a86ee7 and 63e4b68. This uses the current upstream form.
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.
ARMJIT_Linkage.S: add .note.GNU-stack to the JIT linkage files
Fixes the core failing to load on glibc 2.41 and newer:
Both
ARMJIT_Linkage.Sfiles are assembled without a.note.GNU-stacksection. The linker treats an object without that note as needing an executable stack and marks the whole.soRWE. glibc 2.41 changeddlopento fail on such objects rather than making the stack executable, so RetroArch cannot load the core.Four lines appended to each file, using upstream melonDS's current form:
Upstream added these in 3ab752b and refined the guards in 2a86ee7 (non-MinGW Clang) and 63e4b68 (
_WIN64instead of a workaround).Guards are needed because
.note.GNU-stackis ELF-only, and Mach-O and PE/COFF targets must not see the directive. Makefile:548 builds these files with$(CC) -x assembler-with-cpp, so the preprocessor runs and the guards take effect. Windows and Apple builds assemble as before.Testing
On x86_64 Linux with glibc 2.41+:
readelf -lW melonds_libretro.soreportsGNU_STACK ... RWE, and RetroArch fails to load it with the error above.GNU_STACK ... RW, core loads and runs contentARMJIT_Linkage.Salone both ways:ldprints "missing .note.GNU-stack section implies executable stack" before, and nothing after.-D_WIN64and-D__APPLE__: the directive is dropped in both cases and kept on a plain ELF targetThe aarch64 change is the same edit to the same construct and matches upstream, but I have not built it on hardware.