xref: /haiku/headers/private/kernel/elf.h (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 /*
2  * Copyright 2005-2018 Haiku Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT license.
4  *
5  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6  * Distributed under the terms of the NewOS License.
7  */
8 #ifndef _KERNEL_ELF_H
9 #define _KERNEL_ELF_H
10 
11 
12 #include <elf_private.h>
13 #include <thread.h>
14 #include <image.h>
15 
16 
17 struct kernel_args;
18 
19 
20 struct elf_symbol_info {
21 	addr_t	address;
22 	size_t	size;
23 };
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 status_t elf_load_user_image(const char *path, Team *team, uint32 flags,
31 	addr_t *_entry);
32 #ifdef _COMPAT_MODE
33 #define	ELF_LOAD_USER_IMAGE_TEST_EXECUTABLE		0x1
34 status_t elf32_load_user_image(const char *path, Team *team, uint32 flags,
35 	addr_t *_entry);
36 #endif
37 
38 // these two might get public one day:
39 image_id load_kernel_add_on(const char *path);
40 status_t unload_kernel_add_on(image_id id);
41 
42 status_t elf_debug_lookup_symbol_address(addr_t address, addr_t *_baseAddress,
43 			const char **_symbolName, const char **_imageName,
44 			bool *_exactMatch);
45 status_t elf_debug_lookup_user_symbol_address(Team* team, addr_t address,
46 			addr_t *_baseAddress, const char **_symbolName,
47 			const char **_imageName, bool *_exactMatch);
48 addr_t elf_debug_lookup_symbol(const char* searchName);
49 status_t elf_lookup_kernel_symbol(const char* name, elf_symbol_info* info);
50 struct elf_image_info* elf_get_kernel_image();
51 status_t elf_get_image_info_for_address(addr_t address, image_info* info);
52 image_id elf_create_memory_image(const char* imageName, addr_t text,
53 			size_t textSize, addr_t data, size_t dataSize);
54 status_t elf_add_memory_image_symbol(image_id id, const char* name,
55 			addr_t address, size_t size, int32 type);
56 status_t elf_read_kernel_image_symbols(image_id id, elf_sym* symbolTable,
57 			int32* _symbolCount, char* stringTable, size_t* _stringTableSize,
58 			addr_t* _imageDelta, bool kernel);
59 status_t elf_init(struct kernel_args *args);
60 
61 status_t _user_read_kernel_image_symbols(image_id id, elf_sym* symbolTable,
62 			int32* _symbolCount, char* stringTable, size_t* _stringTableSize,
63 			addr_t* _imageDelta);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif	/* _KERNEL_ELF_H */
70