Changeset 32254d6 in mainline for uspace/lib/c/generic/elf/elf_load.c


Ignore:
Timestamp:
2025-02-13T10:16:55Z (7 days ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
286c4b0, f455de0
Parents:
a7a16a2f
git-author:
Matěj Volf <git@…> (2025-02-13 10:16:55)
git-committer:
GitHub <noreply@…> (2025-02-13 10:16:55)
Message:

init RTLD runtime at load time even for statically linked binaries (#242)

init RTLD runtime at load time even for statically linked binaries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/elf/elf_load.c

    ra7a16a2f r32254d6  
    6060        rtld_t *env;
    6161#endif
    62         errno_t rc;
     62        errno_t rc = EOK;
     63        elf_finfo_t *finfo = &info->finfo;
    6364
    64         rc = elf_load_file(file, 0, &info->finfo);
     65        rc = elf_load_file(file, 0, finfo);
    6566        if (rc != EOK) {
    66                 DPRINTF("Failed to load executable '%s'.\n", file_name);
     67                DPRINTF("Failed to load executable.\n");
    6768                return rc;
    6869        }
    6970
     71#ifdef CONFIG_RTLD
     72        DPRINTF("- prog dynamic: %p\n", finfo->dynamic);
     73        rc = rtld_prog_process(finfo, &env);
     74        if (rc != EOK) {
     75                DPRINTF("Failed to process executable.\n");
     76                return rc;
     77        }
     78        info->env = env;
     79        return EOK;
     80#else
    7081        if (info->finfo.dynamic == NULL) {
    71                 /* Statically linked program */
    72                 DPRINTF("Binary is statically linked.\n");
    7382                info->env = NULL;
    7483                return EOK;
    7584        }
    7685
    77         DPRINTF("Binary is dynamically linked.\n");
    78 #ifdef CONFIG_RTLD
    79         DPRINTF("- prog dynamic: %p\n", info->finfo.dynamic);
    80 
    81         rc = rtld_prog_process(&info->finfo, &env);
    82         info->env = env;
    83 #else
    84         rc = ENOTSUP;
     86        DPRINTF("Error: trying to run a dynamically-linked executable with CONFIG_RTLD disabled.\n");
     87        return ENOTSUP;
    8588#endif
    86         return rc;
    8789}
    8890
Note: See TracChangeset for help on using the changeset viewer.