summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/chunk_generator.hh2
-rw-r--r--src/base/loader/elf_object.cc32
-rw-r--r--src/base/loader/elf_object.hh9
-rw-r--r--src/base/loader/symtab.hh12
-rw-r--r--src/base/remote_gdb.hh1
5 files changed, 48 insertions, 8 deletions
diff --git a/src/base/chunk_generator.hh b/src/base/chunk_generator.hh
index e9d5355ca..e8238464b 100644
--- a/src/base/chunk_generator.hh
+++ b/src/base/chunk_generator.hh
@@ -72,7 +72,7 @@ class ChunkGenerator
public:
/**
* Constructor.
- * @param startAddr The starting address of the region.
+ * @param _startAddr The starting address of the region.
* @param totalSize The total size of the region.
* @param _chunkSize The size/alignment of chunks into which
* the region should be decomposed.
diff --git a/src/base/loader/elf_object.cc b/src/base/loader/elf_object.cc
index 00d218b76..2ca0d4f4a 100644
--- a/src/base/loader/elf_object.cc
+++ b/src/base/loader/elf_object.cc
@@ -153,8 +153,38 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
} // while sections
}
+ ElfObject * result = new ElfObject(fname, fd, len, data, arch, opSys);
+
+ //The number of headers in the file
+ result->_programHeaderCount = ehdr.e_phnum;
+ //Record the size of each entry
+ result->_programHeaderSize = ehdr.e_phentsize;
+ if(result->_programHeaderCount) //If there is a program header table
+ {
+ //Figure out the virtual address of the header table in the
+ //final memory image. We use the program headers themselves
+ //to translate from a file offset to the address in the image.
+ GElf_Phdr phdr;
+ uint64_t e_phoff = ehdr.e_phoff;
+ result->_programHeaderTable = 0;
+ for(int hdrnum = 0; hdrnum < result->_programHeaderCount; hdrnum++)
+ {
+ gelf_getphdr(elf, hdrnum, &phdr);
+ //Check if we've found the segment with the headers in it
+ if(phdr.p_offset <= e_phoff &&
+ phdr.p_offset + phdr.p_filesz > e_phoff)
+ {
+ result->_programHeaderTable = phdr.p_vaddr + e_phoff;
+ break;
+ }
+ }
+ }
+ else
+ result->_programHeaderTable = 0;
+
+
elf_end(elf);
- return new ElfObject(fname, fd, len, data, arch, opSys);
+ return result;
}
}
diff --git a/src/base/loader/elf_object.hh b/src/base/loader/elf_object.hh
index 46dbfe37b..9755426b4 100644
--- a/src/base/loader/elf_object.hh
+++ b/src/base/loader/elf_object.hh
@@ -37,6 +37,12 @@ class ElfObject : public ObjectFile
{
protected:
+ //These values are provided to a linux process by the kernel, so we
+ //need to keep them around.
+ Addr _programHeaderTable;
+ uint16_t _programHeaderSize;
+ uint16_t _programHeaderCount;
+
/// Helper functions for loadGlobalSymbols() and loadLocalSymbols().
bool loadSomeSymbols(SymbolTable *symtab, int binding);
@@ -52,6 +58,9 @@ class ElfObject : public ObjectFile
static ObjectFile *tryFile(const std::string &fname, int fd,
size_t len, uint8_t *data);
+ Addr programHeaderTable() {return _programHeaderTable;}
+ uint16_t programHeaderSize() {return _programHeaderSize;}
+ uint16_t programHeaderCount() {return _programHeaderCount;}
};
#endif // __ELF_OBJECT_HH__
diff --git a/src/base/loader/symtab.hh b/src/base/loader/symtab.hh
index 55ff0c86f..184c0a996 100644
--- a/src/base/loader/symtab.hh
+++ b/src/base/loader/symtab.hh
@@ -104,11 +104,11 @@ class SymbolTable
/// Find the nearest symbol equal to or less than the supplied
/// address (e.g., the label for the enclosing function).
- /// @param address The address to look up.
- /// @param symbol Return reference for symbol string.
- /// @param sym_address Return reference for symbol address.
- /// @param next_sym_address Address of following symbol (for
- /// determining valid range of symbol).
+ /// @param addr The address to look up.
+ /// @param symbol Return reference for symbol string.
+ /// @param symaddr Return reference for symbol address.
+ /// @param nextaddr Address of following symbol (for
+ /// determining valid range of symbol).
/// @retval True if a symbol was found.
bool
findNearestSymbol(Addr addr, std::string &symbol, Addr &symaddr,
@@ -126,7 +126,7 @@ class SymbolTable
}
/// Overload for findNearestSymbol() for callers who don't care
- /// about next_sym_address.
+ /// about nextaddr.
bool
findNearestSymbol(Addr addr, std::string &symbol, Addr &symaddr) const
{
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 90b53e53f..8c3ce7572 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -33,6 +33,7 @@
#include <map>
+#include "arch/types.hh"
#include "base/kgdb.h"
#include "cpu/pc_event.hh"
#include "base/pollevent.hh"