1/*
2 * Copyright 2005, 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_common.h>
13#include <fatelf.h>
14#include <thread.h>
15#include <image.h>
16
17
18struct kernel_args;
19
20struct elf_fat_arch_section {
21	struct elf_image_arch arch;
22	off_t offset;
23	off_t size;
24};
25
26struct elf_symbol_info {
27	addr_t	address;
28	size_t	size;
29};
30
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36status_t elf_find_best_fat_section(int fd,
37		struct elf_fat_arch_section *found_section);
38
39status_t elf_find_best_compatible_fat_section(int fd,
40	elf_image_arch *image_arch, struct elf_fat_arch_section *found_section);
41
42status_t elf_load_user_image(const char *path, Team *team, int flags,
43	addr_t *entry, struct elf_image_arch *min_arch_required);
44
45// these two might get public one day:
46image_id load_kernel_add_on(const char *path);
47status_t unload_kernel_add_on(image_id id);
48
49status_t elf_debug_lookup_symbol_address(addr_t address, addr_t *_baseAddress,
50			const char **_symbolName, const char **_imageName,
51			bool *_exactMatch);
52status_t elf_debug_lookup_user_symbol_address(Team* team, addr_t address,
53			addr_t *_baseAddress, const char **_symbolName,
54			const char **_imageName, bool *_exactMatch);
55addr_t elf_debug_lookup_symbol(const char* searchName);
56status_t elf_lookup_kernel_symbol(const char* name, elf_symbol_info* info);
57struct elf_image_info* elf_get_kernel_image();
58status_t elf_get_image_info_for_address(addr_t address, image_info* info);
59image_id elf_create_memory_image(const char* imageName, addr_t text,
60			size_t textSize, addr_t data, size_t dataSize);
61status_t elf_add_memory_image_symbol(image_id id, const char* name,
62			addr_t address, size_t size, int32 type);
63status_t elf_init(struct kernel_args *args);
64
65status_t _user_read_kernel_image_symbols(image_id id, elf_sym* symbolTable,
66			int32* _symbolCount, char* stringTable, size_t* _stringTableSize,
67			addr_t* _imageDelta);
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif	/* _KERNEL_ELF_H */
74