elf_priv.h revision 44f24718
1/*
2 * Copyright 2002-2018, 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 <elf_private.h>
13
14#include <image.h>
15
16
17struct elf_version_info;
18
19
20typedef struct elf_region {
21	area_id		id;
22	addr_t		start;
23	addr_t		size;
24	long		delta;
25} elf_region;
26
27struct elf_image_info {
28	struct elf_image_info* next;		// next image in the hash
29	char*			name;
30	image_id		id;
31	int32			ref_count;
32	struct vnode*	vnode;
33	elf_region		text_region;
34	elf_region		data_region;
35	addr_t			dynamic_section;	// pointer to the dynamic section
36	struct elf_linked_image* linked_images;
37
38	bool			symbolic;
39
40	elf_ehdr*		elf_header;
41
42	// pointer to symbol participation data structures
43	char*			needed;
44	uint32*			symhash;
45	elf_sym*		syms;
46	char*			strtab;
47	elf_rel*		rel;
48	int				rel_len;
49	elf_rela*		rela;
50	int				rela_len;
51	elf_rel*		pltrel;
52	int				pltrel_len;
53	int				pltrel_type;
54
55	elf_sym*		debug_symbols;
56	uint32			num_debug_symbols;
57	const char*		debug_string_table;
58
59	// versioning related structures
60	uint32			num_version_definitions;
61	elf_verdef*		version_definitions;
62	uint32			num_needed_versions;
63	elf_verneed*	needed_versions;
64	elf_versym*		symbol_versions;
65	struct elf_version_info* versions;
66	uint32			num_versions;
67};
68
69
70#define STRING(image, offset) ((char*)(&(image)->strtab[(offset)]))
71#define SYMNAME(image, sym) STRING(image, (sym)->st_name)
72#define SYMBOL(image, num) (&(image)->syms[num])
73#define HASHTABSIZE(image) ((image)->symhash[0])
74#define HASHBUCKETS(image) ((unsigned int*)&(image)->symhash[2])
75#define HASHCHAINS(image) ((unsigned int*)&(image)->symhash[2+HASHTABSIZE(image)])
76
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82extern status_t elf_resolve_symbol(struct elf_image_info* image,
83	elf_sym* symbol, struct elf_image_info* sharedImage,
84	elf_addr* _symbolAddress);
85#ifdef _COMPAT_MODE
86extern status_t elf32_resolve_symbol(struct elf_image_info* image,
87	elf_sym* symbol, struct elf_image_info* sharedImage,
88	elf_addr* _symbolAddress);
89#endif
90
91#ifdef __cplusplus
92}
93#endif
94
95
96#endif	/* _KERNEL_ELF_PRIV_H */
97