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 9 10 #include "runtime_loader_private.h" 11 12 13 // exported via the rld_export structure in user space program arguments 14 15 16 static image_id 17 export_load_add_on(char const *name, uint32 flags) 18 { 19 void* handle; 20 return load_library(name, flags, true, &handle); 21 } 22 23 24 static status_t 25 export_unload_add_on(image_id id) 26 { 27 return unload_library(NULL, id, true); 28 } 29 30 31 static image_id 32 export_load_library(char const *name, uint32 flags, void **_handle) 33 { 34 return load_library(name, flags, false, _handle); 35 } 36 37 38 static status_t 39 export_unload_library(void* handle) 40 { 41 return unload_library(handle, -1, false); 42 } 43 44 45 struct rld_export gRuntimeLoader = { 46 // dynamic loading support API 47 export_load_add_on, 48 export_unload_add_on, 49 export_load_library, 50 export_unload_library, 51 get_symbol, 52 get_library_symbol, 53 get_nth_symbol, 54 get_nearest_symbol_at_address, 55 test_executable, 56 get_executable_architecture, 57 get_next_image_dependency, 58 59 elf_reinit_after_fork, 60 NULL, // call_atexit_hooks_for_range 61 terminate_program, 62 63 // the following values will be set later 64 NULL, // program_args 65 NULL, // commpage_address 66 0 // ABI version 67 }; 68 69 70 void 71 rldexport_init(void) 72 { 73 gRuntimeLoader.program_args = gProgramArgs; 74 gRuntimeLoader.commpage_address = __gCommPageAddress; 75 } 76 77 78 /*! Is called for all images, and sets the minimum ABI version found to the 79 gRuntimeLoader.abi_version field. 80 */ 81 void 82 set_abi_version(int abi_version) 83 { 84 if (gRuntimeLoader.abi_version == 0 85 || gRuntimeLoader.abi_version > abi_version) { 86 gRuntimeLoader.abi_version = abi_version; 87 } 88 } 89