summaryrefslogtreecommitdiff
path: root/include/melf.h
blob: 095518b47b1087ce8578343b429b90a39f2c6341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Copyright (c) 2024 Freya Murphy */

#ifndef __MELF_H__
#define __MELF_H__

#include <elf.h>
#include <arpa/inet.h>

#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,
	.e_flags = B32(EF_MIPS_ARCH_32R6),
	.e_ehsize = B16(sizeof(Elf32_Ehdr)),
	.e_phentsize = B16(sizeof(Elf32_Phdr)),
	.e_shentsize = B16(sizeof(Elf32_Shdr)),
};

#endif /* __MELF_H__ */