loadelf.c: Fix dlsym symbol conflict with system libraries on macOS #538
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.
Summary
Fix segmentation fault on newer macOS versions (Darwin 25.x / macOS 26).
Problem
On newer macOS,
dlsym(0, "history")returns libedit'shistoryfunction instead of EusLisp's___historyfunction. This causes a segmentation fault when loading modules during the build process (e.g., when compiling with eusgl).The issue occurs because:
dlopen(0, RTLD_LAZY|RTLD_GLOBAL)with-flat_namespacemakes all loaded library symbols visibledlsymfinds libedit'shistorybefore EusLisp's___historySolution
Reverse the symbol lookup order to first try the
___prefixed symbol name, then fall back to the raw name. This avoids conflicts with system library symbols.Testing
Tested on macOS with Darwin 25.2.0 - eusgl and irteusgl build and run successfully after this fix.