Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/rtld_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ char* la_objsearch(const char* name, uintptr_t* cookie, unsigned int flag) {
log_debug(", ");
log_debug_int(flag);
log_debug(")\n");
if (flag == LA_SER_DEFAULT && strncmp(name, "/nix/store", 10) != 0) {
if (flag == LA_SER_DEFAULT) {
char* libname = my_strrchr(name, '/');
if (libname != NULL) {
libname++; // advance past the /
Expand All @@ -48,7 +48,24 @@ char* la_objsearch(const char* name, uintptr_t* cookie, unsigned int flag) {
log_info("\n searching...\n");
const char* result = NULL;
if (result == NULL) {
result = dynamic_lookup(libname, replit_ld_library_path);
const char* search_path = replit_ld_library_path;
if (strstartswith("/nix/store/", name)) {
// Count slashes to find the 5th one (after /nix/store/hash-name/lib/)
int slash_count = 0;
int i;
for (i = 0; name[i] && slash_count < 5; i++) {
if (name[i] == '/') slash_count++;
}
// Check if it's actually a /lib/ directory
if (i >= 5 && i <= MAX_LD_LIBRARY_PATH_LENGTH && strneql(name + i - 5, "/lib/", 5)) {
char extended_path[MAX_LD_LIBRARY_PATH_LENGTH];
my_strncpy(extended_path, name, i);
extended_path[i - 1] = ':';
my_strncpy(extended_path + i, replit_ld_library_path, MAX_LD_LIBRARY_PATH_LENGTH - i - 1);
search_path = extended_path;
}
}
result = dynamic_lookup(libname, search_path);
if (result != NULL) {
log_info(" found dynamically: ");
log_info(result);
Expand Down
Loading