-
Notifications
You must be signed in to change notification settings - Fork 50
/
Linker.h
71 lines (58 loc) · 1.21 KB
/
Linker.h
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* naken_asm assembler.
* Author: Michael Kohn
* Email: [email protected]
* Web: https://www.mikekohn.net/
* License: GPLv3
*
* Copyright 2010-2023 by Michael Kohn
*
*/
#ifndef NAKEN_ASM_LINKER_H
#define NAKEN_ASM_LINKER_H
#include <stdint.h>
enum
{
IMPORT_TYPE_AR,
IMPORT_TYPE_OBJ,
};
struct Imports
{
Imports *next;
int type;
int size;
uint8_t code[];
};
class Linker
{
public:
Linker();
~Linker();
int get_symbol_count();
int add_file(const char *filename);
int search_code_from_symbol(const char *symbol);
uint8_t *get_code_from_symbol(
Imports **imports,
const char *symbol,
uint32_t *function_offset,
uint32_t *function_size,
uint8_t **obj_file,
uint32_t *obj_size);
const char *find_name_from_offset(uint32_t offset);
const char *get_symbol_at_index(int index);
void print_symbol_list();
private:
int verify_import(Imports *imports);
Imports *get_from_symbol_list(const char *name);
void add_to_symbol_list(Imports *imports, const char *name);
Imports *imports;
uint8_t *symbol_list_buffer;
uint32_t symbol_list_buffer_size;
uint32_t symbol_list_buffer_end;
};
struct SymbolList
{
Imports *imports;
char name[];
};
#endif