mips/include/melf.h

43 lines
896 B
C
Raw Permalink Normal View History

/* Copyright (c) 2024 Freya Murphy */
#ifndef __MELF_H__
#define __MELF_H__
#include <elf.h>
#include <arpa/inet.h>
2024-10-09 16:08:58 +00:00
/// mips is a big endian system
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define B32(n) (__bswap_constant_32(n))
#define B16(n) (__bswap_constant_16(n))
#else
#define B32(n) (n)
#define B16(n) (n)
#endif
static const Elf32_Ehdr MIPS_ELF_EHDR =
{
.e_ident = {
[EI_MAG0] = ELFMAG0,
[EI_MAG1] = ELFMAG1,
[EI_MAG2] = ELFMAG2,
[EI_MAG3] = ELFMAG3,
[EI_CLASS] = ELFCLASS32,
[EI_DATA] = ELFDATA2MSB,
[EI_VERSION] = EV_CURRENT,
[EI_OSABI] = ELFOSABI_NONE,
[EI_ABIVERSION] = 0x00,
[EI_PAD] = 0x00,
},
.e_type = B16(ET_REL),
.e_machine = B16(EM_MIPS),
.e_version = B32(EV_CURRENT),
.e_entry = 0x00,
2024-10-09 16:08:58 +00:00
.e_flags = 0x00,
.e_ehsize = B16(sizeof(Elf32_Ehdr)),
.e_phentsize = B16(sizeof(Elf32_Phdr)),
.e_shentsize = B16(sizeof(Elf32_Shdr)),
};
#endif /* __MELF_H__ */