2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * symtab - symbol table routines
13 #include "sys/types.h"
17 * using the toc_syment structure, that we fabricate:
18 * sym->n_offset is the string pointer
20 #define sym_off(sym) ((sym)->n_offset)
21 #define sym_str(sym) \
22 ((sym)->n_zeroes == 0 ? (char *) sym_off(sym) : (sym)->n_name)
25 sym_lookup(name, value)
27 static sym_t *symsrch(), *search();
34 * first, try just the name. if that fails, try with a
35 * prefix '.', and failing that, a prefix '_'.
37 if (sym = symsrch(name))
39 bcopy(name, buf+1, sizeof (buf) - 2);
42 if (sym = symsrch(buf))
62 for (sp = toc_syms; sp < &toc_syms[toc_nsyms]; ++sp) {
63 if (sp->n_value <= addr && sp->n_value >= value) {
66 if (sp->n_value == addr)
70 return save ? sym_flex(save) : 0;
77 register sym_t *found;
82 * determine length of symbol
84 for (len = 0, p = s; *p; ++p)
88 for (sp = toc_syms; sp < &toc_syms[toc_nsyms]; ++sp) {
90 * exact matches preferred
92 if (strcmp(sym_str(sp), s) == 0) {
97 * otherwise, prefices might interest us.
99 if (!found && (strncmp(sym_str(sp), s, len) == 0)) {
105 return found ? sym_flex(found) : 0;
109 * sym_flex - convert a symbol so that there is no distinction between
110 * flex-string and non flex-string format.
113 * sym - ^ to symbol table entry
116 * ^ to static location containing modified symbol.
120 register sym_t *sym; {
122 static char name[48];
124 strncpy(name, sym_str(sym), sizeof (name) - 1);
126 if (sym->n_zeroes != 0)
127 name[8] = 0; /* make sure that we truncate correctly */
131 symbol.n_nptr = name;