summaryrefslogtreecommitdiff
path: root/src/base/loader/object_file.cc
diff options
context:
space:
mode:
authorCurtis Dunham <Curtis.Dunham@arm.com>2015-07-03 10:14:34 -0400
committerCurtis Dunham <Curtis.Dunham@arm.com>2015-07-03 10:14:34 -0400
commite385ae0c72993d1d58256324d0fe425247fad207 (patch)
treed133e9497e8f08ed370a0fc425b2e8f561632156 /src/base/loader/object_file.cc
parentd9f8f076135870de5382f2d2ec3b185b6ece6b16 (diff)
downloadgem5-e385ae0c72993d1d58256324d0fe425247fad207.tar.xz
base: remove fd from object loaders
All the object loaders directly examine the (already completely loaded by object_file.cc) memory image. There is no current motivation to keep the fd around.
Diffstat (limited to 'src/base/loader/object_file.cc')
-rw-r--r--src/base/loader/object_file.cc22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/base/loader/object_file.cc b/src/base/loader/object_file.cc
index 29cea8ccf..e24aeddd3 100644
--- a/src/base/loader/object_file.cc
+++ b/src/base/loader/object_file.cc
@@ -50,10 +50,10 @@
using namespace std;
-ObjectFile::ObjectFile(const string &_filename, int _fd,
+ObjectFile::ObjectFile(const string &_filename,
size_t _len, uint8_t *_data,
Arch _arch, OpSys _opSys)
- : filename(_filename), descriptor(_fd), fileData(_data), len(_len),
+ : filename(_filename), fileData(_data), len(_len),
arch(_arch), opSys(_opSys), entry(0), globalPtr(0),
text{0, nullptr, 0}, data{0, nullptr, 0}, bss{0, nullptr, 0}
{
@@ -95,11 +95,6 @@ ObjectFile::loadSections(PortProxy& memProxy, Addr addrMask, Addr offset)
void
ObjectFile::close()
{
- if (descriptor >= 0) {
- ::close(descriptor);
- descriptor = -1;
- }
-
if (fileData) {
::munmap((char*)fileData, len);
fileData = NULL;
@@ -124,35 +119,34 @@ createObjectFile(const string &fname, bool raw)
// mmap the whole shebang
uint8_t *fileData =
(uint8_t *)mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
+ close(fd);
if (fileData == MAP_FAILED) {
- close(fd);
return NULL;
}
ObjectFile *fileObj = NULL;
// figure out what we have here
- if ((fileObj = EcoffObject::tryFile(fname, fd, len, fileData)) != NULL) {
+ if ((fileObj = ElfObject::tryFile(fname, len, fileData)) != NULL) {
return fileObj;
}
- if ((fileObj = AoutObject::tryFile(fname, fd, len, fileData)) != NULL) {
+ if ((fileObj = EcoffObject::tryFile(fname, len, fileData)) != NULL) {
return fileObj;
}
- if ((fileObj = ElfObject::tryFile(fname, fd, len, fileData)) != NULL) {
+ if ((fileObj = AoutObject::tryFile(fname, len, fileData)) != NULL) {
return fileObj;
}
- if ((fileObj = DtbObject::tryFile(fname, fd, len, fileData)) != NULL) {
+ if ((fileObj = DtbObject::tryFile(fname, len, fileData)) != NULL) {
return fileObj;
}
if (raw)
- return RawObject::tryFile(fname, fd, len, fileData);
+ return RawObject::tryFile(fname, len, fileData);
// don't know what it is
- close(fd);
munmap((char*)fileData, len);
return NULL;
}