Use namespace.

committer: mfx <mfx> 1109750346 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2005-03-02 07:59:06 +00:00
parent 4c97b11207
commit efd30c61c3
+37 -33
View File
@@ -34,9 +34,11 @@
// Some ELF type definitinons
**************************************************************************/
namespace TT_Elf32 {
// The ELF file header. This appears at the start of every ELF file.
template <class TT16, class TT32>
struct TT_Elf32_Ehdr
template <class TT16, class TT32, class TT64>
struct Ehdr
{
unsigned char e_ident[16]; /* Magic number and other info */
TT16 e_type; /* Object file type */
@@ -58,11 +60,11 @@ struct TT_Elf32_Ehdr
EI_DATA = 5,
EI_VERSION = 6,
EI_OSABI = 7,
EI_ABIVERSION = 8
EI_ABIVERSION = 8,
};
enum { // EI_CLASS
ELFCLASS32 = 1, /* 32-bit objects */
ELFCLASS64 = 2 /* 64-bit objects */
ELFCLASS64 = 2, /* 64-bit objects */
};
enum { // EI_DATA
ELFDATA2LSB = 1, /* 2's complement, little endian */
@@ -76,22 +78,22 @@ struct TT_Elf32_Ehdr
ET_REL = 1, /* Relocatable file */
ET_EXEC = 2, /* Executable file */
ET_DYN = 3, /* Shared object file */
ET_CORE = 4 /* Core file */
ET_CORE = 4, /* Core file */
};
enum { // e_machine
EM_386 = 3,
EM_PPC = 20
EM_PPC = 20,
};
enum { // e_version
EV_CURRENT = 1
EV_CURRENT = 1,
};
}
__attribute_packed;
// Program segment header.
template <class TT16, class TT32>
struct TT_Elf32_Phdr
template <class TT16, class TT32, class TT64>
struct Phdr
{
TT32 p_type; /* Segment type */
TT32 p_offset; /* Segment file offset */
@@ -102,24 +104,24 @@ struct TT_Elf32_Phdr
TT32 p_flags; /* Segment flags */
TT32 p_align; /* Segment alignment */
// Values for p_type
enum {
enum { // p_type
PT_LOAD = 1, /* Loadable program segment */
PT_DYNAMIC = 2, /* Dynamic linking information */
PT_INTERP = 3, /* Name of program interpreter */
PT_PHDR = 6 /* Entry for header table itself */
PT_PHDR = 6, /* Entry for header table itself */
};
// Values for p_flags
enum { PF_X = (1 << 0) }; /* Segment is executable */
enum { PF_W = (1 << 1) }; /* Segment is writable */
enum { PF_R = (1 << 2) }; /* Segment is readable */
enum { // p_flags
PF_X = 1, /* Segment is executable */
PF_W = 2, /* Segment is writable */
PF_R = 4, /* Segment is readable */
};
}
__attribute_packed;
template <class TT16, class TT32>
struct TT_Elf32_Shdr
template <class TT16, class TT32, class TT64>
struct Shdr
{
TT32 sh_name; /* Section name (string tbl index) */
TT32 sh_type; /* Section type */
@@ -132,7 +134,7 @@ struct TT_Elf32_Shdr
TT32 sh_addralign; /* Section alignment */
TT32 sh_entsize; /* Entry size if section holds table */
enum { // values for sh_type
enum { // sh_type
SHT_NULL = 0, /* Section header table entry unused */
SHT_PROGBITS = 1, /* Program data */
SHT_SYMTAB = 2, /* Symbol table */
@@ -151,10 +153,10 @@ struct TT_Elf32_Shdr
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
SHT_GROUP = 17, /* Section group */
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
SHT_NUM = 19 /* Number of defined types. */
SHT_NUM = 19, /* Number of defined types. */
};
enum { // values for sh_flags
enum { // sh_flags
SHF_WRITE = (1 << 0), /* Writable */
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
SHF_EXECINSTR = (1 << 2), /* Executable */
@@ -167,35 +169,37 @@ struct TT_Elf32_Shdr
__attribute_packed;
template <class TT16, class TT32>
struct TT_Elf32_Dyn
template <class TT16, class TT32, class TT64>
struct Dyn
{
TT32 d_tag;
TT32 d_val;
enum { // tags
enum { // d_tag
DT_NULL = 0, /* End flag */
DT_NEEDED = 1, /* Name of needed library */
DT_STRTAB = 5, /* String table */
DT_STRSZ = 10 /* Sizeof string table */
DT_STRSZ = 10, /* Sizeof string table */
};
}
__attribute_packed;
} // namespace
/*************************************************************************
// now for the actual types
**************************************************************************/
typedef TT_Elf32_Ehdr<LE16,LE32> Elf_LE32_Ehdr;
typedef TT_Elf32_Phdr<LE16,LE32> Elf_LE32_Phdr;
typedef TT_Elf32_Shdr<LE16,LE32> Elf_LE32_Shdr;
typedef TT_Elf32_Dyn <LE16,LE32> Elf_LE32_Dyn;
typedef TT_Elf32::Ehdr<LE16,LE32,void> Elf_LE32_Ehdr;
typedef TT_Elf32::Phdr<LE16,LE32,void> Elf_LE32_Phdr;
typedef TT_Elf32::Shdr<LE16,LE32,void> Elf_LE32_Shdr;
typedef TT_Elf32::Dyn <LE16,LE32,void> Elf_LE32_Dyn;
typedef TT_Elf32_Ehdr<unsigned short,unsigned int> Elf32_Ehdr;
typedef TT_Elf32_Phdr<unsigned short,unsigned int> Elf32_Phdr;
typedef TT_Elf32_Shdr<unsigned short,unsigned int> Elf32_Shdr;
typedef TT_Elf32_Dyn <unsigned short,unsigned int> Elf32_Dyn;
typedef TT_Elf32::Ehdr<unsigned short,unsigned int,void> Elf32_Ehdr;
typedef TT_Elf32::Phdr<unsigned short,unsigned int,void> Elf32_Phdr;
typedef TT_Elf32::Shdr<unsigned short,unsigned int,void> Elf32_Shdr;
typedef TT_Elf32::Dyn <unsigned short,unsigned int,void> Elf32_Dyn;
#endif /* already included */