vfs: check userland buffers before reading them.
[haiku.git] / src / system / runtime_loader / export.cpp
bloba480210cbd401ad47ab15123712de14bb68487cd
1 /*
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.
7 */
10 #include "runtime_loader_private.h"
11 #include "elf_tls.h"
14 // exported via the rld_export structure in user space program arguments
17 static image_id
18 export_load_add_on(char const *name, uint32 flags)
20 void* handle;
21 return load_library(name, flags, true, &handle);
25 static status_t
26 export_unload_add_on(image_id id)
28 return unload_library(NULL, id, true);
32 static image_id
33 export_load_library(char const *name, uint32 flags, void **_handle)
35 return load_library(name, flags, false, _handle);
39 static status_t
40 export_unload_library(void* handle)
42 return unload_library(handle, -1, false);
46 struct rld_export gRuntimeLoader = {
47 // dynamic loading support API
48 export_load_add_on,
49 export_unload_add_on,
50 export_load_library,
51 export_unload_library,
52 get_symbol,
53 get_library_symbol,
54 get_nth_symbol,
55 get_nearest_symbol_at_address,
56 test_executable,
57 get_executable_architecture,
58 get_next_image_dependency,
59 get_tls_address,
60 destroy_thread_tls,
62 elf_reinit_after_fork,
63 NULL, // call_atexit_hooks_for_range
64 terminate_program,
66 // the following values will be set later
67 NULL, // program_args
68 NULL, // commpage_address
69 0 // ABI version
72 rld_export* __gRuntimeLoader = &gRuntimeLoader;
75 void
76 rldexport_init(void)
78 gRuntimeLoader.program_args = gProgramArgs;
79 gRuntimeLoader.commpage_address = __gCommPageAddress;
83 /*! Is called for all images, and sets the minimum ABI version found to the
84 gRuntimeLoader.abi_version field.
86 void
87 set_abi_version(int abi_version)
89 if (gRuntimeLoader.abi_version == 0
90 || gRuntimeLoader.abi_version > abi_version) {
91 gRuntimeLoader.abi_version = abi_version;