#include <stdlib.h>
#include "ansidecl.h"
+#include "bfd.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/signals.h"
#include "memory.h"
#include "simulator.h"
-static unsigned long symcount = 0;
-static asymbol ** symtab = NULL;
-
/* Filter out (in place) symbols that are useless for disassembly.
COUNT is the number of elements in SYMBOLS.
Return the number of useful symbols. */
-static unsigned long
-remove_useless_symbols (asymbol **symbols, unsigned long count)
+static long
+remove_useless_symbols (asymbol **symbols, long count)
{
asymbol **in_ptr = symbols;
asymbol **out_ptr = symbols;
/* Find the name of the function at ADDR. */
const char *
-aarch64_get_func (uint64_t addr)
+aarch64_get_func (SIM_DESC sd, uint64_t addr)
{
+ long symcount = STATE_PROG_SYMS_COUNT (sd);
+ asymbol **symtab = STATE_PROG_SYMS (sd);
int min, max;
min = -1;
return "";
}
-uint64_t
-aarch64_get_sym_value (const char *name)
-{
- unsigned long i;
-
- for (i = 0; i < symcount; i++)
- if (strcmp (bfd_asymbol_name (symtab[i]), name) == 0)
- return bfd_asymbol_value (symtab[i]);
-
- return 0;
-}
-
SIM_RC
sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
char * const *argv, char * const *env)
{
sim_cpu *cpu = STATE_CPU (sd, 0);
- long storage = 0;
bfd_vma addr = 0;
if (abfd != NULL)
STATE_PROG_ARGV (sd) = dupargv (argv);
}
- if (abfd != NULL)
- storage = bfd_get_symtab_upper_bound (abfd);
- if (storage > 0)
+ if (trace_load_symbols (sd))
{
- symtab = (asymbol **) xmalloc (storage);
- symcount = bfd_canonicalize_symtab (abfd, symtab);
- symcount = remove_useless_symbols (symtab, symcount);
- qsort (symtab, symcount, sizeof (asymbol *), compare_symbols);
+ STATE_PROG_SYMS_COUNT (sd) =
+ remove_useless_symbols (STATE_PROG_SYMS (sd),
+ STATE_PROG_SYMS_COUNT (sd));
+ qsort (STATE_PROG_SYMS (sd), STATE_PROG_SYMS_COUNT (sd),
+ sizeof (asymbol *), compare_symbols);
}
aarch64_init (cpu, addr);