2 * Copyright 2003-2011, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
5 * Copyright 2002, Manuel J. Petit. All rights reserved.
6 * Distributed under the terms of the NewOS License.
8 #ifndef RUNTIME_LOADER_PRIVATE_H
9 #define RUNTIME_LOADER_PRIVATE_H
11 #include <user_runtime.h>
12 #include <runtime_loader.h>
14 #include "tracing_config.h"
21 # define TRACE(x) dprintf x
27 #if RUNTIME_LOADER_TRACING
28 # define KTRACE(x...) ktrace_printf(x)
31 #endif // RUNTIME_LOADER_TRACING
36 dprintf("runtime_loader: " x); \
37 if (!gProgramLoaded) \
38 printf("runtime_loader: " x); \
42 struct SymbolLookupCache
;
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
;
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
);
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
,
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** _imageName
, char** _symbolName
, int32
* _type
,
72 void** _location
, bool* _exactMatch
);
73 status_t
get_symbol(image_id imageID
, char const* symbolName
, int32 symbolType
,
74 bool recursive
, image_id
* _inImage
, void** _location
);
75 status_t
get_library_symbol(void* handle
, void* caller
, const char* symbolName
,
77 status_t
get_next_image_dependency(image_id id
, uint32
* cookie
,
79 int resolve_symbol(image_t
* rootImage
, image_t
* image
, elf_sym
* sym
,
80 SymbolLookupCache
* cache
, addr_t
* sym_addr
, image_t
** symbolImage
= NULL
);
83 status_t
elf_verify_header(void* header
, size_t length
);
84 void rldelf_init(void);
85 void rldexport_init(void);
86 void set_abi_version(int abi_version
);
87 status_t
elf_reinit_after_fork(void);
89 status_t
heap_init(void);
91 // arch dependent prototypes
92 status_t
arch_relocate_image(image_t
* rootImage
, image_t
* image
,
93 SymbolLookupCache
* cache
);
97 #endif /* RUNTIME_LOADER_PRIVATE_H */