xref: /haiku/src/system/runtime_loader/images.h (revision b6455c080b61ccff5a6c3fc6d35761ed040b6fb9)
1 /*
2  * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2003-2011, Axel Dörfler, axeld@pinc-software.de.
4  * Distributed under the terms of the MIT License.
5  *
6  * Copyright 2002, Manuel J. Petit. All rights reserved.
7  * Copyright 2001, Travis Geiselbrecht. All rights reserved.
8  * Distributed under the terms of the NewOS License.
9  */
10 #ifndef IMAGES_H
11 #define IMAGES_H
12 
13 #include <runtime_loader.h>
14 
15 
16 enum {
17 	// the lower two bits are reserved for RTLD_NOW and RTLD_GLOBAL
18 
19 	RFLAG_RW					= 0x0010,
20 	RFLAG_ANON					= 0x0020,
21 
22 	RFLAG_TERMINATED			= 0x0200,
23 	RFLAG_INITIALIZED			= 0x0400,
24 	RFLAG_SYMBOLIC				= 0x0800,
25 	RFLAG_RELOCATED				= 0x1000,
26 	RFLAG_PROTECTED				= 0x2000,
27 	RFLAG_DEPENDENCIES_LOADED	= 0x4000,
28 	RFLAG_REMAPPED				= 0x8000,
29 
30 	RFLAG_VISITED				= 0x10000,
31 	RFLAG_USE_FOR_RESOLVING		= 0x20000
32 		// temporarily set in the symbol resolution code
33 };
34 
35 
36 #define IMAGE_TYPE_TO_MASK(type)	(1 << ((type) - 1))
37 #define ALL_IMAGE_TYPES				(IMAGE_TYPE_TO_MASK(B_APP_IMAGE) \
38 									| IMAGE_TYPE_TO_MASK(B_LIBRARY_IMAGE) \
39 									| IMAGE_TYPE_TO_MASK(B_ADD_ON_IMAGE) \
40 									| IMAGE_TYPE_TO_MASK(B_SYSTEM_IMAGE))
41 #define APP_OR_LIBRARY_TYPE			(IMAGE_TYPE_TO_MASK(B_APP_IMAGE) \
42 									| IMAGE_TYPE_TO_MASK(B_LIBRARY_IMAGE))
43 
44 
45 extern bool gInvalidImageIDs;
46 
47 
48 image_t*	create_image(const char* name, const char* path, int regionCount);
49 void		delete_image_struct(image_t* image);
50 void		delete_image(image_t* image);
51 void		put_image(image_t* image);
52 
53 status_t	map_image(int fd, char const* path, image_t* image, bool fixed);
54 void		unmap_image(image_t* image);
55 void		remap_images();
56 
57 void		register_image(image_t* image, int fd, const char* path);
58 status_t	update_image_ids();
59 
60 image_queue_t& get_loaded_images();
61 image_queue_t& get_disposable_images();
62 uint32		count_loaded_images();
63 void		enqueue_loaded_image(image_t* image);
64 void		dequeue_loaded_image(image_t* image);
65 void		dequeue_disposable_image(image_t* image);
66 
67 image_t*	find_loaded_image_by_name(char const* name, uint32 typeMask);
68 image_t*	find_loaded_image_by_id(image_id id, bool ignoreDisposable);
69 image_t*	find_loaded_image_by_address(addr_t address);
70 
71 void		set_image_flags_recursively(image_t* image, uint32 flags);
72 void		clear_image_flags_recursively(image_t* image, uint32 flags);
73 ssize_t		get_sorted_image_list(image_t* image, image_t*** _list,
74 				uint32 sortFlag);
75 
76 
77 #endif	// IMAGES_H
78