xref: /haiku/src/system/runtime_loader/elf_symbol_lookup.h (revision a1163de83ea633463a79de234b8742ee106531b2)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef ELF_SYMBOL_LOOKUP_H
6 #define ELF_SYMBOL_LOOKUP_H
7 
8 #include <runtime_loader.h>
9 
10 
11 // values for SymbolLookupInfo::flags
12 #define LOOKUP_FLAG_DEFAULT_VERSION	0x01
13 
14 
15 uint32 elf_hash(const char* name);
16 
17 
18 struct SymbolLookupInfo {
19 	const char*				name;
20 	int32					type;
21 	uint32					hash;
22 	uint32					flags;
23 	const elf_version_info*	version;
24 
25 	SymbolLookupInfo(const char* name, int32 type, uint32 hash,
26 		const elf_version_info* version = NULL, uint32 flags = 0)
27 		:
28 		name(name),
29 		type(type),
30 		hash(hash),
31 		flags(flags),
32 		version(version)
33 	{
34 	}
35 
36 	SymbolLookupInfo(const char* name, int32 type,
37 		const elf_version_info* version = NULL, uint32 flags = 0)
38 		:
39 		name(name),
40 		type(type),
41 		hash(elf_hash(name)),
42 		flags(flags),
43 		version(version)
44 	{
45 	}
46 };
47 
48 
49 void		patch_defined_symbol(image_t* image, const char* name,
50 				void** symbol, int32* type);
51 void		patch_undefined_symbol(image_t* rootImage, image_t* image,
52 				const char* name, image_t** foundInImage, void** symbol,
53 				int32* type);
54 
55 Elf32_Sym*	find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo);
56 status_t	find_symbol(image_t* image, const SymbolLookupInfo& lookupInfo,
57 				void** _location);
58 status_t	find_symbol_breadth_first(image_t* image,
59 				const SymbolLookupInfo& lookupInfo, image_t** _foundInImage,
60 				void** _location);
61 Elf32_Sym*	find_undefined_symbol_beos(image_t* rootImage, image_t* image,
62 				const SymbolLookupInfo& lookupInfo, image_t** foundInImage);
63 Elf32_Sym*	find_undefined_symbol_global(image_t* rootImage, image_t* image,
64 				const SymbolLookupInfo& lookupInfo, image_t** foundInImage);
65 Elf32_Sym*	find_undefined_symbol_add_on(image_t* rootImage, image_t* image,
66 				const SymbolLookupInfo& lookupInfo, image_t** foundInImage);
67 
68 
69 #endif	// ELF_SYMBOL_LOOKUP_H
70