| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2008 Jiri Svoboda
|
|---|
| 3 | *
|
|---|
| 4 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | /** @addtogroup libc
|
|---|
| 8 | * @{
|
|---|
| 9 | */
|
|---|
| 10 | /** @file
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #ifndef _LIBC_RTLD_DYNAMIC_H_
|
|---|
| 14 | #define _LIBC_RTLD_DYNAMIC_H_
|
|---|
| 15 |
|
|---|
| 16 | #include <stdbool.h>
|
|---|
| 17 | #include <rtld/elf_dyn.h>
|
|---|
| 18 | #include <libarch/rtld/dynamic.h>
|
|---|
| 19 |
|
|---|
| 20 | /**
|
|---|
| 21 | * Holds the data extracted from an ELF Dynamic section.
|
|---|
| 22 | *
|
|---|
| 23 | * The data is already pre-processed: Pointers are adjusted
|
|---|
| 24 | * to their final run-time values by adding the load bias
|
|---|
| 25 | * and indices into the symbol table are converted to pointers.
|
|---|
| 26 | */
|
|---|
| 27 | typedef struct dyn_info {
|
|---|
| 28 | /** Relocation table without explicit addends */
|
|---|
| 29 | void *rel;
|
|---|
| 30 | size_t rel_sz;
|
|---|
| 31 | size_t rel_ent;
|
|---|
| 32 |
|
|---|
| 33 | /** Relocation table with explicit addends */
|
|---|
| 34 | void *rela;
|
|---|
| 35 | size_t rela_sz;
|
|---|
| 36 | size_t rela_ent;
|
|---|
| 37 |
|
|---|
| 38 | /** PLT relocation table */
|
|---|
| 39 | void *jmp_rel;
|
|---|
| 40 | size_t plt_rel_sz;
|
|---|
| 41 | /** Type of relocations used for the PLT, either DT_REL or DT_RELA */
|
|---|
| 42 | int plt_rel;
|
|---|
| 43 |
|
|---|
| 44 | /** Pointer to PLT/GOT (processor-specific) */
|
|---|
| 45 | void *plt_got;
|
|---|
| 46 |
|
|---|
| 47 | /** Hash table */
|
|---|
| 48 | elf_word *hash;
|
|---|
| 49 |
|
|---|
| 50 | /** String table */
|
|---|
| 51 | char *str_tab;
|
|---|
| 52 | size_t str_sz;
|
|---|
| 53 |
|
|---|
| 54 | /** Symbol table */
|
|---|
| 55 | void *sym_tab;
|
|---|
| 56 | size_t sym_ent;
|
|---|
| 57 |
|
|---|
| 58 | void *init; /**< Module initialization code */
|
|---|
| 59 | void *fini; /**< Module cleanup code */
|
|---|
| 60 |
|
|---|
| 61 | const char *soname; /**< Library identifier */
|
|---|
| 62 | char *rpath; /**< Library search path list */
|
|---|
| 63 |
|
|---|
| 64 | bool symbolic;
|
|---|
| 65 | bool text_rel;
|
|---|
| 66 | bool bind_now;
|
|---|
| 67 |
|
|---|
| 68 | /* Assume for now that there's at most one needed library */
|
|---|
| 69 | char *needed;
|
|---|
| 70 |
|
|---|
| 71 | /** Pointer to the module's dynamic section */
|
|---|
| 72 | elf_dyn_t *dynamic;
|
|---|
| 73 |
|
|---|
| 74 | /** Architecture-specific info. */
|
|---|
| 75 | dyn_info_arch_t arch;
|
|---|
| 76 | } dyn_info_t;
|
|---|
| 77 |
|
|---|
| 78 | void dynamic_parse(elf_dyn_t *dyn_ptr, size_t bias, dyn_info_t *info);
|
|---|
| 79 | void dyn_parse_arch(elf_dyn_t *dp, size_t bias, dyn_info_t *info);
|
|---|
| 80 |
|
|---|
| 81 | #endif
|
|---|
| 82 |
|
|---|
| 83 | /** @}
|
|---|
| 84 | */
|
|---|