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/m68hc11/ChangeLog | 6 ++++++ sim/m68hc11/interp.c | 49 ++++++++++++------------------------------------- 2 files changed, 18 insertions(+), 37 deletions(-) (limited to 'sim/m68hc11') diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog index e7619d3..5564c0a 100644 --- a/sim/m68hc11/ChangeLog +++ b/sim/m68hc11/ChangeLog @@ -1,3 +1,9 @@ +2016-08-15 Mike Frysinger + + * interp.c (sim_get_bank_parameters): Delete abfd arg. + Replace all symbol lookup code with calls to trace_sym_value. + (sim_prepare_for_program): Update sim_get_bank_parameters call. + 2016-08-13 Mike Frysinger * dv-m68hc11.c (m68hc11cpu_port_event): Adjust cpu prototype style. diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c index ab20571..8a80656 100644 --- a/sim/m68hc11/interp.c +++ b/sim/m68hc11/interp.c @@ -292,50 +292,25 @@ sim_hw_configure (SIM_DESC sd) /* Get the memory bank parameters by looking at the global symbols defined by the linker. */ static int -sim_get_bank_parameters (SIM_DESC sd, bfd* abfd) +sim_get_bank_parameters (SIM_DESC sd) { sim_cpu *cpu; - long symsize; - long symbol_count, i; unsigned size; - asymbol** asymbols; - asymbol** current; + bfd_vma addr; cpu = STATE_CPU (sd, 0); - symsize = bfd_get_symtab_upper_bound (abfd); - if (symsize < 0) - { - sim_io_eprintf (sd, "Cannot read symbols of program"); - return 0; - } - asymbols = (asymbol **) xmalloc (symsize); - symbol_count = bfd_canonicalize_symtab (abfd, asymbols); - if (symbol_count < 0) - { - sim_io_eprintf (sd, "Cannot read symbols of program"); - return 0; - } + addr = trace_sym_value (sd, BFD_M68HC11_BANK_START_NAME); + if (addr != -1) + cpu->bank_start = addr; - size = 0; - for (i = 0, current = asymbols; i < symbol_count; i++, current++) - { - const char* name = bfd_asymbol_name (*current); + size = trace_sym_value (sd, BFD_M68HC11_BANK_SIZE_NAME); + if (size == -1) + size = 0; - if (strcmp (name, BFD_M68HC11_BANK_START_NAME) == 0) - { - cpu->bank_start = bfd_asymbol_value (*current); - } - else if (strcmp (name, BFD_M68HC11_BANK_SIZE_NAME) == 0) - { - size = bfd_asymbol_value (*current); - } - else if (strcmp (name, BFD_M68HC11_BANK_VIRTUAL_NAME) == 0) - { - cpu->bank_virtual = bfd_asymbol_value (*current); - } - } - free (asymbols); + addr = trace_sym_value (sd, BFD_M68HC11_BANK_VIRTUAL_NAME); + if (addr != -1) + cpu->bank_virtual = addr; cpu->bank_end = cpu->bank_start + size; cpu->bank_shift = 0; @@ -387,7 +362,7 @@ sim_prepare_for_program (SIM_DESC sd, bfd* abfd) if (elf_flags & E_M68HC12_BANKS) { - if (sim_get_bank_parameters (sd, abfd) != 0) + if (sim_get_bank_parameters (sd) != 0) sim_io_eprintf (sd, "Memory bank parameters are not initialized\n"); } } -- cgit v1.1