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