-static long
-lookup_symbol (SIM_DESC sd, const char *name)
-{
- struct bfd *abfd = STATE_PROG_BFD (sd);
- asymbol **symbol_table = STATE_SYMBOL_TABLE (sd);
- long number_of_symbols = STATE_NUM_SYMBOLS (sd);
- long i;
-
- if (abfd == NULL)
- return -1;
-
- if (symbol_table == NULL)
- {
- long storage_needed;
-
- storage_needed = bfd_get_symtab_upper_bound (abfd);
- if (storage_needed <= 0)
- return -1;
-
- STATE_SYMBOL_TABLE (sd) = symbol_table = xmalloc (storage_needed);
- STATE_NUM_SYMBOLS (sd) = number_of_symbols =
- bfd_canonicalize_symtab (abfd, symbol_table);
- }
-
- for (i = 0; i < number_of_symbols; i++)
- if (strcmp (symbol_table[i]->name, name) == 0)
- {
- long val = symbol_table[i]->section->vma + symbol_table[i]->value;
- return val;
- }
- return -1;
-}
-