mirror of
https://review.haiku-os.org/haiku
synced 2025-02-06 13:58:21 +01:00
of a DWARF 3 reader. It can read the .debug_info section and create objects for the entries, but most attributes are ignored yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31047 a95241bf-73f2-0310-859d-f6bbb57e9c96
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
/*
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef ELF_FILE_H
|
|
#define ELF_FILE_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <elf32.h>
|
|
#include <util/DoublyLinkedList.h>
|
|
|
|
|
|
class ElfSection : public DoublyLinkedListLinkImpl<ElfSection> {
|
|
public:
|
|
ElfSection(const char* name, int fd,
|
|
off_t offset, off_t size);
|
|
~ElfSection();
|
|
|
|
const char* Name() const { return fName; }
|
|
off_t Offset() const { return fOffset; }
|
|
off_t Size() const { return fSize; }
|
|
const void* Data() const { return fData; }
|
|
|
|
status_t Load();
|
|
void Unload();
|
|
|
|
private:
|
|
const char* fName;
|
|
int fFD;
|
|
off_t fOffset;
|
|
off_t fSize;
|
|
void* fData;
|
|
int32 fLoadCount;
|
|
};
|
|
|
|
|
|
class ElfFile {
|
|
public:
|
|
ElfFile();
|
|
~ElfFile();
|
|
|
|
status_t Init(const char* fileName);
|
|
|
|
ElfSection* GetSection(const char* name);
|
|
void PutSection(ElfSection* section);
|
|
|
|
private:
|
|
typedef DoublyLinkedList<ElfSection> SectionList;
|
|
|
|
private:
|
|
bool _CheckRange(off_t offset, off_t size) const;
|
|
bool _CheckElfHeader() const;
|
|
|
|
private:
|
|
off_t fFileSize;
|
|
int fFD;
|
|
Elf32_Ehdr* fElfHeader;
|
|
SectionList fSections;
|
|
};
|
|
|
|
|
|
#endif // ELF_FILE_H
|