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


Ignore:
Timestamp:
2025-01-26T21:33:13Z (7 weeks ago)
Author:
Matěj Volf <git@…>
Children:
ea77c2d
Parents:
31ea2a7
git-author:
Matěj Volf <git@…> (2025-01-26 21:04:16)
git-committer:
Matěj Volf <git@…> (2025-01-26 21:33:13)
Message:

properly initialize RTLD runtime for static binaries

this is a better approach than what I did of previous commit

see https://github.com/HelenOS/helenos/pull/242 for a lot more context

File:
1 edited

Legend:

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

    r31ea2a7 rf215c6ef  
    5757errno_t elf_load(int file, elf_info_t *info)
    5858{
     59#ifdef CONFIG_RTLD
     60        rtld_t *env;
     61#endif
    5962        errno_t rc = EOK;
     63        elf_finfo_t *finfo = &info->finfo;
    6064
    61         rc = elf_load_file(file, 0, &info->finfo);
     65        rc = elf_load_file(file, 0, finfo);
    6266        if (rc != EOK) {
    6367                DPRINTF("Failed to load executable '%s'.\n", file_name);
     
    6569        }
    6670
     71        if (info->finfo.dynamic == NULL) {
     72                /* Statically linked program */
     73                DPRINTF("Binary is statically linked.\n");
     74                info->env = NULL;
    6775#ifdef CONFIG_RTLD
    68         rtld_t *env;
    69         rc = rtld_prog_process(&info->finfo, &env);
     76                rc = rtld_init_static(finfo, &env);
     77                info->env = env;
     78#endif
     79                return EOK;
     80        }
     81
     82        DPRINTF("Binary is dynamically linked.\n");
     83#ifdef CONFIG_RTLD
     84        DPRINTF("- prog dynamic: %p\n", finfo->dynamic);
     85        rc = rtld_prog_process(finfo, &env);
    7086        info->env = env;
    7187#else
Note: See TracChangeset for help on using the changeset viewer.