=== modified file 'uspace/lib/c/arch/ia32/src/rtld/reloc.c'
|
|
|
|
| 70 | 70 | char *str_tab; |
| 71 | 71 | |
| 72 | 72 | elf_symbol_t *sym_def; |
| | 73 | module_t *src; |
| 73 | 74 | module_t *dest; |
| 74 | 75 | |
| 75 | 76 | DPRINTF("parse relocation table\n"); |
| … |
… |
|
| 99 | 100 | if (sym->st_name != 0) { |
| 100 | 101 | // DPRINTF("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset); |
| 101 | 102 | sym_def = symbol_def_find(str_tab + sym->st_name, |
| 102 | | m, &dest); |
| | 103 | m, &dest, NULL); |
| 103 | 104 | // DPRINTF("dest name: '%s'\n", dest->dyn.soname); |
| 104 | 105 | // DPRINTF("dest bias: 0x%x\n", dest->bias); |
| 105 | 106 | if (sym_def) { |
| … |
… |
|
| 138 | 139 | * Copy symbol data from shared object to specified |
| 139 | 140 | * location. |
| 140 | 141 | */ |
| 141 | | DPRINTF("fixup R_386_COPY (s)\n"); |
| 142 | 142 | sym_size = sym->st_size; |
| 143 | 143 | if (sym_size != sym_def->st_size) { |
| 144 | 144 | printf("Warning: Mismatched symbol sizes.\n"); |
| … |
… |
|
| 146 | 146 | if (sym_size > sym_def->st_size) |
| 147 | 147 | sym_size = sym_def->st_size; |
| 148 | 148 | } |
| 149 | | memcpy(r_ptr, (const void *)sym_addr, sym_size); |
| | 149 | |
| | 150 | /* |
| | 151 | * Look for the source symbol definition in all other |
| | 152 | * modules. |
| | 153 | */ |
| | 154 | elf_symbol_t *sdef; |
| | 155 | sdef = symbol_def_find(str_tab + sym->st_name, m, &src, m); |
| | 156 | if (sdef) { |
| | 157 | uint32_t saddr; |
| | 158 | |
| | 159 | saddr = (uint32_t) symbol_get_addr(sdef, src); |
| | 160 | memcpy(r_ptr, (const void *) saddr, sym_size); |
| | 161 | } else { |
| | 162 | printf("Source definition of '%s' not found.\n", |
| | 163 | str_tab + sym->st_name); |
| | 164 | } |
| | 165 | |
| 150 | 166 | break; |
| 151 | 167 | |
| 152 | 168 | case R_386_RELATIVE: |
=== modified file 'uspace/lib/c/generic/dlfcn.c'
|
|
|
|
| 80 | 80 | module_t *sm; |
| 81 | 81 | |
| 82 | 82 | printf("dlsym(0x%lx, \"%s\")\n", (long)mod, sym_name); |
| 83 | | sd = symbol_bfs_find(sym_name, (module_t *) mod, &sm); |
| | 83 | sd = symbol_bfs_find(sym_name, (module_t *) mod, &sm, NULL); |
| 84 | 84 | if (sd != NULL) { |
| 85 | 85 | return symbol_get_addr(sd, sm); |
| 86 | 86 | } |
=== modified file 'uspace/lib/c/generic/rtld/symbol.c'
|
|
|
|
| 112 | 112 | * @param start Module in which to start the search.. |
| 113 | 113 | * @param mod (output) Will be filled with a pointer to the module |
| 114 | 114 | * that contains the symbol. |
| | 115 | * @param avoid Module to exclude from the symbol search or NULL. |
| 115 | 116 | */ |
| 116 | | elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod) |
| | 117 | elf_symbol_t * |
| | 118 | symbol_bfs_find(const char *name, module_t *start, module_t **mod, |
| | 119 | module_t *avoid) |
| 117 | 120 | { |
| 118 | 121 | module_t *m, *dm; |
| 119 | 122 | elf_symbol_t *sym, *s; |
| … |
… |
|
| 144 | 147 | m = list_get_instance(list_first(&queue), module_t, queue_link); |
| 145 | 148 | list_remove(&m->queue_link); |
| 146 | 149 | |
| 147 | | s = def_find_in_module(name, m); |
| 148 | | if (s != NULL) { |
| 149 | | /* Symbol found */ |
| 150 | | sym = s; |
| 151 | | *mod = m; |
| 152 | | break; |
| | 150 | if (m != avoid) { |
| | 151 | s = def_find_in_module(name, m); |
| | 152 | if (s != NULL) { |
| | 153 | /* Symbol found */ |
| | 154 | sym = s; |
| | 155 | *mod = m; |
| | 156 | break; |
| | 157 | } |
| 153 | 158 | } |
| 154 | 159 | |
| 155 | 160 | /* |
| … |
… |
|
| 178 | 183 | } |
| 179 | 184 | |
| 180 | 185 | |
| 181 | | /** Find the definition of a symbol.. |
| | 186 | /** Find the definition of a symbol. |
| 182 | 187 | * |
| 183 | 188 | * By definition in System V ABI, if module origin has the flag DT_SYMBOLIC, |
| 184 | 189 | * origin is searched first. Otherwise, or if the symbol hasn't been found, |
| … |
… |
|
| 189 | 194 | * @param origin Module in which the dependency originates. |
| 190 | 195 | * @param mod (output) Will be filled with a pointer to the module |
| 191 | 196 | * that contains the symbol. |
| | 197 | * @param avoid Module to exclude from the symbol search or NULL. |
| 192 | 198 | */ |
| 193 | | elf_symbol_t *symbol_def_find(const char *name, module_t *origin, module_t **mod) |
| | 199 | elf_symbol_t * |
| | 200 | symbol_def_find(const char *name, module_t *origin, module_t **mod, |
| | 201 | module_t *avoid) |
| 194 | 202 | { |
| 195 | 203 | elf_symbol_t *s; |
| 196 | 204 | |
| 197 | | if (origin->dyn.symbolic) { |
| | 205 | if ((origin != avoid) && origin->dyn.symbolic) { |
| 198 | 206 | /* |
| 199 | 207 | * Origin module has a DT_SYMBOLIC flag. |
| 200 | 208 | * Try this module first |
| … |
… |
|
| 211 | 219 | |
| 212 | 220 | if (runtime_env->program) { |
| 213 | 221 | /* Program is dynamic -- start with program as root. */ |
| 214 | | return symbol_bfs_find(name, runtime_env->program, mod); |
| | 222 | return symbol_bfs_find(name, runtime_env->program, mod, avoid); |
| 215 | 223 | } else { |
| 216 | 224 | /* Program is static -- start with @a origin as root. */ |
| 217 | | return symbol_bfs_find(name, origin, mod); |
| | 225 | return symbol_bfs_find(name, origin, mod, avoid); |
| 218 | 226 | } |
| 219 | 227 | } |
| 220 | 228 | |
=== modified file 'uspace/lib/c/include/rtld/symbol.h'
|
|
|
|
| 38 | 38 | #include <elf/elf.h> |
| 39 | 39 | #include <rtld/rtld.h> |
| 40 | 40 | |
| 41 | | elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod); |
| 42 | | elf_symbol_t *symbol_def_find(const char *name, module_t *origin, module_t **mod); |
| | 41 | elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod, |
| | 42 | module_t *avoid); |
| | 43 | elf_symbol_t *symbol_def_find(const char *name, module_t *origin, module_t **mod, |
| | 44 | module_t *avoid); |
| 43 | 45 | void *symbol_get_addr(elf_symbol_t *sym, module_t *m); |
| 44 | 46 | |
| 45 | 47 | #endif |