diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-01-21 22:17:59 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-08-15 07:00:11 -0700 |
commit | 5357150c97899af2cc93072780a9c3a128c5b1ae (patch) | |
tree | f61415d77e934b9f54994e92e7f00b30da499890 /sim/m68hc11/interp.c | |
parent | 31925464a80970e37c06192a0c49f8948a2f5da0 (diff) | |
download | fsf-binutils-gdb-5357150c97899af2cc93072780a9c3a128c5b1ae.zip fsf-binutils-gdb-5357150c97899af2cc93072780a9c3a128c5b1ae.tar.gz fsf-binutils-gdb-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/m68hc11/interp.c')
-rw-r--r-- | sim/m68hc11/interp.c | 49 |
1 files changed, 12 insertions, 37 deletions
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"); } } |