object_file.cc (8229:78bf55f23338) object_file.cc (8706:b1838faf3bcc)
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 31 unchanged lines hidden (view full) ---

40
41#include "base/loader/aout_object.hh"
42#include "base/loader/ecoff_object.hh"
43#include "base/loader/elf_object.hh"
44#include "base/loader/object_file.hh"
45#include "base/loader/raw_object.hh"
46#include "base/loader/symtab.hh"
47#include "base/cprintf.hh"
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 31 unchanged lines hidden (view full) ---

40
41#include "base/loader/aout_object.hh"
42#include "base/loader/ecoff_object.hh"
43#include "base/loader/elf_object.hh"
44#include "base/loader/object_file.hh"
45#include "base/loader/raw_object.hh"
46#include "base/loader/symtab.hh"
47#include "base/cprintf.hh"
48#include "mem/translating_port.hh"
48#include "mem/port_proxy.hh"
49
50using namespace std;
51
52ObjectFile::ObjectFile(const string &_filename, int _fd,
53 size_t _len, uint8_t *_data,
54 Arch _arch, OpSys _opSys)
55 : filename(_filename), descriptor(_fd), fileData(_data), len(_len),
56 arch(_arch), opSys(_opSys)
57{
58}
59
60
61ObjectFile::~ObjectFile()
62{
63 close();
64}
65
66
67bool
49
50using namespace std;
51
52ObjectFile::ObjectFile(const string &_filename, int _fd,
53 size_t _len, uint8_t *_data,
54 Arch _arch, OpSys _opSys)
55 : filename(_filename), descriptor(_fd), fileData(_data), len(_len),
56 arch(_arch), opSys(_opSys)
57{
58}
59
60
61ObjectFile::~ObjectFile()
62{
63 close();
64}
65
66
67bool
68ObjectFile::loadSection(Section *sec, Port *memPort, Addr addrMask)
68ObjectFile::loadSection(Section *sec, PortProxy* memProxy, Addr addrMask)
69{
70 if (sec->size != 0) {
71 Addr addr = sec->baseAddr & addrMask;
72 if (sec->fileImage) {
69{
70 if (sec->size != 0) {
71 Addr addr = sec->baseAddr & addrMask;
72 if (sec->fileImage) {
73 memPort->writeBlob(addr, sec->fileImage, sec->size);
73 memProxy->writeBlob(addr, sec->fileImage, sec->size);
74 }
75 else {
76 // no image: must be bss
74 }
75 else {
76 // no image: must be bss
77 memPort->memsetBlob(addr, 0, sec->size);
77 memProxy->memsetBlob(addr, 0, sec->size);
78 }
79 }
80 return true;
81}
82
83
84bool
78 }
79 }
80 return true;
81}
82
83
84bool
85ObjectFile::loadSections(Port *memPort, Addr addrMask)
85ObjectFile::loadSections(PortProxy* memProxy, Addr addrMask)
86{
86{
87 return (loadSection(&text, memPort, addrMask)
88 && loadSection(&data, memPort, addrMask)
89 && loadSection(&bss, memPort, addrMask));
87 return (loadSection(&text, memProxy, addrMask)
88 && loadSection(&data, memProxy, addrMask)
89 && loadSection(&bss, memProxy, addrMask));
90}
91
92
93void
94ObjectFile::close()
95{
96 if (descriptor >= 0) {
97 ::close(descriptor);

--- 53 unchanged lines hidden ---
90}
91
92
93void
94ObjectFile::close()
95{
96 if (descriptor >= 0) {
97 ::close(descriptor);

--- 53 unchanged lines hidden ---