xref: /haiku/src/system/runtime_loader/runtime_loader_private.h (revision 83b1a68c52ba3e0e8796282759f694b7fdddf06d)
1 /*
2  * Copyright 2003-2011, 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  * Distributed under the terms of the NewOS License.
7  */
8 #ifndef RUNTIME_LOADER_PRIVATE_H
9 #define RUNTIME_LOADER_PRIVATE_H
10 
11 #include <user_runtime.h>
12 #include <runtime_loader.h>
13 
14 #include "tracing_config.h"
15 
16 #include "utility.h"
17 
18 
19 //#define TRACE_RLD
20 #ifdef TRACE_RLD
21 #	define TRACE(x) dprintf x
22 #else
23 #	define TRACE(x) ;
24 #endif
25 
26 
27 #if RUNTIME_LOADER_TRACING
28 #	define KTRACE(x...)	ktrace_printf(x)
29 #else
30 #	define KTRACE(x...)
31 #endif	// RUNTIME_LOADER_TRACING
32 
33 
34 #define FATAL(x...)							\
35 	do {									\
36 		dprintf("runtime_loader: " x);		\
37 		if (!gProgramLoaded)				\
38 			printf("runtime_loader: " x);	\
39 	} while (false)
40 
41 
42 struct SymbolLookupCache;
43 
44 
45 extern struct user_space_program_args* gProgramArgs;
46 extern void* __gCommPageAddress;
47 extern struct rld_export gRuntimeLoader;
48 extern char* (*gGetEnv)(const char* name);
49 extern bool gProgramLoaded;
50 extern image_t* gProgramImage;
51 
52 
53 extern "C" {
54 
55 int runtime_loader(void* arg, void* commpage);
56 int open_executable(char* name, image_type type, const char* rpath,
57 	const char* programPath, const char* requestingObjectPath,
58 	const char* abiSpecificSubDir);
59 status_t test_executable(const char* path, char* interpreter);
60 status_t get_executable_architecture(const char* path,
61 	const char** _architecture);
62 
63 void terminate_program(void);
64 image_id load_program(char const* path, void** entry);
65 image_id load_library(char const* path, uint32 flags, bool addOn,
66 	void** _handle);
67 status_t unload_library(void* handle, image_id imageID, bool addOn);
68 status_t get_nth_symbol(image_id imageID, int32 num, char* nameBuffer,
69 	int32* _nameLength, int32* _type, void** _location);
70 status_t get_nearest_symbol_at_address(void* address, image_id* _imageID,
71 	char** _imagePath, char** _symbolName, int32* _type, void** _location);
72 status_t get_symbol(image_id imageID, char const* symbolName, int32 symbolType,
73 	bool recursive, image_id* _inImage, void** _location);
74 status_t get_library_symbol(void* handle, void* caller, const char* symbolName,
75 	void** _location);
76 status_t get_next_image_dependency(image_id id, uint32* cookie,
77 	const char** _name);
78 int resolve_symbol(image_t* rootImage, image_t* image, elf_sym* sym,
79 	SymbolLookupCache* cache, addr_t* sym_addr, image_t** symbolImage = NULL);
80 
81 
82 status_t elf_verify_header(void* header, size_t length);
83 void rldelf_init(void);
84 void rldexport_init(void);
85 void set_abi_version(int abi_version);
86 status_t elf_reinit_after_fork(void);
87 
88 status_t heap_init(void);
89 
90 // arch dependent prototypes
91 status_t arch_relocate_image(image_t* rootImage, image_t* image,
92 	SymbolLookupCache* cache);
93 
94 }
95 
96 #endif	/* RUNTIME_LOADER_PRIVATE_H */
97