Changeset 17341d4 in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2016-04-20T17:25:48Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dc0d8b52
Parents:
13dfa3f9
Message:

Move rtld internals out of loader. Stop misusing rtld instance from current environment for loading dynamically linked executables.

Location:
uspace/lib/c/include
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/elf/elf_load.h

    r13dfa3f9 r17341d4  
    11/*
    2  * Copyright (c) 2006 Sergey Bondari
    3  * Copyright (c) 2008 Jiri Svoboda
     2 * Copyright (c) 2016 Jiri Svoboda
    43 * All rights reserved.
    54 *
     
    3231 */
    3332/** @file
    34  * @brief ELF loader structures and public functions.
     33 * @brief
    3534 */
    3635
     
    3837#define ELF_LOAD_H_
    3938
    40 #include <elf/elf.h>
    41 #include <sys/types.h>
    42 #include <loader/pcb.h>
     39#include <elf/elf_mod.h>
     40#include <rtld/rtld.h>
    4341
    44 /**
    45  * ELF error return codes
    46  */
    47 #define EE_OK                   0       /* No error */
    48 #define EE_INVALID              1       /* Invalid ELF image */
    49 #define EE_MEMORY               2       /* Cannot allocate address space */
    50 #define EE_INCOMPATIBLE         3       /* ELF image is not compatible with current architecture */
    51 #define EE_UNSUPPORTED          4       /* Non-supported ELF (e.g. dynamic ELFs) */
    52 #define EE_LOADER               5       /* The image is actually a program loader. */
    53 #define EE_IRRECOVERABLE        6
    54 
    55 typedef enum {
    56         /** Leave all segments in RW access mode. */
    57         ELDF_RW = 1
    58 } eld_flags_t;
    59 
    60 /**
    61  * Some data extracted from the headers are stored here
    62  */
     42/** Information on loaded ELF program */
    6343typedef struct {
    64         /** Entry point */
    65         entry_point_t entry;
    66 
    67         /** ELF interpreter name or NULL if statically-linked */
    68         const char *interp;
    69 
    70         /** Pointer to the dynamic section */
    71         void *dynamic;
     44        elf_finfo_t finfo;
     45        rtld_t *env;
    7246} elf_info_t;
    7347
    74 /**
    75  * Holds information about an ELF binary being loaded.
    76  */
    77 typedef struct {
    78         /** Filedescriptor of the file from which we are loading */
    79         int fd;
    80 
    81         /** Difference between run-time addresses and link-time addresses */
    82         uintptr_t bias;
    83 
    84         /** Flags passed to the ELF loader. */
    85         eld_flags_t flags;
    86 
    87         /** A copy of the ELF file header */
    88         elf_header_t *header;
    89 
    90         /** Store extracted info here */
    91         elf_info_t *info;
    92 } elf_ld_t;
    93 
    94 extern const char *elf_error(unsigned int);
    95 extern int elf_load_file(const char *, size_t, eld_flags_t, elf_info_t *);
    96 extern void elf_create_pcb(elf_info_t *, pcb_t *);
     48extern int elf_load(const char *, elf_info_t *);
     49extern void elf_set_pcb(elf_info_t *, pcb_t *);
    9750
    9851#endif
  • uspace/lib/c/include/loader/pcb.h

    r13dfa3f9 r17341d4  
    6969        /** Pointer to ELF dynamic section of the program. */
    7070        void *dynamic;
    71         /** Pointer to dynamic linker state structure (runtime_env_t). */
     71        /** Pointer to dynamic linker state structure (rtld_t). */
    7272        void *rtld_runtime;
    7373} pcb_t;
  • uspace/lib/c/include/rtld/module.h

    r13dfa3f9 r17341d4  
    3939#include <rtld/dynamic.h>
    4040#include <adt/list.h>
     41#include <types/rtld/module.h>
     42#include <types/rtld/rtld.h>
    4143
    42 typedef struct module {
    43         dyn_info_t dyn;
    44         size_t bias;
     44extern void module_process_relocs(module_t *);
     45extern module_t *module_find(rtld_t *, const char *);
     46extern module_t *module_load(rtld_t *, const char *);
     47extern void module_load_deps(module_t *);
    4548
    46         /** Array of pointers to directly dependent modules */
    47         struct module **deps;
    48         /** Number of fields in deps */
    49         size_t n_deps;
    50 
    51         /** True iff relocations have already been processed in this module. */
    52         bool relocated;
    53 
    54         /** Link to list of all modules in runtime environment */
    55         link_t modules_link;
    56 
    57         /** Link to BFS queue. Only used when doing a BFS of the module graph */
    58         link_t queue_link;
    59         /** Tag for modules already processed during a BFS */
    60         bool bfs_tag;
    61 } module_t;
    62 
    63 void module_process_relocs(module_t *m);
    64 module_t *module_find(const char *name);
    65 module_t *module_load(const char *name);
    66 void module_load_deps(module_t *m);
    67 
    68 void modules_process_relocs(module_t *start);
    69 void modules_untag(void);
     49extern void modules_process_relocs(rtld_t *, module_t *);
     50extern void modules_untag(rtld_t *);
    7051
    7152#endif
  • uspace/lib/c/include/rtld/rtld.h

    r13dfa3f9 r17341d4  
    3636#define LIBC_RTLD_H_
    3737
     38#include <adt/list.h>
     39#include <elf/elf_mod.h>
    3840#include <sys/types.h>
    39 #include <adt/list.h>
    4041
    4142#include <rtld/dynamic.h>
    42 #include <rtld/module.h>
     43#include <types/rtld/rtld.h>
    4344
    44 typedef struct {
    45         elf_dyn_t *rtld_dynamic;
    46         module_t rtld;
    47 
    48         module_t *program;
    49 
    50         /** List of all loaded modules including rtld and the program */
    51         list_t modules;
    52 
    53         /** Temporary hack to place each module at different address. */
    54         uintptr_t next_bias;
    55 } runtime_env_t;
    56 
    57 extern runtime_env_t *runtime_env;
     45extern rtld_t *runtime_env;
    5846
    5947extern void rtld_init_static(void);
     48extern int rtld_prog_process(elf_finfo_t *, rtld_t **);
    6049
    6150#endif
  • uspace/lib/c/include/rtld/rtld_debug.h

    r13dfa3f9 r17341d4  
    3636#define LIBC_RTLD_RTLD_DEBUG_H_
    3737
     38#include <stdio.h>
     39
    3840/* Define to enable debugging mode. */
    3941#undef RTLD_DEBUG
Note: See TracChangeset for help on using the changeset viewer.