diff --git a/fesvr/htif.cc b/fesvr/htif.cc index 13cdc0af..c64ce2ad 100644 --- a/fesvr/htif.cc +++ b/fesvr/htif.cc @@ -84,12 +84,17 @@ htif_t::~htif_t() void htif_t::start() { - if (!targs.empty() && targs[0] != "none") { - try { - load_program(); - } catch (const incompat_xlen & err) { - fprintf(stderr, "Error: cannot execute %d-bit program on RV%d hart\n", err.actual_xlen, err.expected_xlen); - exit(1); + if (!targs.empty()) { + if (targs[0] != "none") { + try { + load_program(); + } catch (const incompat_xlen & err) { + fprintf(stderr, "Error: cannot execute %d-bit program on RV%d hart\n", err.actual_xlen, err.expected_xlen); + exit(1); + } + } else { + auto empty_symbols = std::map(); + load_symbols(empty_symbols); } } @@ -150,21 +155,8 @@ std::map htif_t::load_payload(const std::string& payload, } } -void htif_t::load_program() +void htif_t::load_symbols(std::map& symbols) { - std::map symbols = load_payload(targs[0], &entry, load_offset); - - // detect torture tests so we can print the memory signature at the end - if (symbols.count("begin_signature") && symbols.count("end_signature")) { - sig_addr = symbols["begin_signature"]; - sig_len = symbols["end_signature"] - sig_addr; - } - - for (auto payload : payloads) { - reg_t dummy_entry; - load_payload(payload, &dummy_entry, 0); - } - class nop_memif_t : public memif_t { public: nop_memif_t(htif_t* htif) : memif_t(htif), htif(htif) {} @@ -181,6 +173,12 @@ void htif_t::load_program() symbols.merge(other_symbols); } + // detect torture tests so we can print the memory signature at the end + if (symbols.count("begin_signature") && symbols.count("end_signature")) { + sig_addr = symbols["begin_signature"]; + sig_len = symbols["end_signature"] - sig_addr; + } + if (symbols.count("tohost") && symbols.count("fromhost")) { tohost_addr = symbols["tohost"]; fromhost_addr = symbols["fromhost"]; @@ -193,6 +191,18 @@ void htif_t::load_program() if ( it == addr2symbol.end()) addr2symbol[i.second] = i.first; } +} + +void htif_t::load_program() +{ + std::map symbols = load_payload(targs[0], &entry, load_offset); + + load_symbols(symbols); + + for (auto payload : payloads) { + reg_t dummy_entry; + load_payload(payload, &dummy_entry, 0); + } return; } diff --git a/fesvr/htif.h b/fesvr/htif.h index a790f46c..380e24af 100644 --- a/fesvr/htif.h +++ b/fesvr/htif.h @@ -65,6 +65,7 @@ class htif_t : public chunked_memif_t virtual std::map load_payload(const std::string& payload, reg_t* entry, reg_t load_addr); virtual void load_program(); + virtual void load_symbols(std::map&); virtual void idle() {} const std::vector& host_args() { return hargs; }