Changeset View
Changeset View
Standalone View
Standalone View
head/sys/ddb/db_main.c
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
c_db_sym_t | c_db_sym_t | ||||
X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, db_strategy_t strat, | X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, db_strategy_t strat, | ||||
db_expr_t *diffp) | db_expr_t *diffp) | ||||
{ | { | ||||
c_linker_sym_t lsym; | c_linker_sym_t lsym; | ||||
Elf_Sym *sym, *match; | Elf_Sym *sym, *match; | ||||
unsigned long diff; | unsigned long diff; | ||||
db_addr_t stoffs; | |||||
if (symtab->private == NULL) { | if (symtab->private == NULL) { | ||||
if (!linker_ddb_search_symbol((caddr_t)off, &lsym, &diff)) { | if (!linker_ddb_search_symbol((caddr_t)off, &lsym, &diff)) { | ||||
*diffp = (db_expr_t)diff; | *diffp = (db_expr_t)diff; | ||||
return ((c_db_sym_t)lsym); | return ((c_db_sym_t)lsym); | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
diff = ~0UL; | diff = ~0UL; | ||||
match = NULL; | match = NULL; | ||||
stoffs = DB_STOFFS(off); | |||||
for (sym = (Elf_Sym*)symtab->start; (char*)sym < symtab->end; sym++) { | for (sym = (Elf_Sym*)symtab->start; (char*)sym < symtab->end; sym++) { | ||||
if (sym->st_name == 0 || sym->st_shndx == SHN_UNDEF) | if (sym->st_name == 0 || sym->st_shndx == SHN_UNDEF) | ||||
continue; | continue; | ||||
if (off < sym->st_value) | if (stoffs < sym->st_value) | ||||
continue; | continue; | ||||
if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT && | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT && | ||||
ELF_ST_TYPE(sym->st_info) != STT_FUNC && | ELF_ST_TYPE(sym->st_info) != STT_FUNC && | ||||
ELF_ST_TYPE(sym->st_info) != STT_NOTYPE) | ELF_ST_TYPE(sym->st_info) != STT_NOTYPE) | ||||
continue; | continue; | ||||
if ((off - sym->st_value) > diff) | if ((stoffs - sym->st_value) > diff) | ||||
continue; | continue; | ||||
if ((off - sym->st_value) < diff) { | if ((stoffs - sym->st_value) < diff) { | ||||
diff = off - sym->st_value; | diff = stoffs - sym->st_value; | ||||
match = sym; | match = sym; | ||||
} else { | } else { | ||||
if (match == NULL) | if (match == NULL) | ||||
match = sym; | match = sym; | ||||
else if (ELF_ST_BIND(match->st_info) == STB_LOCAL && | else if (ELF_ST_BIND(match->st_info) == STB_LOCAL && | ||||
ELF_ST_BIND(sym->st_info) != STB_LOCAL) | ELF_ST_BIND(sym->st_info) != STB_LOCAL) | ||||
match = sym; | match = sym; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |