Skip to content

Commit

Permalink
Explicitly load librt
Browse files Browse the repository at this point in the history
  • Loading branch information
cataphract committed Oct 1, 2024
1 parent 8bc89bf commit a6c85ac
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spawn_worker/src/trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ int main(int argc, char *argv[]) {

#ifndef _WIN32
void **handles = NULL;
#ifdef __GLIBC__
void *librt_handle = NULL;
#endif

if (additional_shared_libraries_args > 0) {
handles = calloc(additional_shared_libraries_args, sizeof(void *));

#ifdef __GLIBC__
// appsec needs librt for shm_open, but doesn't declare needing it for compat with musl.
// RTDL_LAZY has no effect because of the elf flag BIND_NOW
librt_handle = dlopen("librt.so.1", RTLD_LAZY | RTLD_GLOBAL);
#endif
}

int additional_shared_libraries_count = 0;
Expand Down Expand Up @@ -93,6 +102,11 @@ int main(int argc, char *argv[]) {
}
free(handles);
}
#ifdef __GLIBC__
if (librt_handle) {
dlclose(librt_handle);
}
#endif
#else
for (int i = 0; i < additional_shared_libraries_args; i++) {
const char *lib_path = argv[3 + i];
Expand Down

0 comments on commit a6c85ac

Please sign in to comment.