xref: /haiku/headers/private/kernel/elf_priv.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
1 /*
2  * Copyright 2002-2006, 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_PRIV_H
9 #define _KERNEL_ELF_PRIV_H
10 
11 
12 #include <elf32.h>
13 #include <image.h>
14 
15 
16 typedef struct elf_region {
17 	area_id		id;
18 	addr_t		start;
19 	addr_t		size;
20 	long		delta;
21 } elf_region;
22 
23 struct elf_image_info {
24 	struct elf_image_info *next;	// next image in the hash
25 	char		*name;
26 	image_id	id;
27 	int32		ref_count;
28 	void		*vnode;
29 	elf_region	text_region;
30 	elf_region	data_region;
31 	addr_t		dynamic_section;		// pointer to the dynamic section
32 	struct elf_linked_image *linked_images;
33 
34 	struct Elf32_Ehdr *elf_header;
35 
36 	// pointer to symbol participation data structures
37 	char		*needed;
38 	uint32		*symhash;
39 	struct Elf32_Sym *syms;
40 	char		*strtab;
41 	struct Elf32_Rel *rel;
42 	int			rel_len;
43 	struct Elf32_Rela *rela;
44 	int			rela_len;
45 	struct Elf32_Rel *pltrel;
46 	int			pltrel_len;
47 	int			pltrel_type;
48 
49 	struct Elf32_Sym *debug_symbols;
50 	uint32		num_debug_symbols;
51 	const char	*debug_string_table;
52 };
53 
54 
55 #define STRING(image, offset) ((char *)(&(image)->strtab[(offset)]))
56 #define SYMNAME(image, sym) STRING(image, (sym)->st_name)
57 #define SYMBOL(image, num) ((struct Elf32_Sym *)&(image)->syms[num])
58 #define HASHTABSIZE(image) ((image)->symhash[0])
59 #define HASHBUCKETS(image) ((unsigned int *)&(image)->symhash[2])
60 #define HASHCHAINS(image) ((unsigned int *)&(image)->symhash[2+HASHTABSIZE(image)])
61 
62 extern
63 #ifdef __cplusplus
64 "C"
65 #endif
66 status_t elf_resolve_symbol(struct elf_image_info *image, struct Elf32_Sym *sym,
67 			struct elf_image_info *shared_image, const char *sym_prepend, addr_t *sym_addr);
68 
69 #endif	/* _KERNEL_ELF_PRIV_H */
70