blob: 6c13d1848f5ae16be41748ee09b0161b33719be9 (
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
|
#ifndef PROGRAM_H
#define PROGRAM_H
#include <unistd.h>
#include <libelf.h>
#include <gelf.h>
#include <cstdint>
#include <qvector.h>
#include <qstring.h>
#include "memory.h"
namespace machine {
class ProgramLoader {
public:
ProgramLoader(const char *file);
ProgramLoader(QString file);
~ProgramLoader();
void to_memory(Memory *mem); // Writes all loaded sections to memory
std::uint32_t end(); // Return address after which there is no more code for sure
private:
int fd;
Elf *elf;
GElf_Ehdr hdr; // elf file header
size_t n_secs; // number of sections in elf program header
Elf32_Phdr *phdrs; // program section headers
QVector<size_t> map; // external index to phdrs index
};
}
#endif // PROGRAM_H
|