Skip to content

Commit

Permalink
Workaround upstream FreeBSD issue #272992
Browse files Browse the repository at this point in the history
FreeBSD does not support looking up WEAK symbols in its libc via `dlsym`
if you're using a library-specific handle. It will give you the empty
stub in libc instead of, e.g., the strong implementation in ld-elf.so

This fix and the one that was merged upstream are pretty conspicuously
incomplete, since `dlsym`, `dladdr` and a ton of other symbols still
have stubs with no trampoline in libc:
https://cgit.freebsd.org/src/tree/lib/libc/gen/dlfcn.c?id=21a52f99440c9bec7679f3b0c5c9d888901c3694

Thankfully, this appears to be the only function that we directly
`ccall` from Julia's Libdl so we can leave this fix incomplete for now.
  • Loading branch information
topolarity committed Aug 30, 2023
1 parent 197180d commit d9c56bf
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ JL_DLLEXPORT int jl_dlsym(void *handle, const char *symbol, void ** value, int t
// Look for symbols in internal libraries
JL_DLLEXPORT const char *jl_dlfind(const char *f_name)
{
#ifdef _OS_FREEBSD_
// This is a workaround for FreeBSD <= 13.2 which do not have
// https://cgit.freebsd.org/src/commit/?id=21a52f99440c9bec7679f3b0c5c9d888901c3694
// (See https://github.com/JuliaLang/julia/issues/50846)
if (strcmp(f_name, "dl_iterate_phdr") == 0)
return JL_EXE_LIBNAME;
#endif
void * dummy;
if (jl_dlsym(jl_libjulia_internal_handle, f_name, &dummy, 0))
return JL_LIBJULIA_INTERNAL_DL_LIBNAME;
Expand Down

0 comments on commit d9c56bf

Please sign in to comment.