1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 2014 The Android Open Source Project. 10 Copyright (C) 2018-2019 Aurora Free Open Source Software. 11 12 This file is part of the Aurora Free Open Source Software. This 13 organization promote free and open source software that you can 14 redistribute and/or modify under the terms of the GNU Lesser General 15 Public License Version 3 as published by the Free Software Foundation or 16 (at your option) any later version approved by the Aurora Free Open Source 17 Software Organization. The license is available in the package root path 18 as 'LICENSE' file. Please review the following information to ensure the 19 GNU Lesser General Public License version 3 requirements will be met: 20 https://www.gnu.org/licenses/lgpl.html . 21 22 Alternatively, this file may be used under the terms of the GNU General 23 Public License version 3 or later as published by the Free Software 24 Foundation. Please review the following information to ensure the GNU 25 General Public License requirements will be met: 26 https://www.gnu.org/licenses/gpl-3.0.html. 27 28 NOTE: All products, services or anything associated to trademarks and 29 service marks used or referenced on this file are the property of their 30 respective companies/owners or its subsidiaries. Other names and brands 31 may be claimed as the property of others. 32 33 For more info about intellectual property visit: aurorafoss.org or 34 directly send an email to: contact (at) aurorafoss.org . 35 36 This file has bindings for an existing code, part of The Android Open Source 37 Project implementation. Check it out at android.googlesource.com . 38 */ 39 40 module aurorafw.android.platform.dlext; 41 42 version (Android): 43 extern (C): 44 @system: 45 nothrow: 46 @nogc: 47 48 /* for off64_t */ 49 50 /** 51 * @addtogroup libdl Dynamic Linker 52 * @{ 53 */ 54 55 /** 56 * \file 57 * Advanced dynamic library opening support. Most users will want to use 58 * the standard [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html) 59 * functionality in `<dlfcn.h>` instead. 60 */ 61 62 /** Bitfield definitions for `android_dlextinfo::flags`. */ 63 enum 64 { 65 /** 66 * When set, the `reserved_addr` and `reserved_size` fields must point to an 67 * already-reserved region of address space which will be used to load the 68 * library if it fits. 69 * 70 * If the reserved region is not large enough, loading will fail. 71 */ 72 ANDROID_DLEXT_RESERVED_ADDRESS = 1, 73 74 /** 75 * Like `ANDROID_DLEXT_RESERVED_ADDRESS`, but if the reserved region is not large enough, 76 * the linker will choose an available address instead. 77 */ 78 ANDROID_DLEXT_RESERVED_ADDRESS_HINT = 2, 79 80 /** 81 * When set, write the GNU RELRO section of the mapped library to `relro_fd` 82 * after relocation has been performed, to allow it to be reused by another 83 * process loading the same library at the same address. This implies 84 * `ANDROID_DLEXT_USE_RELRO`. 85 * 86 * This is mainly useful for the system WebView implementation. 87 */ 88 ANDROID_DLEXT_WRITE_RELRO = 4, 89 90 /** 91 * When set, compare the GNU RELRO section of the mapped library to `relro_fd` 92 * after relocation has been performed, and replace any relocated pages that 93 * are identical with a version mapped from the file. 94 * 95 * This is mainly useful for the system WebView implementation. 96 */ 97 ANDROID_DLEXT_USE_RELRO = 8, 98 99 /** 100 * Use `library_fd` instead of opening the file by name. 101 * The filename parameter is still used to identify the library. 102 */ 103 ANDROID_DLEXT_USE_LIBRARY_FD = 16, 104 105 /** 106 * If opening a library using `library_fd` read it starting at `library_fd_offset`. 107 * This is mainly useful for loading a library stored within another file (such as uncompressed 108 * inside a ZIP archive). 109 * This flag is only valid when `ANDROID_DLEXT_USE_LIBRARY_FD` is set. 110 */ 111 ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 32, 112 113 /** 114 * When set, do not use `stat(2)` to check if the library has already been loaded. 115 * 116 * This flag allows forced loading of the library in the case when for some 117 * reason multiple ELF files share the same filename (because the already-loaded 118 * library has been removed and overwritten, for example). 119 * 120 * Note that if the library has the same `DT_SONAME` as an old one and some other 121 * library has the soname in its `DT_NEEDED` list, the first one will be used to resolve any 122 * dependencies. 123 */ 124 ANDROID_DLEXT_FORCE_LOAD = 64, 125 126 /** 127 * When set, if the minimum `p_vaddr` of the ELF file's `PT_LOAD` segments is non-zero, 128 * the dynamic linker will load it at that address. 129 * 130 * This flag is for ART internal use only. 131 */ 132 ANDROID_DLEXT_FORCE_FIXED_VADDR = 128, 133 134 /** 135 * Instructs dlopen to load the library at the address specified by reserved_addr. 136 * 137 * The difference between `ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS` and 138 * `ANDROID_DLEXT_RESERVED_ADDRESS` is that for `ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS` the linker 139 * reserves memory at `reserved_addr` whereas for `ANDROID_DLEXT_RESERVED_ADDRESS` the linker 140 * relies on the caller to reserve the memory. 141 * 142 * This flag can be used with `ANDROID_DLEXT_FORCE_FIXED_VADDR`. When 143 * `ANDROID_DLEXT_FORCE_FIXED_VADDR` is set and `load_bias` is not 0 (`load_bias` is the 144 * minimum `p_vaddr` of all `PT_LOAD` segments) this flag is ignored because the linker has to 145 * pick one address over the other and this way is more convenient for ART. 146 * Note that `ANDROID_DLEXT_FORCE_FIXED_VADDR` does not generate an error when the minimum 147 * `p_vaddr` is 0. 148 * 149 * Cannot be used with `ANDROID_DLEXT_RESERVED_ADDRESS` or `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`. 150 * 151 * This flag is for ART internal use only. 152 */ 153 ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS = 256, 154 155 /** 156 * This flag used to load library in a different namespace. The namespace is 157 * specified in `library_namespace`. 158 * 159 * This flag is for internal use only (since there is no NDK API for namespaces). 160 */ 161 ANDROID_DLEXT_USE_NAMESPACE = 512, 162 163 /** Mask of valid bits. */ 164 ANDROID_DLEXT_VALID_FLAG_BITS = 1023 165 } 166 167 struct android_namespace_t; 168 169 /** Used to pass Android-specific arguments to `android_dlopen_ext`. */ 170 struct android_dlextinfo 171 { 172 /** A bitmask of `ANDROID_DLEXT_` enum values. */ 173 ulong flags; 174 175 /** Used by `ANDROID_DLEXT_RESERVED_ADDRESS` and `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`. */ 176 void* reserved_addr; 177 /** Used by `ANDROID_DLEXT_RESERVED_ADDRESS` and `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`. */ 178 size_t reserved_size; 179 180 /** Used by `ANDROID_DLEXT_WRITE_RELRO` and `ANDROID_DLEXT_USE_RELRO`. */ 181 int relro_fd; 182 183 /** Used by `ANDROID_DLEXT_USE_LIBRARY_FD`. */ 184 int library_fd; 185 /** Used by `ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET` */ 186 off64_t library_fd_offset; 187 188 /** Used by `ANDROID_DLEXT_USE_NAMESPACE`. */ 189 android_namespace_t* library_namespace; 190 } 191 192 /** 193 * Opens the given library. The `__filename` and `__flags` arguments are 194 * the same as for [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html), 195 * with the Android-specific flags supplied via the `flags` member of `__info`. 196 */ 197 198 void* android_dlopen_ext ( 199 const(char)* __filename, 200 int __flags, 201 const(android_dlextinfo)* __info); 202 /* __ANDROID_API__ >= 21 */ 203 204 /** @} */ 205