Skip to content

Commit e9be6ec

Browse files
committed
fix: add -Wl,-z,noexecstack to prevent dlopen failure on modern kernels
Modern kernels (Linux 6.x, OrbStack) reject dlopen of shared objects with PT_GNU_STACK RWE (executable stack) flag. gfortran historically sets this flag as a conservative measure for Fortran nested function trampolines. Analysis confirmed zero risk: wsjtx_lib contains 414 Fortran source files with no CONTAINS keyword, meaning no nested internal procedures and no trampolines. Applied to both targets on Linux/Unix: - wsjtx_core shared library (root cause, directly linked with gfortran) - wsjtx_lib_nodejs .node module (inherits flag transitively) Windows (MinGW) unaffected: flag is in UNIX-only branch and would be silently ignored by PE format linker regardless.
1 parent 9f7c31a commit e9be6ec

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ elseif(UNIX)
291291
if(FFTW_HAS_THREADS)
292292
target_link_libraries(wsjtx_core PRIVATE fftw3f_threads)
293293
endif()
294+
# Prevent execstack: modern kernels (and OrbStack) reject dlopen of .so with PT_GNU_STACK RWE.
295+
# Safe because wsjtx_lib Fortran code has no nested internal procedures (no CONTAINS),
296+
# so gfortran never generates trampolines requiring executable stack.
297+
target_link_options(wsjtx_core PRIVATE -Wl,-z,noexecstack)
294298
elseif(WIN32)
295299
# Static-link ALL non-system dependencies so wsjtx_core.dll only depends
296300
# on Windows system DLLs (KERNEL32.dll, msvcrt.dll). This prevents DLL
@@ -416,8 +420,9 @@ foreach(cfg Debug Release RelWithDebInfo MinSizeRel)
416420
)
417421
endforeach()
418422

419-
# Linux RPATH for .node
423+
# Linux RPATH for .node + prevent execstack
420424
if(UNIX AND NOT APPLE)
425+
target_link_options(${PROJECT_NAME} PRIVATE -Wl,-z,noexecstack)
421426
set_target_properties(${PROJECT_NAME} PROPERTIES
422427
BUILD_RPATH "\$ORIGIN"
423428
INSTALL_RPATH "\$ORIGIN"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wsjtx-lib",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Node.js C++ extension for WSJTX digital radio protocol library",
55
"type": "module",
66
"main": "dist/src/index.js",

0 commit comments

Comments
 (0)