From 5357150c97899af2cc93072780a9c3a128c5b1ae Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 21 Jan 2016 22:17:59 -0500 Subject: 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. --- sim/lm32/ChangeLog | 6 ++++++ sim/lm32/sim-if.c | 24 ++++++------------------ 2 files changed, 12 insertions(+), 18 deletions(-) (limited to 'sim/lm32') diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog index c1b442d..51869ba 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,3 +1,9 @@ +2016-08-15 Mike Frysinger + + * sim-if.c (find_limit): Change prototype to take a SIM_DESC. + Replace symbol lookup code with a call to trace_sym_value. + (sim_open): Update find_limit call. + 2016-01-10 Mike Frysinger * config.in, configure: Regenerate. diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c index 860c1e6..aad3a35 100644 --- a/sim/lm32/sim-if.c +++ b/sim/lm32/sim-if.c @@ -71,27 +71,15 @@ find_base (bfd *prog_bfd) } static unsigned long -find_limit (bfd *prog_bfd) +find_limit (SIM_DESC sd) { - struct bfd_symbol **asymbols; - long symsize; - long symbol_count; - long s; + bfd_vma addr; - symsize = bfd_get_symtab_upper_bound (prog_bfd); - if (symsize < 0) - return 0; - asymbols = (asymbol **) xmalloc (symsize); - symbol_count = bfd_canonicalize_symtab (prog_bfd, asymbols); - if (symbol_count < 0) + addr = trace_sym_value (sd, "_fstack"); + if (addr == -1) return 0; - for (s = 0; s < symbol_count; s++) - { - if (!strcmp (asymbols[s]->name, "_fstack")) - return (asymbols[s]->value + 65536) & ~(0xffffUL); - } - return 0; + return (addr + 65536) & ~(0xffffUL); } /* Create an instance of the simulator. */ @@ -159,7 +147,7 @@ sim_open (kind, callback, abfd, argv) { /* It doesn't, so we should try to allocate enough memory to hold program. */ base = find_base (STATE_PROG_BFD (sd)); - limit = find_limit (STATE_PROG_BFD (sd)); + limit = find_limit (sd); if (limit == 0) { sim_io_eprintf (sd, -- cgit v1.1