Changeset 0f792c28 in mainline
- Timestamp:
- 2016-04-12T16:59:41Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2e9a8a
- Parents:
- 3b0f1b9a
- Location:
- uspace/lib/c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/ia32/src/rtld/reloc.c
r3b0f1b9a r0f792c28 69 69 uint32_t sym_size; 70 70 char *str_tab; 71 71 72 72 elf_symbol_t *sym_def; 73 73 module_t *dest; … … 80 80 81 81 DPRINTF("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries); 82 82 83 83 for (i = 0; i < rt_entries; ++i) { 84 84 // DPRINTF("symbol %d: ", i); … … 100 100 // DPRINTF("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset); 101 101 sym_def = symbol_def_find(str_tab + sym->st_name, 102 m, &dest);102 m, ssf_none, &dest); 103 103 // DPRINTF("dest name: '%s'\n", dest->dyn.soname); 104 104 // DPRINTF("dest bias: 0x%x\n", dest->bias); … … 137 137 /* 138 138 * Copy symbol data from shared object to specified 139 * location. 139 * location. Need to find the 'source', i.e. the 140 * other instance of the object than the one in the 141 * executable program. 140 142 */ 141 143 DPRINTF("fixup R_386_COPY (s)\n"); 144 145 sym_def = symbol_def_find(str_tab + sym->st_name, 146 m, ssf_noroot, &dest); 147 148 if (sym_def) { 149 sym_addr = (uint32_t) 150 symbol_get_addr(sym_def, dest); 151 } else { 152 printf("Source definition of '%s' not found.\n", 153 str_tab + sym->st_name); 154 continue; 155 } 156 142 157 sym_size = sym->st_size; 143 158 if (sym_size != sym_def->st_size) { … … 147 162 sym_size = sym_def->st_size; 148 163 } 164 149 165 memcpy(r_ptr, (const void *)sym_addr, sym_size); 150 166 break; 151 167 152 168 case R_386_RELATIVE: 153 169 DPRINTF("fixup R_386_RELATIVE (b+a)\n"); -
uspace/lib/c/generic/dlfcn.c
r3b0f1b9a r0f792c28 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, ssf_none, &sm); 84 84 if (sd != NULL) { 85 85 return symbol_get_addr(sd, sm); -
uspace/lib/c/generic/rtld/symbol.c
r3b0f1b9a r0f792c28 111 111 * @param name Name of the symbol to search for. 112 112 * @param start Module in which to start the search.. 113 * @param flags @c ssf_none or @c ssf_noroot to not look for the symbol 114 * in @a start 113 115 * @param mod (output) Will be filled with a pointer to the module 114 116 * that contains the symbol. 115 117 */ 116 elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod) 118 elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, 119 symbol_search_flags_t flags, module_t **mod) 117 120 { 118 121 module_t *m, *dm; … … 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 ssf_noroot is specified, do not look in start module */ 151 if (m != start || (flags & ssf_noroot) == 0) { 152 s = def_find_in_module(name, m); 153 if (s != NULL) { 154 /* Symbol found */ 155 sym = s; 156 *mod = m; 157 break; 158 } 153 159 } 154 160 … … 179 185 180 186 181 /** Find the definition of a symbol. .187 /** Find the definition of a symbol. 182 188 * 183 189 * By definition in System V ABI, if module origin has the flag DT_SYMBOLIC, … … 188 194 * @param name Name of the symbol to search for. 189 195 * @param origin Module in which the dependency originates. 196 * @param flags @c ssf_none or @c ssf_noroot to not look for the symbol 197 * in the executable program. 190 198 * @param mod (output) Will be filled with a pointer to the module 191 199 * that contains the symbol. 192 200 */ 193 elf_symbol_t *symbol_def_find(const char *name, module_t *origin, module_t **mod) 201 elf_symbol_t *symbol_def_find(const char *name, module_t *origin, 202 symbol_search_flags_t flags, module_t **mod) 194 203 { 195 204 elf_symbol_t *s; … … 212 221 if (runtime_env->program) { 213 222 /* Program is dynamic -- start with program as root. */ 214 return symbol_bfs_find(name, runtime_env->program, mod);223 return symbol_bfs_find(name, runtime_env->program, flags, mod); 215 224 } else { 216 225 /* Program is static -- start with @a origin as root. */ 217 return symbol_bfs_find(name, origin, mod);226 return symbol_bfs_find(name, origin, ssf_none, mod); 218 227 } 219 228 } -
uspace/lib/c/include/rtld/symbol.h
r3b0f1b9a r0f792c28 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); 43 void *symbol_get_addr(elf_symbol_t *sym, module_t *m); 41 /** Symbol search flags */ 42 typedef enum { 43 /** No flags */ 44 ssf_none = 0, 45 /** Do not search tree root */ 46 ssf_noroot = 0x1 47 } symbol_search_flags_t; 48 49 extern elf_symbol_t *symbol_bfs_find(const char *, module_t *, 50 symbol_search_flags_t, module_t **); 51 extern elf_symbol_t *symbol_def_find(const char *, module_t *, 52 symbol_search_flags_t, module_t **); 53 extern void *symbol_get_addr(elf_symbol_t *, module_t *); 44 54 45 55 #endif
Note:
See TracChangeset
for help on using the changeset viewer.