2 * Copyright (C) 2016 The Android Open Source Project
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef __LINKER_MAIN_H
30 #define __LINKER_MAIN_H
32 #include <android/dlext.h>
34 #include <unordered_map>
37 #include "linker_namespaces.h"
38 #include "linker_soinfo.h"
40 class ProtectedDataGuard {
43 ~ProtectedDataGuard();
46 void protect_data(int protection);
47 static size_t ref_count_;
52 std::vector<android_namespace_t*> init_default_namespaces(const char* executable_path);
53 soinfo* soinfo_alloc(android_namespace_t* ns, const char* name,
54 struct stat* file_stat, off64_t file_offset,
57 bool find_libraries(android_namespace_t* ns,
59 const char* const library_names[],
60 size_t library_names_count,
62 std::vector<soinfo*>* ld_preloads,
63 size_t ld_preloads_count,
65 const android_dlextinfo* extinfo,
67 bool search_linked_namespaces,
68 std::unordered_map<const soinfo*, ElfReader>& readers_map,
69 std::vector<android_namespace_t*>* namespaces = nullptr);
71 void solist_add_soinfo(soinfo* si);
72 bool solist_remove_soinfo(soinfo* si);
73 soinfo* solist_get_head();
74 soinfo* solist_get_somain();