Added the load address and the section flags to ElfSection.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39275 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-11-02 20:03:11 +00:00
parent 2ee3a4e272
commit e2ea5a6646
2 changed files with 18 additions and 6 deletions
+9 -4
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009-2010, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -23,13 +23,16 @@
// #pragma mark - ElfSection // #pragma mark - ElfSection
ElfSection::ElfSection(const char* name, int fd, off_t offset, off_t size) ElfSection::ElfSection(const char* name, int fd, off_t offset, off_t size,
target_addr_t loadAddress, uint32 flags)
: :
fName(name), fName(name),
fFD(fd), fFD(fd),
fOffset(offset), fOffset(offset),
fSize(size), fSize(size),
fData(NULL), fData(NULL),
fLoadAddress(loadAddress),
fFlags(flags),
fLoadCount(0) fLoadCount(0)
{ {
} }
@@ -190,7 +193,8 @@ ElfFile::Init(const char* fileName)
size_t sectionStringSize = stringSectionHeader->sh_size; size_t sectionStringSize = stringSectionHeader->sh_size;
ElfSection* sectionStringSection = new(std::nothrow) ElfSection(".shstrtab", ElfSection* sectionStringSection = new(std::nothrow) ElfSection(".shstrtab",
fFD, stringSectionHeader->sh_offset, sectionStringSize); fFD, stringSectionHeader->sh_offset, sectionStringSize,
stringSectionHeader->sh_addr, stringSectionHeader->sh_flags);
if (sectionStringSection == NULL) if (sectionStringSection == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
fSections.Add(sectionStringSection); fSections.Add(sectionStringSection);
@@ -215,7 +219,8 @@ ElfFile::Init(const char* fileName)
// create an ElfSection // create an ElfSection
ElfSection* section = new(std::nothrow) ElfSection(name, fFD, ElfSection* section = new(std::nothrow) ElfSection(name, fFD,
sectionHeader->sh_offset, sectionHeader->sh_size); sectionHeader->sh_offset, sectionHeader->sh_size,
sectionHeader->sh_addr, sectionHeader->sh_flags);
if (section == NULL) if (section == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
fSections.Add(section); fSections.Add(section);
+9 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2009, Ingo Weinhold, [email protected]. * Copyright 2009-2010, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef ELF_FILE_H #ifndef ELF_FILE_H
@@ -18,13 +18,18 @@
class ElfSection : public DoublyLinkedListLinkImpl<ElfSection> { class ElfSection : public DoublyLinkedListLinkImpl<ElfSection> {
public: public:
ElfSection(const char* name, int fd, ElfSection(const char* name, int fd,
off_t offset, off_t size); off_t offset, off_t size,
target_addr_t loadAddress, uint32 flags);
~ElfSection(); ~ElfSection();
const char* Name() const { return fName; } const char* Name() const { return fName; }
off_t Offset() const { return fOffset; } off_t Offset() const { return fOffset; }
off_t Size() const { return fSize; } off_t Size() const { return fSize; }
const void* Data() const { return fData; } const void* Data() const { return fData; }
target_addr_t LoadAddress() const
{ return fLoadAddress; }
bool IsWritable() const
{ return (fFlags & SHF_WRITE) != 0; }
status_t Load(); status_t Load();
void Unload(); void Unload();
@@ -35,6 +40,8 @@ private:
off_t fOffset; off_t fOffset;
off_t fSize; off_t fSize;
void* fData; void* fData;
target_addr_t fLoadAddress;
uint32 fFlags;
int32 fLoadCount; int32 fLoadCount;
}; };