Root/
Source at commit 338 created 13 years 8 months ago. By meklort, Modules can not depend on each other. Modules can be linked using the -weak-libary cmmand in ld. Untested. | |
---|---|
1 | /*␊ |
2 | * Module Loading functionality␊ |
3 | * Copyright 2009 Evan Lojewski. All rights reserved.␊ |
4 | *␊ |
5 | */␊ |
6 | ␊ |
7 | #include <mach-o/loader.h>␊ |
8 | #include <mach-o/nlist.h>␊ |
9 | ␊ |
10 | ␊ |
11 | typedef struct symbolList_t{␊ |
12 | ␉char* symbol;␊ |
13 | ␉unsigned int addr;␊ |
14 | ␉struct symbolList_t* next;␊ |
15 | } symbolList_t;␊ |
16 | ␊ |
17 | typedef struct moduleList_t{␊ |
18 | ␉char* module;␊ |
19 | ␉unsigned int version;␊ |
20 | ␉unsigned int compat;␊ |
21 | ␉struct moduleList_t* next;␊ |
22 | } moduleList_t;␊ |
23 | ␊ |
24 | #ifndef __BOOT_MODULES_H␊ |
25 | #define __BOOT_MODULES_H␊ |
26 | ␊ |
27 | #define SYMBOLS_MODULE "Symbols"␊ |
28 | ␊ |
29 | #define SYMBOL_DYLD_STUB_BINDER␉"dyld_stub_binder"␊ |
30 | #define STUB_ENTRY_SIZE␉6␊ |
31 | ␊ |
32 | #define SECT_NON_LAZY_SYMBOL_PTR␉"__nl_symbol_ptr"␊ |
33 | #define SECT_SYMBOL_STUBS␉␉␉"__symbol_stub"␊ |
34 | ␊ |
35 | #define SUCCESS␉1␊ |
36 | #define␉ERROR␉0␊ |
37 | ␊ |
38 | int load_module(const char* module);␊ |
39 | int is_module_laoded(const char* name);␊ |
40 | void module_loaded(char* name, UInt32 version, UInt32 compat);␊ |
41 | ␊ |
42 | void add_symbol(char* symbol, void* addr);␊ |
43 | void* parse_mach(void* binary);␊ |
44 | ␊ |
45 | unsigned int handle_symtable(UInt32 base, struct symtab_command* symtabCommand, char* symbolStub, char* nonlazy);␊ |
46 | ␊ |
47 | unsigned int lookup_external_all(const char* name);␊ |
48 | ␊ |
49 | #endif /* __BOOT_MODULES_H */ |