xref: /haiku/headers/private/runtime_loader/runtime_loader.h (revision 3e216965baa8d58a67bf7372e2bfa13d999f5a9d)
1 /*
2  * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de.
3  * Distributed under the terms of the MIT License.
4  *
5  * Copyright 2002, Manuel J. Petit. All rights reserved.
6  * Copyright 2001, Travis Geiselbrecht. All rights reserved.
7  * Distributed under the terms of the NewOS License.
8  */
9 
10 #ifndef _RUNTIME_LOADER_H
11 #define _RUNTIME_LOADER_H
12 
13 #include <image.h>
14 #include <OS.h>
15 
16 #include <elf32.h>
17 
18 typedef struct elf_region_t {
19 	area_id		id;
20 	addr_t		start;
21 	addr_t		size;
22 	addr_t		vmstart;
23 	addr_t		vmsize;
24 	addr_t		fdstart;
25 	addr_t		fdsize;
26 	long		delta;
27 	uint32		flags;
28 } elf_region_t;
29 
30 typedef struct image_t {
31 	// image identification
32 	char				path[B_PATH_NAME_LENGTH];
33 	char				name[B_OS_NAME_LENGTH];
34 	image_id			id;
35 	image_type			type;
36 
37 	struct image_t		*next;
38 	struct image_t		*prev;
39 	int32				ref_count;
40 	uint32				flags;
41 
42 	addr_t 				entry_point;
43 	addr_t				init_routine;
44 	addr_t				term_routine;
45 	addr_t 				dynamic_ptr; 	// pointer to the dynamic section
46 
47 	// pointer to symbol participation data structures
48 	uint32				*symhash;
49 	struct Elf32_Sym	*syms;
50 	char				*strtab;
51 	struct Elf32_Rel	*rel;
52 	int					rel_len;
53 	struct Elf32_Rela	*rela;
54 	int					rela_len;
55 	struct Elf32_Rel	*pltrel;
56 	int					pltrel_len;
57 
58 	uint32				num_needed;
59 	struct image_t		**needed;
60 
61 	// describes the text and data regions
62 	uint32				num_regions;
63 	elf_region_t		regions[1];
64 } image_t;
65 
66 typedef struct image_queue_t {
67 	image_t *head;
68 	image_t *tail;
69 } image_queue_t;
70 
71 #define STRING(image, offset) ((char *)(&(image)->strtab[(offset)]))
72 #define SYMNAME(image, sym) STRING(image, (sym)->st_name)
73 #define SYMBOL(image, num) ((struct Elf32_Sym *)&(image)->syms[num])
74 #define HASHTABSIZE(image) ((image)->symhash[0])
75 #define HASHBUCKETS(image) ((unsigned int *)&(image)->symhash[2])
76 #define HASHCHAINS(image) ((unsigned int *)&(image)->symhash[2+HASHTABSIZE(image)])
77 
78 
79 // The name of the area the runtime loader creates for debugging purposes.
80 #define RUNTIME_LOADER_DEBUG_AREA_NAME	"_rld_debug_"
81 
82 // The contents of the runtime loader debug area.
83 typedef struct runtime_loader_debug_area {
84 	image_queue_t	*loaded_images;
85 } runtime_loader_debug_area;
86 
87 #endif	// _RUNTIME_LOADER_H
88