Browse Source

fesvr: Add symbol_elfs field to htif_t

When populated, symbol_elfs are additional elf files that populate the
addr2symbol map in htif
pull/1274/head
Jerry Zhao 3 years ago
parent
commit
76a4414381
  1. 16
      fesvr/htif.cc
  2. 1
      fesvr/htif.h

16
fesvr/htif.cc

@ -7,6 +7,7 @@
#include "platform.h" #include "platform.h"
#include "byteorder.h" #include "byteorder.h"
#include "trap.h" #include "trap.h"
#include "../riscv/common.h"
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <vector> #include <vector>
@ -171,6 +172,21 @@ void htif_t::load_program()
load_payload(payload, &dummy_entry); load_payload(payload, &dummy_entry);
} }
class nop_memif_t : public memif_t {
public:
nop_memif_t(htif_t* htif) : memif_t(htif), htif(htif) {}
void read(addr_t UNUSED addr, size_t UNUSED len, void UNUSED *bytes) override {}
void write(addr_t UNUSED taddr, size_t UNUSED len, const void UNUSED *src) override {}
private:
htif_t* htif;
} nop_memif(this);
reg_t nop_entry;
for (auto &s : symbol_elfs) {
std::map<std::string, uint64_t> other_symbols = load_elf(s.c_str(), &nop_memif, &nop_entry,
expected_xlen);
symbols.merge(other_symbols);
}
for (auto i : symbols) { for (auto i : symbols) {
auto it = addr2symbol.find(i.second); auto it = addr2symbol.find(i.second);

1
fesvr/htif.h

@ -99,6 +99,7 @@ class htif_t : public chunked_memif_t
std::vector<device_t*> dynamic_devices; std::vector<device_t*> dynamic_devices;
std::vector<std::string> payloads; std::vector<std::string> payloads;
std::vector<std::string> symbol_elfs;
std::map<uint64_t, std::string> addr2symbol; std::map<uint64_t, std::string> addr2symbol;
friend class memif_t; friend class memif_t;

Loading…
Cancel
Save