link_elf.c (f6494f2e1360cb4509afbbb2efbe329bfbe8ec4b) | link_elf.c (757686b11510174fffffec96b816204c8d659fba) |
---|---|
1/*- 2 * Copyright (c) 1998-2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 106 unchanged lines hidden (view full) --- 115static void link_elf_unload_file(linker_file_t); 116static void link_elf_unload_preload(linker_file_t); 117static int link_elf_lookup_set(linker_file_t, const char *, 118 void ***, void ***, int *); 119static int link_elf_each_function_name(linker_file_t, 120 int (*)(const char *, void *), 121 void *); 122static void link_elf_reloc_local(linker_file_t); | 1/*- 2 * Copyright (c) 1998-2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 106 unchanged lines hidden (view full) --- 115static void link_elf_unload_file(linker_file_t); 116static void link_elf_unload_preload(linker_file_t); 117static int link_elf_lookup_set(linker_file_t, const char *, 118 void ***, void ***, int *); 119static int link_elf_each_function_name(linker_file_t, 120 int (*)(const char *, void *), 121 void *); 122static void link_elf_reloc_local(linker_file_t); |
123static Elf_Addr elf_lookup(linker_file_t lf, Elf_Word symidx, int deps); | 123static Elf_Addr elf_lookup(linker_file_t lf, Elf_Size symidx, int deps); |
124 125static kobj_method_t link_elf_methods[] = { 126 KOBJMETHOD(linker_lookup_symbol, link_elf_lookup_symbol), 127 KOBJMETHOD(linker_symbol_values, link_elf_symbol_values), 128 KOBJMETHOD(linker_search_symbol, link_elf_search_symbol), 129 KOBJMETHOD(linker_unload, link_elf_unload_file), 130 KOBJMETHOD(linker_load_file, link_elf_load_file), 131 KOBJMETHOD(linker_link_preload, link_elf_link_preload), --- 772 unchanged lines hidden (view full) --- 904static void 905link_elf_unload_preload(linker_file_t file) 906{ 907 if (file->filename) 908 preload_delete_name(file->filename); 909} 910 911static const char * | 124 125static kobj_method_t link_elf_methods[] = { 126 KOBJMETHOD(linker_lookup_symbol, link_elf_lookup_symbol), 127 KOBJMETHOD(linker_symbol_values, link_elf_symbol_values), 128 KOBJMETHOD(linker_search_symbol, link_elf_search_symbol), 129 KOBJMETHOD(linker_unload, link_elf_unload_file), 130 KOBJMETHOD(linker_load_file, link_elf_load_file), 131 KOBJMETHOD(linker_link_preload, link_elf_link_preload), --- 772 unchanged lines hidden (view full) --- 904static void 905link_elf_unload_preload(linker_file_t file) 906{ 907 if (file->filename) 908 preload_delete_name(file->filename); 909} 910 911static const char * |
912symbol_name(elf_file_t ef, Elf_Word r_info) | 912symbol_name(elf_file_t ef, Elf_Size r_info) |
913{ 914 const Elf_Sym *ref; 915 916 if (ELF_R_SYM(r_info)) { 917 ref = ef->symtab + ELF_R_SYM(r_info); 918 return ef->strtab + ref->st_name; 919 } else 920 return NULL; --- 306 unchanged lines hidden (view full) --- 1227link_elf_get_gp(linker_file_t lf) 1228{ 1229 elf_file_t ef = (elf_file_t)lf; 1230 return (Elf_Addr)ef->got; 1231} 1232#endif 1233 1234const Elf_Sym * | 913{ 914 const Elf_Sym *ref; 915 916 if (ELF_R_SYM(r_info)) { 917 ref = ef->symtab + ELF_R_SYM(r_info); 918 return ef->strtab + ref->st_name; 919 } else 920 return NULL; --- 306 unchanged lines hidden (view full) --- 1227link_elf_get_gp(linker_file_t lf) 1228{ 1229 elf_file_t ef = (elf_file_t)lf; 1230 return (Elf_Addr)ef->got; 1231} 1232#endif 1233 1234const Elf_Sym * |
1235elf_get_sym(linker_file_t lf, Elf_Word symidx) | 1235elf_get_sym(linker_file_t lf, Elf_Size symidx) |
1236{ 1237 elf_file_t ef = (elf_file_t)lf; 1238 1239 if (symidx >= ef->nchains) 1240 return (NULL); 1241 return (ef->symtab + symidx); 1242} 1243 1244const char * | 1236{ 1237 elf_file_t ef = (elf_file_t)lf; 1238 1239 if (symidx >= ef->nchains) 1240 return (NULL); 1241 return (ef->symtab + symidx); 1242} 1243 1244const char * |
1245elf_get_symname(linker_file_t lf, Elf_Word symidx) | 1245elf_get_symname(linker_file_t lf, Elf_Size symidx) |
1246{ 1247 elf_file_t ef = (elf_file_t)lf; 1248 const Elf_Sym *sym; 1249 1250 if (symidx >= ef->nchains) 1251 return (NULL); 1252 sym = ef->symtab + symidx; 1253 return (ef->strtab + sym->st_name); 1254} 1255 1256/* 1257 * Symbol lookup function that can be used when the symbol index is known (ie 1258 * in relocations). It uses the symbol index instead of doing a fully fledged 1259 * hash table based lookup when such is valid. For example for local symbols. 1260 * This is not only more efficient, it's also more correct. It's not always 1261 * the case that the symbol can be found through the hash table. 1262 */ 1263static Elf_Addr | 1246{ 1247 elf_file_t ef = (elf_file_t)lf; 1248 const Elf_Sym *sym; 1249 1250 if (symidx >= ef->nchains) 1251 return (NULL); 1252 sym = ef->symtab + symidx; 1253 return (ef->strtab + sym->st_name); 1254} 1255 1256/* 1257 * Symbol lookup function that can be used when the symbol index is known (ie 1258 * in relocations). It uses the symbol index instead of doing a fully fledged 1259 * hash table based lookup when such is valid. For example for local symbols. 1260 * This is not only more efficient, it's also more correct. It's not always 1261 * the case that the symbol can be found through the hash table. 1262 */ 1263static Elf_Addr |
1264elf_lookup(linker_file_t lf, Elf_Word symidx, int deps) | 1264elf_lookup(linker_file_t lf, Elf_Size symidx, int deps) |
1265{ 1266 elf_file_t ef = (elf_file_t)lf; 1267 const Elf_Sym *sym; 1268 const char *symbol; 1269 1270 /* Don't even try to lookup the symbol if the index is bogus. */ 1271 if (symidx >= ef->nchains) 1272 return (0); --- 59 unchanged lines hidden --- | 1265{ 1266 elf_file_t ef = (elf_file_t)lf; 1267 const Elf_Sym *sym; 1268 const char *symbol; 1269 1270 /* Don't even try to lookup the symbol if the index is bogus. */ 1271 if (symidx >= ef->nchains) 1272 return (0); --- 59 unchanged lines hidden --- |