Files
Project_CTR/makerom/elf.h
T
2014-08-28 22:35:20 +10:00

82 lines
1.3 KiB
C

#pragma once
typedef enum
{
NOT_ELF_FILE = -10,
NOT_ARM_ELF = -11,
NON_EXECUTABLE_ELF = -12,
ELF_SECTION_NOT_FOUND = -13,
NOT_FIND_CODE_SECTIONS = -14,
ELF_SEGMENT_SECTION_SIZE_MISMATCH = -15,
ELF_SEGMENTS_NOT_CONTINUOUS = -16,
ELF_SEGMENTS_NOT_FOUND = -17,
} elf_errors;
typedef struct
{
char *name;
u64 type;
u64 flags;
u8 *ptr;
u64 offsetInFile;
u64 size;
u64 address;
u64 alignment;
} elf_section_entry;
typedef struct
{
u64 type;
u64 flags;
u8 *ptr;
u64 offsetInFile;
u64 sizeInFile;
u64 virtualAddress;
u64 physicalAddress;
u64 sizeInMemory;
u64 alignment;
} elf_program_entry;
typedef struct
{
char *name;
u64 vAddr;
elf_program_entry *header;
u32 sectionNum;
elf_section_entry *sections;
} elf_segment;
typedef struct
{
u32 address;
u32 size;
u32 maxPageNum;
u8 *data;
} code_segment;
typedef struct
{
u32 pageSize;
bool IsLittleEndian;
bool Is64bit;
u64 programTableOffset;
u16 programTableEntrySize;
u16 programTableEntryCount;
u64 sectionTableOffset;
u16 sectionTableEntrySize;
u16 sectionTableEntryCount;
u16 sectionHeaderNameEntryIndex;
elf_section_entry *sections;
elf_program_entry *programHeaders;
u16 activeSegments;
elf_segment *segments;
} elf_context;
int BuildExeFsCode(ncch_settings *ncchset);