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 <afs/param.h>
14 #include <afsconfig.h>
18 #include "sys/types.h"
22 * using the toc_syment structure, that we fabricate:
23 * sym->n_offset is the string pointer
25 #define sym_off(sym) ((sym)->n_offset)
26 #define sym_str(sym) \
27 ((sym)->n_zeroes == 0 ? (char *) sym_off(sym) : (sym)->n_name)
30 sym_lookup(name, value)
32 static sym_t *symsrch(), *search();
39 * first, try just the name. if that fails, try with a
40 * prefix '.', and failing that, a prefix '_'.
42 if (sym = symsrch(name))
44 bcopy(name, buf+1, sizeof (buf) - 2);
47 if (sym = symsrch(buf))
67 for (sp = toc_syms; sp < &toc_syms[toc_nsyms]; ++sp) {
68 if (sp->n_value <= addr && sp->n_value >= value) {
71 if (sp->n_value == addr)
75 return save ? sym_flex(save) : 0;
82 register sym_t *found;
87 * determine length of symbol
89 for (len = 0, p = s; *p; ++p)
93 for (sp = toc_syms; sp < &toc_syms[toc_nsyms]; ++sp) {
95 * exact matches preferred
97 if (strcmp(sym_str(sp), s) == 0) {
102 * otherwise, prefices might interest us.
104 if (!found && (strncmp(sym_str(sp), s, len) == 0)) {
110 return found ? sym_flex(found) : 0;
114 * sym_flex - convert a symbol so that there is no distinction between
115 * flex-string and non flex-string format.
118 * sym - ^ to symbol table entry
121 * ^ to static location containing modified symbol.
125 register sym_t *sym; {
127 static char name[48];
129 strncpy(name, sym_str(sym), sizeof (name) - 1);
131 if (sym->n_zeroes != 0)
132 name[8] = 0; /* make sure that we truncate correctly */
136 symbol.n_nptr = name;