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#if defined(_COMPAT_MODE) && !defined(__x86_64__) 34 #if __GNUC__ == 2 35 #define RLD_PREFIX "runtime_loader_x86_gcc2: " 36 #else 37 #define RLD_PREFIX "runtime_loader_x86: " 38 #endif 39#endif 40#ifndef RLD_PREFIX 41#define RLD_PREFIX "runtime_loader: " 42#endif 43#define FATAL(x...) \ 44 do { \ 45 dprintf(RLD_PREFIX x); \ 46 if (!gProgramLoaded) \ 47 printf(RLD_PREFIX x); \ 48 } while (false) 49 50 51struct SymbolLookupCache; 52 53 54extern struct user_space_program_args* gProgramArgs; 55extern void* __gCommPageAddress; 56extern struct rld_export gRuntimeLoader; 57extern char* (*gGetEnv)(const char* name); 58extern bool gProgramLoaded; 59extern image_t* gProgramImage; 60 61 62extern "C" { 63 64int runtime_loader(void* arg, void* commpage); 65int open_executable(char* name, image_type type, const char* rpath, 66 const char* runpath, const char* programPath, const char* requestingObjectPath, 67 const char* abiSpecificSubDir); 68status_t test_executable(const char* path, char* interpreter); 69status_t get_executable_architecture(const char* path, 70 const char** _architecture); 71 72void terminate_program(void); 73image_id load_program(char const* path, void** entry); 74image_id load_library(char const* path, uint32 flags, bool addOn, 75 void* caller, void** _handle); 76status_t unload_library(void* handle, image_id imageID, bool addOn); 77status_t get_nth_symbol(image_id imageID, int32 num, char* nameBuffer, 78 int32* _nameLength, int32* _type, void** _location); 79status_t get_nearest_symbol_at_address(void* address, image_id* _imageID, 80 char** _imagePath, char** _imageName, char** _symbolName, int32* _type, 81 void** _location, bool* _exactMatch); 82status_t get_symbol(image_id imageID, char const* symbolName, int32 symbolType, 83 bool recursive, image_id* _inImage, void** _location); 84status_t get_library_symbol(void* handle, void* caller, const char* symbolName, 85 void** _location); 86status_t get_next_image_dependency(image_id id, uint32* cookie, 87 const char** _name); 88int resolve_symbol(image_t* rootImage, image_t* image, elf_sym* sym, 89 SymbolLookupCache* cache, addr_t* sym_addr, image_t** symbolImage = NULL); 90 91 92status_t elf_verify_header(void* header, size_t length); 93#ifdef _COMPAT_MODE 94#ifdef __x86_64__ 95status_t elf32_verify_header(void *header, size_t length); 96#else 97status_t elf64_verify_header(void *header, size_t length); 98#endif // __x86_64__ 99#endif // _COMPAT_MODE 100void rldelf_init(void); 101void rldexport_init(void); 102void set_abi_api_version(int abi_version, int api_version); 103status_t elf_reinit_after_fork(); 104 105status_t heap_init(); 106status_t heap_reinit_after_fork(); 107 108// arch dependent prototypes 109status_t arch_relocate_image(image_t* rootImage, image_t* image, 110 SymbolLookupCache* cache); 111 112} 113 114#endif /* RUNTIME_LOADER_PRIVATE_H */ 115