aboutsummaryrefslogtreecommitdiff
path: root/sim/aarch64/interp.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-01-21 22:17:59 -0500
committerMike Frysinger <vapier@gentoo.org>2016-08-15 07:00:11 -0700
commit5357150c97899af2cc93072780a9c3a128c5b1ae (patch)
treef61415d77e934b9f54994e92e7f00b30da499890 /sim/aarch64/interp.c
parent31925464a80970e37c06192a0c49f8948a2f5da0 (diff)
downloadbinutils-5357150c97899af2cc93072780a9c3a128c5b1ae.zip
binutils-5357150c97899af2cc93072780a9c3a128c5b1ae.tar.gz
binutils-5357150c97899af2cc93072780a9c3a128c5b1ae.tar.bz2
sim: unify symbol table handling
The common sim tracing code already handles loading and tracking of symbols from the target program so that it can show symbol info in trace/disassembly calls. Once we touch up the trace code and add a few API callbacks, ports don't need to do loading and searching of symbol tables themselves anymore.
Diffstat (limited to 'sim/aarch64/interp.c')
-rw-r--r--sim/aarch64/interp.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c
index 2a3ff26..2c72c13 100644
--- a/sim/aarch64/interp.c
+++ b/sim/aarch64/interp.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include "ansidecl.h"
+#include "bfd.h"
#include "gdb/callback.h"
#include "gdb/remote-sim.h"
#include "gdb/signals.h"
@@ -38,15 +39,12 @@
#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;
@@ -87,8 +85,10 @@ compare_symbols (const void *ap, const void *bp)
/* 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;
@@ -118,24 +118,11 @@ aarch64_get_func (uint64_t addr)
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)
@@ -154,14 +141,13 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
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);