2024-02-14 18:42:04 -08:00
|
|
|
#pragma once
|
|
|
|
|
2024-02-14 23:39:35 -08:00
|
|
|
#include <ehs/Serializer.h>
|
2024-02-14 18:42:04 -08:00
|
|
|
#include <ehs/Array.h>
|
|
|
|
#include <ehs/Str.h>
|
|
|
|
|
2024-02-14 23:39:35 -08:00
|
|
|
/// Section types.
|
|
|
|
#define SECH_TYPE_NULL 0x0000
|
|
|
|
#define SECH_TYPE_PROGBITS 0x0001
|
2024-02-15 05:05:02 -08:00
|
|
|
#define SECH_TYPE_SYMTAB 0x0002
|
2024-02-14 23:39:35 -08:00
|
|
|
#define SECH_TYPE_STRTAB 0x0003
|
|
|
|
|
|
|
|
/// Section flags.
|
|
|
|
#define SECH_FLAG_ALLOC 0x02
|
|
|
|
#define SECH_FLAG_EXEC 0x04
|
|
|
|
#define SECH_FLAG_STRINGS 0x20
|
|
|
|
|
|
|
|
#define SECH_SIZE 64
|
|
|
|
|
2024-02-14 18:42:04 -08:00
|
|
|
class ELF64_Section
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class ELF64;
|
|
|
|
|
2024-02-14 23:39:35 -08:00
|
|
|
ehs::UInt_64 hashId;
|
|
|
|
ehs::Str_8 id;
|
|
|
|
ehs::UInt_32 nameOffset;
|
2024-02-15 05:05:02 -08:00
|
|
|
ehs::UInt_64 fileOffset;
|
2024-02-14 18:42:04 -08:00
|
|
|
ehs::UInt_32 type;
|
|
|
|
ehs::UInt_64 flags;
|
|
|
|
ehs::UInt_64 vAddr;
|
|
|
|
ehs::UInt_64 segmentOffset;
|
2024-02-15 05:05:02 -08:00
|
|
|
ehs::UInt_32 link;
|
2024-02-14 18:42:04 -08:00
|
|
|
ehs::UInt_32 info;
|
|
|
|
ehs::UInt_64 align;
|
2024-02-15 05:05:02 -08:00
|
|
|
ehs::UInt_64 entries;
|
2024-02-14 23:39:35 -08:00
|
|
|
ehs::Serializer<ehs::UInt_64> data;
|
2024-02-14 18:42:04 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
ELF64_Section();
|
|
|
|
|
2024-02-15 05:05:02 -08:00
|
|
|
ELF64_Section(ehs::Str_8 id, ehs::UInt_64 fileOffset, ehs::UInt_32 type, ehs::UInt_64 flags, ehs::UInt_64 vAddr, ehs::UInt_64 align);
|
2024-02-14 23:39:35 -08:00
|
|
|
|
|
|
|
ELF64_Section(ELF64_Section&& sect) noexcept;
|
|
|
|
|
|
|
|
ELF64_Section(const ELF64_Section& sect);
|
|
|
|
|
|
|
|
ELF64_Section& operator=(ELF64_Section&& sect) noexcept;
|
|
|
|
|
|
|
|
ELF64_Section& operator=(const ELF64_Section& sect);
|
|
|
|
|
|
|
|
ehs::UInt_64 GetHashId() const;
|
|
|
|
|
|
|
|
ehs::Str_8 GetId() const;
|
|
|
|
|
|
|
|
ehs::UInt_32 GetType() const;
|
|
|
|
|
|
|
|
ehs::UInt_64 GetFlags() const;
|
|
|
|
|
|
|
|
ehs::UInt_64 GetVirtualAddress() const;
|
|
|
|
|
2024-02-15 05:05:02 -08:00
|
|
|
void SetLink(ehs::UInt_32 newLink);
|
|
|
|
|
|
|
|
void SetInfo(ehs::UInt_32 newInfo);
|
|
|
|
|
2024-02-14 23:39:35 -08:00
|
|
|
ehs::UInt_64 GetAlignment() const;
|
|
|
|
|
2024-02-15 05:05:02 -08:00
|
|
|
void SetEntries(ehs::UInt_64 newEntries);
|
|
|
|
|
2024-02-14 23:39:35 -08:00
|
|
|
void SetData(ehs::Serializer<ehs::UInt_64> newData);
|
|
|
|
|
|
|
|
ehs::Serializer<ehs::UInt_64>& GetData();
|
|
|
|
|
|
|
|
void Serialize(ehs::Serializer<ehs::UInt_64>& inData) const;
|
2024-02-14 18:42:04 -08:00
|
|
|
};
|