152a38012Sejakowatz/*
2a553e95dSJérôme Duval * Copyright 2005-2018 Haiku Inc. All Rights Reserved.
3dca26362SAxel Dörfler * Distributed under the terms of the MIT license.
4dd1c278dSIngo Weinhold *
5dca26362SAxel Dörfler * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6dca26362SAxel Dörfler * Distributed under the terms of the NewOS License.
7dca26362SAxel Dörfler */
852a38012Sejakowatz#ifndef _KERNEL_ELF_H
952a38012Sejakowatz#define _KERNEL_ELF_H
1052a38012Sejakowatz
1150ba16fcSAxel Dörfler
1275c31ae2SSimon South#include <elf_private.h>
1352a38012Sejakowatz#include <thread.h>
149f956562SAxel Dörfler#include <image.h>
1552a38012Sejakowatz
16fec47a57SIngo Weinhold
17dca26362SAxel Dörflerstruct kernel_args;
18dca26362SAxel Dörfler
1950ba16fcSAxel Dörfler
2024df6592SIngo Weinholdstruct elf_symbol_info {
2124df6592SIngo Weinhold	addr_t	address;
2224df6592SIngo Weinhold	size_t	size;
2324df6592SIngo Weinhold};
2424df6592SIngo Weinhold
2524df6592SIngo Weinhold
2650ba16fcSAxel Dörfler#ifdef __cplusplus
2750ba16fcSAxel Dörflerextern "C" {
2850ba16fcSAxel Dörfler#endif
2950ba16fcSAxel Dörfler
30a553e95dSJérôme Duvalstatus_t elf_load_user_image(const char *path, Team *team, uint32 flags,
314535495dSIngo Weinhold	addr_t *_entry);
32a553e95dSJérôme Duval#ifdef _COMPAT_MODE
33a553e95dSJérôme Duval#define	ELF_LOAD_USER_IMAGE_TEST_EXECUTABLE		0x1
34a553e95dSJérôme Duvalstatus_t elf32_load_user_image(const char *path, Team *team, uint32 flags,
35a553e95dSJérôme Duval	addr_t *_entry);
36a553e95dSJérôme Duval#endif
37d81a053bSAxel Dörfler
38d81a053bSAxel Dörfler// these two might get public one day:
39d81a053bSAxel Dörflerimage_id load_kernel_add_on(const char *path);
40d81a053bSAxel Dörflerstatus_t unload_kernel_add_on(image_id id);
41d81a053bSAxel Dörfler
425793da1eSAxel Dörflerstatus_t elf_debug_lookup_symbol_address(addr_t address, addr_t *_baseAddress,
432477bce5SIngo Weinhold			const char **_symbolName, const char **_imageName,
442477bce5SIngo Weinhold			bool *_exactMatch);
454535495dSIngo Weinholdstatus_t elf_debug_lookup_user_symbol_address(Team* team, addr_t address,
462477bce5SIngo Weinhold			addr_t *_baseAddress, const char **_symbolName,
472477bce5SIngo Weinhold			const char **_imageName, bool *_exactMatch);
48e0aad96fSAxel Dörfleraddr_t elf_debug_lookup_symbol(const char* searchName);
4924df6592SIngo Weinholdstatus_t elf_lookup_kernel_symbol(const char* name, elf_symbol_info* info);
50b36c8ba2SIngo Weinholdstruct elf_image_info* elf_get_kernel_image();
51dd1c278dSIngo Weinholdstatus_t elf_get_image_info_for_address(addr_t address, image_info* info);
52fec47a57SIngo Weinholdimage_id elf_create_memory_image(const char* imageName, addr_t text,
53fec47a57SIngo Weinhold			size_t textSize, addr_t data, size_t dataSize);
54fec47a57SIngo Weinholdstatus_t elf_add_memory_image_symbol(image_id id, const char* name,
55fec47a57SIngo Weinhold			addr_t address, size_t size, int32 type);
5690f57186SIngo Weinholdstatus_t elf_read_kernel_image_symbols(image_id id, elf_sym* symbolTable,
5790f57186SIngo Weinhold			int32* _symbolCount, char* stringTable, size_t* _stringTableSize,
5890f57186SIngo Weinhold			addr_t* _imageDelta, bool kernel);
59dca26362SAxel Dörflerstatus_t elf_init(struct kernel_args *args);
6052a38012Sejakowatz
618a190335SAlex Smithstatus_t _user_read_kernel_image_symbols(image_id id, elf_sym* symbolTable,
628a190335SAlex Smith			int32* _symbolCount, char* stringTable, size_t* _stringTableSize,
638a190335SAlex Smith			addr_t* _imageDelta);
648839d592SIngo Weinhold
6550ba16fcSAxel Dörfler#ifdef __cplusplus
6650ba16fcSAxel Dörfler}
6750ba16fcSAxel Dörfler#endif
6850ba16fcSAxel Dörfler
695ca8da7aSAxel Dörfler#endif	/* _KERNEL_ELF_H */
70