36 #include <sys/types.h> 
   56                        size_t _len, uint8_t *_data,
 
   58     : filename(_filename), fileData(_data), 
len(_len),
 
   59       arch(_arch), opSys(_op_sys), entry(0), globalPtr(0),
 
   60       text{0, 
nullptr, 0}, 
data{0, 
nullptr, 0}, bss{0, 
nullptr, 0}
 
  103     uint8_t buf[2] = {0};
 
  104     size_t sz = pread(fd, buf, 2, 0);
 
  105     panic_if(sz != 2, 
"Couldn't read magic bytes from object file");
 
  106     return ((buf[0] == 0x1f) && (buf[1] == 0x8b));
 
  112     const size_t blk_sz = 4096;
 
  114     gzFile fdz = gzdopen(fd, 
"rb");
 
  119     size_t tmp_len = strlen(P_tmpdir);
 
  120     char *tmpnam = (
char*) malloc(tmp_len + 20);
 
  121     strcpy(tmpnam, P_tmpdir);
 
  122     strcpy(tmpnam+tmp_len, 
"/gem5-gz-obj-XXXXXX"); 
 
  123     fd = mkstemp(tmpnam); 
 
  130     if (unlink(tmpnam) != 0)
 
  131         warn(
"couldn't remove temporary file %s\n", tmpnam);
 
  135     auto buf = 
new uint8_t[blk_sz];
 
  137     while ((r = gzread(fdz, buf, blk_sz)) > 0) {
 
  140             auto sz = write(fd, 
p, r);
 
  160     int fd = open(fname.c_str(), O_RDONLY);
 
  174     off_t off = lseek(fd, 0, SEEK_END);
 
  176              "Failed to determine size of object file %s\n", fname);
 
  177     auto len = 
static_cast<size_t>(off);
 
  180     uint8_t *file_data = (uint8_t *)mmap(NULL, 
len, PROT_READ, MAP_SHARED,
 
  184     if (file_data == MAP_FAILED) {
 
  211     munmap((
char*)file_data, 
len);
 
static int doGzipLoad(int fd)
 
static ObjectFile * tryFile(const std::string &fname, size_t len, uint8_t *data)
 
static bool hasGzipMagic(int fd)
 
panic_if(!root,"Invalid expression\n")
 
static ObjectFile * tryFile(const std::string &fname, size_t len, uint8_t *data)
 
This implements an object file format to support loading and modifying flattened device tree blobs fo...
 
static ObjectFile * tryFile(const std::string &fname, size_t len, uint8_t *data)
 
PortProxy Object Declaration. 
 
ObjectFile(const std::string &_filename, size_t _len, uint8_t *_data, Arch _arch, OpSys _opSys)
 
uint64_t Addr
Address type This will probably be moved somewhere else in the near future. 
 
virtual bool loadSections(PortProxy &mem_proxy, Addr mask=maxAddr, Addr offset=0)
 
This object is a proxy for a structural port, to be used for debug accesses. 
 
static ObjectFile * tryFile(const std::string &fname, size_t len, uint8_t *data, bool skip_interp_check=false)
 
ObjectFile * createObjectFile(const string &fname, bool raw)
 
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const 
Write size bytes from p to address. 
 
static ObjectFile * tryFile(const std::string &fname, size_t len, uint8_t *data)
Static function that tries to load file as a flattened device tree blob. 
 
virtual void memsetBlob(Addr addr, uint8_t v, int size) const 
Fill size bytes starting at addr with byte value val. 
 
bool loadSection(Section *sec, PortProxy &mem_proxy, Addr mask, Addr offset=0)
 
fatal_if(p->js_features.size() > 16,"Too many job slot feature registers specified (%i)\n", p->js_features.size())