summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot2017-04-07 16:46:14 -0500
committerGerrit Code Review2017-04-07 16:46:18 -0500
commit1238292db5031fdf0cfe9e753265c30a46a21ec3 (patch)
tree7bf744cb5b457cf2fed14e08c823727b8d944e3e /include
parentf8111b7df86a4678748d484e7292a52b0c2a7769 (diff)
parente8fb11dfa1b376124d0a1a349c8800799f25606a (diff)
downloadplatform-system-core-1238292db5031fdf0cfe9e753265c30a46a21ec3.tar.gz
platform-system-core-1238292db5031fdf0cfe9e753265c30a46a21ec3.tar.xz
platform-system-core-1238292db5031fdf0cfe9e753265c30a46a21ec3.zip
Merge "NativeBridge: add "linked namespace" semantic corresponding to linker"
Diffstat (limited to 'include')
-rw-r--r--include/nativebridge/native_bridge.h106
1 files changed, 74 insertions, 32 deletions
diff --git a/include/nativebridge/native_bridge.h b/include/nativebridge/native_bridge.h
index 45266dedf..929b8aec4 100644
--- a/include/nativebridge/native_bridge.h
+++ b/include/nativebridge/native_bridge.h
@@ -116,14 +116,25 @@ struct native_bridge_namespace_t;
116// Use NativeBridgeIsSupported() instead in non-namespace scenario. 116// Use NativeBridgeIsSupported() instead in non-namespace scenario.
117bool NativeBridgeIsPathSupported(const char* path); 117bool NativeBridgeIsPathSupported(const char* path);
118 118
119// Initializes public and anonymous namespace at native bridge side. 119// Initializes anonymous namespace.
120// NativeBridge's peer of android_init_anonymous_namespace() of dynamic linker.
121//
122// The anonymous namespace is used in the case when a NativeBridge implementation
123// cannot identify the caller of dlopen/dlsym which happens for the code not loaded
124// by dynamic linker; for example calls from the mono-compiled code.
120// 125//
121// Starting with v3, NativeBridge has two scenarios: with/without namespace. 126// Starting with v3, NativeBridge has two scenarios: with/without namespace.
122// Should not use in non-namespace scenario. 127// Should not use in non-namespace scenario.
123bool NativeBridgeInitNamespace(const char* public_ns_sonames, 128bool NativeBridgeInitAnonymousNamespace(const char* public_ns_sonames,
124 const char* anon_ns_library_path); 129 const char* anon_ns_library_path);
125 130
126// Create a namespace and pass the key of related namespaces to native bridge. 131// Create new namespace in which native libraries will be loaded.
132// NativeBridge's peer of android_create_namespace() of dynamic linker.
133//
134// The libraries in the namespace are searched by folowing order:
135// 1. ld_library_path (Think of this as namespace-local LD_LIBRARY_PATH)
136// 2. In directories specified by DT_RUNPATH of the "needed by" binary.
137// 3. deault_library_path (This of this as namespace-local default library path)
127// 138//
128// Starting with v3, NativeBridge has two scenarios: with/without namespace. 139// Starting with v3, NativeBridge has two scenarios: with/without namespace.
129// Should not use in non-namespace scenario. 140// Should not use in non-namespace scenario.
@@ -134,7 +145,17 @@ native_bridge_namespace_t* NativeBridgeCreateNamespace(const char* name,
134 const char* permitted_when_isolated_path, 145 const char* permitted_when_isolated_path,
135 native_bridge_namespace_t* parent_ns); 146 native_bridge_namespace_t* parent_ns);
136 147
148// Creates a link which shares some libraries from one namespace to another.
149// NativeBridge's peer of android_link_namespaces() of dynamic linker.
150//
151// Starting with v3, NativeBridge has two scenarios: with/without namespace.
152// Should not use in non-namespace scenario.
153bool NativeBridgeLinkNamespaces(native_bridge_namespace_t* from, native_bridge_namespace_t* to,
154 const char* shared_libs_sonames);
155
137// Load a shared library with namespace key that is supported by the native bridge. 156// Load a shared library with namespace key that is supported by the native bridge.
157// NativeBridge's peer of android_dlopen_ext() of dynamic linker, only supports namespace
158// extension.
138// 159//
139// Starting with v3, NativeBridge has two scenarios: with/without namespace. 160// Starting with v3, NativeBridge has two scenarios: with/without namespace.
140// Use NativeBridgeLoadLibrary() instead in non-namespace scenario. 161// Use NativeBridgeLoadLibrary() instead in non-namespace scenario.
@@ -152,7 +173,7 @@ struct NativeBridgeCallbacks {
152 // Parameters: 173 // Parameters:
153 // runtime_cbs [IN] the pointer to NativeBridgeRuntimeCallbacks. 174 // runtime_cbs [IN] the pointer to NativeBridgeRuntimeCallbacks.
154 // Returns: 175 // Returns:
155 // true iff initialization was successful. 176 // true if initialization was successful.
156 bool (*initialize)(const NativeBridgeRuntimeCallbacks* runtime_cbs, const char* private_dir, 177 bool (*initialize)(const NativeBridgeRuntimeCallbacks* runtime_cbs, const char* private_dir,
157 const char* instruction_set); 178 const char* instruction_set);
158 179
@@ -194,10 +215,10 @@ struct NativeBridgeCallbacks {
194 // instruction set. 215 // instruction set.
195 // 216 //
196 // Parameters: 217 // Parameters:
197 // instruction_set [IN] the instruction set of the app 218 // instruction_set [IN] the instruction set of the app
198 // Returns: 219 // Returns:
199 // NULL if not supported by native bridge. 220 // NULL if not supported by native bridge.
200 // Otherwise, return all environment values to be set after fork. 221 // Otherwise, return all environment values to be set after fork.
201 const struct NativeBridgeRuntimeValues* (*getAppEnv)(const char* instruction_set); 222 const struct NativeBridgeRuntimeValues* (*getAppEnv)(const char* instruction_set);
202 223
203 // Added callbacks in version 2. 224 // Added callbacks in version 2.
@@ -206,9 +227,9 @@ struct NativeBridgeCallbacks {
206 // forwards- or backwards-compatible, and libnativebridge will then stop using it. 227 // forwards- or backwards-compatible, and libnativebridge will then stop using it.
207 // 228 //
208 // Parameters: 229 // Parameters:
209 // bridge_version [IN] the version of libnativebridge. 230 // bridge_version [IN] the version of libnativebridge.
210 // Returns: 231 // Returns:
211 // true iff the native bridge supports the given version of libnativebridge. 232 // true if the native bridge supports the given version of libnativebridge.
212 bool (*isCompatibleWith)(uint32_t bridge_version); 233 bool (*isCompatibleWith)(uint32_t bridge_version);
213 234
214 // A callback to retrieve a native bridge's signal handler for the specified signal. The runtime 235 // A callback to retrieve a native bridge's signal handler for the specified signal. The runtime
@@ -217,12 +238,12 @@ struct NativeBridgeCallbacks {
217 // that will potentially lead to cycles. 238 // that will potentially lead to cycles.
218 // 239 //
219 // Parameters: 240 // Parameters:
220 // signal [IN] the signal for which the handler is asked for. Currently, only SIGSEGV is 241 // signal [IN] the signal for which the handler is asked for. Currently, only SIGSEGV is
221 // supported by the runtime. 242 // supported by the runtime.
222 // Returns: 243 // Returns:
223 // NULL if the native bridge doesn't use a handler or doesn't want it to be managed by the 244 // NULL if the native bridge doesn't use a handler or doesn't want it to be managed by the
224 // runtime. 245 // runtime.
225 // Otherwise, a pointer to the signal handler. 246 // Otherwise, a pointer to the signal handler.
226 NativeBridgeSignalHandlerFn (*getSignalHandler)(int signal); 247 NativeBridgeSignalHandlerFn (*getSignalHandler)(int signal);
227 248
228 // Added callbacks in version 3. 249 // Added callbacks in version 3.
@@ -231,7 +252,7 @@ struct NativeBridgeCallbacks {
231 // to zero then the dynamic library is unloaded. 252 // to zero then the dynamic library is unloaded.
232 // 253 //
233 // Parameters: 254 // Parameters:
234 // handle [IN] the handler of a dynamic library. 255 // handle [IN] the handler of a dynamic library.
235 // 256 //
236 // Returns: 257 // Returns:
237 // 0 on success, and nonzero on error. 258 // 0 on success, and nonzero on error.
@@ -257,33 +278,36 @@ struct NativeBridgeCallbacks {
257 // Use isSupported instead in non-namespace scenario. 278 // Use isSupported instead in non-namespace scenario.
258 bool (*isPathSupported)(const char* library_path); 279 bool (*isPathSupported)(const char* library_path);
259 280
260 // Initializes anonymous namespace at native bridge side and pass the key of 281 // Initializes anonymous namespace at native bridge side.
261 // two namespaces(default and anonymous) owned by dynamic linker to native bridge. 282 // NativeBridge's peer of android_init_anonymous_namespace() of dynamic linker.
283 //
284 // The anonymous namespace is used in the case when a NativeBridge implementation
285 // cannot identify the caller of dlopen/dlsym which happens for the code not loaded
286 // by dynamic linker; for example calls from the mono-compiled code.
262 // 287 //
263 // Parameters: 288 // Parameters:
264 // public_ns_sonames [IN] the name of "public" libraries. 289 // public_ns_sonames [IN] the name of "public" libraries.
265 // anon_ns_library_path [IN] the library search path of (anonymous) namespace. 290 // anon_ns_library_path [IN] the library search path of (anonymous) namespace.
266 // Returns: 291 // Returns:
267 // true if the pass is ok. 292 // true if the pass is ok.
268 // Otherwise, false. 293 // Otherwise, false.
269 // 294 //
270 // Starting with v3, NativeBridge has two scenarios: with/without namespace. 295 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
271 // Should not use in non-namespace scenario. 296 // Should not use in non-namespace scenario.
272 bool (*initNamespace)(const char* public_ns_sonames, 297 bool (*initAnonymousNamespace)(const char* public_ns_sonames, const char* anon_ns_library_path);
273 const char* anon_ns_library_path);
274
275 298
276 // Create a namespace and pass the key of releated namespaces to native bridge. 299 // Create new namespace in which native libraries will be loaded.
300 // NativeBridge's peer of android_create_namespace() of dynamic linker.
277 // 301 //
278 // Parameters: 302 // Parameters:
279 // name [IN] the name of the namespace. 303 // name [IN] the name of the namespace.
280 // ld_library_path [IN] the first set of library search paths of the namespace. 304 // ld_library_path [IN] the first set of library search paths of the namespace.
281 // default_library_path [IN] the second set of library search path of the namespace. 305 // default_library_path [IN] the second set of library search path of the namespace.
282 // type [IN] the attribute of the namespace. 306 // type [IN] the attribute of the namespace.
283 // permitted_when_isolated_path [IN] the permitted path for isolated namespace(if it is). 307 // permitted_when_isolated_path [IN] the permitted path for isolated namespace(if it is).
284 // parent_ns [IN] the pointer of the parent namespace to be inherited from. 308 // parent_ns [IN] the pointer of the parent namespace to be inherited from.
285 // Returns: 309 // Returns:
286 // native_bridge_namespace_t* for created namespace or nullptr in the case of error. 310 // native_bridge_namespace_t* for created namespace or nullptr in the case of error.
287 // 311 //
288 // Starting with v3, NativeBridge has two scenarios: with/without namespace. 312 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
289 // Should not use in non-namespace scenario. 313 // Should not use in non-namespace scenario.
@@ -294,7 +318,25 @@ struct NativeBridgeCallbacks {
294 const char* permitted_when_isolated_path, 318 const char* permitted_when_isolated_path,
295 native_bridge_namespace_t* parent_ns); 319 native_bridge_namespace_t* parent_ns);
296 320
321 // Creates a link which shares some libraries from one namespace to another.
322 // NativeBridge's peer of android_link_namespaces() of dynamic linker.
323 //
324 // Parameters:
325 // from [IN] the namespace where libraries are accessed.
326 // to [IN] the namespace where libraries are loaded.
327 // shared_libs_sonames [IN] the libraries to be shared.
328 //
329 // Returns:
330 // Whether successed or not.
331 //
332 // Starting with v3, NativeBridge has two scenarios: with/without namespace.
333 // Should not use in non-namespace scenario.
334 bool (*linkNamespaces)(native_bridge_namespace_t* from, native_bridge_namespace_t* to,
335 const char* shared_libs_sonames);
336
297 // Load a shared library within a namespace. 337 // Load a shared library within a namespace.
338 // NativeBridge's peer of android_dlopen_ext() of dynamic linker, only supports namespace
339 // extension.
298 // 340 //
299 // Parameters: 341 // Parameters:
300 // libpath [IN] path to the shared library 342 // libpath [IN] path to the shared library