include/mgba-util/elf-read.h (view raw)
1/* Copyright (c) 2013-2017 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef ELF_READ_H
7#define ELF_READ_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#ifdef USE_ELF
14
15#include <libelf.h>
16
17#if USE_ELF_REPL
18#include <elf_repl.h>
19#else
20#include <elf.h>
21#endif
22
23#include <mgba-util/vector.h>
24
25struct ELF;
26struct VFile;
27
28DECLARE_VECTOR(ELFProgramHeaders, Elf32_Phdr);
29DECLARE_VECTOR(ELFSectionHeaders, Elf32_Shdr);
30
31struct ELF* ELFOpen(struct VFile*);
32void ELFClose(struct ELF*);
33
34void* ELFBytes(struct ELF*, size_t* size);
35
36uint16_t ELFMachine(struct ELF*);
37uint32_t ELFEntry(struct ELF*);
38
39void ELFGetProgramHeaders(struct ELF*, struct ELFProgramHeaders*);
40
41size_t ELFFindSection(struct ELF*, const char* name);
42void ELFGetSectionHeaders(struct ELF*, struct ELFSectionHeaders*);
43Elf32_Shdr* ELFGetSectionHeader(struct ELF*, size_t index);
44
45const char* ELFGetString(struct ELF*, size_t section, size_t string);
46
47#endif
48
49CXX_GUARD_END
50
51#endif