blob: 47a164abb481463b5e5e3aeb5c82628add200252 [file] [log] [blame]
dimitry8868d9e2019-03-19 13:01:42 +01001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <dlfcn.h>
18#include <link.h>
19#include <stdlib.h>
20#include <android/dlext.h>
21
22// These functions are exported by the loader
23// TODO(dimitry): replace these with reference to libc.so
24
25extern "C" {
26
27__attribute__((__weak__, visibility("default")))
28void __loader_android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size);
29
30__attribute__((__weak__, visibility("default")))
dimitry4b8b8492019-03-28 12:43:14 +010031void __loader_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
dimitry8868d9e2019-03-19 13:01:42 +010032
33__attribute__((__weak__, visibility("default")))
34void __loader_android_set_application_target_sdk_version(int target);
35
36__attribute__((__weak__, visibility("default")))
37bool __loader_android_init_anonymous_namespace(const char* shared_libs_sonames,
38 const char* library_search_path);
39
40__attribute__((__weak__, visibility("default")))
41struct android_namespace_t* __loader_android_create_namespace(
42 const char* name,
43 const char* ld_library_path,
44 const char* default_library_path,
45 uint64_t type,
46 const char* permitted_when_isolated_path,
47 struct android_namespace_t* parent,
48 const void* caller_addr);
49
50__attribute__((__weak__, visibility("default")))
51bool __loader_android_link_namespaces(
52 struct android_namespace_t* namespace_from,
53 struct android_namespace_t* namespace_to,
54 const char* shared_libs_sonames);
55
56__attribute__((__weak__, visibility("default")))
57void __loader_android_dlwarning(void* obj, void (*f)(void*, const char*));
58
59__attribute__((__weak__, visibility("default")))
60struct android_namespace_t* __loader_android_get_exported_namespace(const char* name);
61
62// Proxy calls to bionic loader
63__attribute__((__weak__))
64void android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size) {
65 __loader_android_get_LD_LIBRARY_PATH(buffer, buffer_size);
66}
67
68__attribute__((__weak__))
69void android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
70 __loader_android_update_LD_LIBRARY_PATH(ld_library_path);
71}
72
73__attribute__((__weak__))
74void android_set_application_target_sdk_version(int target) {
75 __loader_android_set_application_target_sdk_version(target);
76}
77
78__attribute__((__weak__))
79bool android_init_anonymous_namespace(const char* shared_libs_sonames,
80 const char* library_search_path) {
81 return __loader_android_init_anonymous_namespace(shared_libs_sonames, library_search_path);
82}
83
84__attribute__((__weak__))
85struct android_namespace_t* android_create_namespace(const char* name,
86 const char* ld_library_path,
87 const char* default_library_path,
88 uint64_t type,
89 const char* permitted_when_isolated_path,
90 struct android_namespace_t* parent) {
91 const void* caller_addr = __builtin_return_address(0);
92 return __loader_android_create_namespace(name,
93 ld_library_path,
94 default_library_path,
95 type,
96 permitted_when_isolated_path,
97 parent,
98 caller_addr);
99}
100
101__attribute__((__weak__))
102bool android_link_namespaces(struct android_namespace_t* namespace_from,
103 struct android_namespace_t* namespace_to,
104 const char* shared_libs_sonames) {
105 return __loader_android_link_namespaces(namespace_from, namespace_to, shared_libs_sonames);
106}
107
108__attribute__((__weak__))
109void android_dlwarning(void* obj, void (*f)(void*, const char*)) {
110 __loader_android_dlwarning(obj, f);
111}
112
113__attribute__((__weak__))
114struct android_namespace_t* android_get_exported_namespace(const char* name) {
115 return __loader_android_get_exported_namespace(name);
116}
117
dimitry8868d9e2019-03-19 13:01:42 +0100118} // extern "C"