xref: /haiku/headers/private/kernel/elf_priv.h (revision 513403d4200592b83363a078b8c789af91c626e0)
17fae0705SAxel Dörfler /*
2*a553e95dSJérôme Duval  * Copyright 2002-2018, Haiku Inc. All Rights Reserved.
3c14a34a6SAxel Dörfler  * Distributed under the terms of the MIT license.
4c14a34a6SAxel Dörfler  *
5c14a34a6SAxel Dörfler  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6c14a34a6SAxel Dörfler  * Distributed under the terms of the NewOS License.
77fae0705SAxel Dörfler  */
87fae0705SAxel Dörfler #ifndef _KERNEL_ELF_PRIV_H
97fae0705SAxel Dörfler #define _KERNEL_ELF_PRIV_H
107fae0705SAxel Dörfler 
11e44d4929SAxel Dörfler 
1275c31ae2SSimon South #include <elf_private.h>
1375c31ae2SSimon South 
1429164895SAxel Dörfler #include <image.h>
157fae0705SAxel Dörfler 
167fae0705SAxel Dörfler 
179bf61a0eSIngo Weinhold struct elf_version_info;
189bf61a0eSIngo Weinhold 
199bf61a0eSIngo Weinhold 
20337d1d1bSAxel Dörfler typedef struct elf_region {
21e44d4929SAxel Dörfler 	area_id		id;
22e1a6f46dSAxel Dörfler 	addr_t		start;
23e1a6f46dSAxel Dörfler 	addr_t		size;
247fae0705SAxel Dörfler 	long		delta;
25337d1d1bSAxel Dörfler } elf_region;
267fae0705SAxel Dörfler 
277fae0705SAxel Dörfler struct elf_image_info {
282b6b9a5aSAxel Dörfler 	struct elf_image_info* next;		// next image in the hash
297fae0705SAxel Dörfler 	char*			name;
307fae0705SAxel Dörfler 	image_id		id;
317fae0705SAxel Dörfler 	int32			ref_count;
3280f54692SAxel Dörfler 	struct vnode*	vnode;
332705fb7dSAxel Dörfler 	elf_region		text_region;
342705fb7dSAxel Dörfler 	elf_region		data_region;
35c14a34a6SAxel Dörfler 	addr_t			dynamic_section;	// pointer to the dynamic section
367fae0705SAxel Dörfler 	struct elf_linked_image* linked_images;
377fae0705SAxel Dörfler 
38c07db2ecSIngo Weinhold 	bool			symbolic;
39c07db2ecSIngo Weinhold 
403b802628SAlex Smith 	elf_ehdr*		elf_header;
417fae0705SAxel Dörfler 
427fae0705SAxel Dörfler 	// pointer to symbol participation data structures
437fae0705SAxel Dörfler 	char*			needed;
44e1a6f46dSAxel Dörfler 	uint32*			symhash;
453b802628SAlex Smith 	elf_sym*		syms;
467fae0705SAxel Dörfler 	char*			strtab;
473b802628SAlex Smith 	elf_rel*		rel;
487fae0705SAxel Dörfler 	int				rel_len;
493b802628SAlex Smith 	elf_rela*		rela;
507fae0705SAxel Dörfler 	int				rela_len;
513b802628SAlex Smith 	elf_rel*		pltrel;
527fae0705SAxel Dörfler 	int				pltrel_len;
537fae0705SAxel Dörfler 	int				pltrel_type;
54ecfed6a7SAxel Dörfler 
553b802628SAlex Smith 	elf_sym*		debug_symbols;
56ecfed6a7SAxel Dörfler 	uint32			num_debug_symbols;
57ecfed6a7SAxel Dörfler 	const char*		debug_string_table;
589bf61a0eSIngo Weinhold 
599bf61a0eSIngo Weinhold 	// versioning related structures
609bf61a0eSIngo Weinhold 	uint32			num_version_definitions;
613b802628SAlex Smith 	elf_verdef*		version_definitions;
629bf61a0eSIngo Weinhold 	uint32			num_needed_versions;
633b802628SAlex Smith 	elf_verneed*	needed_versions;
643b802628SAlex Smith 	elf_versym*		symbol_versions;
659bf61a0eSIngo Weinhold 	struct elf_version_info* versions;
669bf61a0eSIngo Weinhold 	uint32			num_versions;
677fae0705SAxel Dörfler };
687fae0705SAxel Dörfler 
697fae0705SAxel Dörfler 
707fae0705SAxel Dörfler #define STRING(image, offset) ((char*)(&(image)->strtab[(offset)]))
717fae0705SAxel Dörfler #define SYMNAME(image, sym) STRING(image, (sym)->st_name)
72f6a34444SAlex Smith #define SYMBOL(image, num) (&(image)->syms[num])
737fae0705SAxel Dörfler #define HASHTABSIZE(image) ((image)->symhash[0])
747fae0705SAxel Dörfler #define HASHBUCKETS(image) ((unsigned int*)&(image)->symhash[2])
757fae0705SAxel Dörfler #define HASHCHAINS(image) ((unsigned int*)&(image)->symhash[2+HASHTABSIZE(image)])
767fae0705SAxel Dörfler 
773b802628SAlex Smith 
78337d1d1bSAxel Dörfler #ifdef __cplusplus
793b802628SAlex Smith extern "C" {
80337d1d1bSAxel Dörfler #endif
813b802628SAlex Smith 
823b802628SAlex Smith extern status_t elf_resolve_symbol(struct elf_image_info* image,
833b802628SAlex Smith 	elf_sym* symbol, struct elf_image_info* sharedImage,
84*a553e95dSJérôme Duval 	elf_addr* _symbolAddress);
853b802628SAlex Smith 
863b802628SAlex Smith #ifdef __cplusplus
873b802628SAlex Smith }
883b802628SAlex Smith #endif
893b802628SAlex Smith 
907fae0705SAxel Dörfler 
917fae0705SAxel Dörfler #endif	/* _KERNEL_ELF_PRIV_H */
92