| Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2016 The Android Open Source Project | 
|  | 3 | * All rights reserved. | 
|  | 4 | * | 
|  | 5 | * Redistribution and use in source and binary forms, with or without | 
|  | 6 | * modification, are permitted provided that the following conditions | 
|  | 7 | * are met: | 
|  | 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 | 
|  | 13 | *    distribution. | 
|  | 14 | * | 
|  | 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 | 
|  | 26 | * SUCH DAMAGE. | 
|  | 27 | */ | 
|  | 28 |  | 
| Elliott Hughes | cbc80ba | 2018-02-13 14:26:29 -0800 | [diff] [blame] | 29 | #pragma once | 
| Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 30 |  | 
|  | 31 | #include <android/dlext.h> | 
|  | 32 |  | 
| Jiyong Park | 02586a2 | 2017-05-20 01:01:24 +0900 | [diff] [blame] | 33 | #include <unordered_map> | 
|  | 34 | #include <vector> | 
|  | 35 |  | 
| Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 36 | #include "linker_namespaces.h" | 
|  | 37 | #include "linker_soinfo.h" | 
|  | 38 |  | 
|  | 39 | class ProtectedDataGuard { | 
|  | 40 | public: | 
|  | 41 | ProtectedDataGuard(); | 
|  | 42 | ~ProtectedDataGuard(); | 
|  | 43 |  | 
|  | 44 | private: | 
|  | 45 | void protect_data(int protection); | 
|  | 46 | static size_t ref_count_; | 
|  | 47 | }; | 
|  | 48 |  | 
| Jiyong Park | 02586a2 | 2017-05-20 01:01:24 +0900 | [diff] [blame] | 49 | class ElfReader; | 
|  | 50 |  | 
|  | 51 | std::vector<android_namespace_t*> init_default_namespaces(const char* executable_path); | 
| Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 52 | soinfo* soinfo_alloc(android_namespace_t* ns, const char* name, | 
|  | 53 | struct stat* file_stat, off64_t file_offset, | 
|  | 54 | uint32_t rtld_flags); | 
|  | 55 |  | 
|  | 56 | bool find_libraries(android_namespace_t* ns, | 
|  | 57 | soinfo* start_with, | 
|  | 58 | const char* const library_names[], | 
|  | 59 | size_t library_names_count, | 
|  | 60 | soinfo* soinfos[], | 
|  | 61 | std::vector<soinfo*>* ld_preloads, | 
|  | 62 | size_t ld_preloads_count, | 
|  | 63 | int rtld_flags, | 
|  | 64 | const android_dlextinfo* extinfo, | 
| Dimitry Ivanov | 7d429d3 | 2017-02-01 15:28:52 -0800 | [diff] [blame] | 65 | bool add_as_children, | 
| Jiyong Park | 02586a2 | 2017-05-20 01:01:24 +0900 | [diff] [blame] | 66 | bool search_linked_namespaces, | 
| Jiyong Park | 02586a2 | 2017-05-20 01:01:24 +0900 | [diff] [blame] | 67 | std::vector<android_namespace_t*>* namespaces = nullptr); | 
| Dimitry Ivanov | 3f66057 | 2016-09-09 10:00:39 -0700 | [diff] [blame] | 68 |  | 
|  | 69 | void solist_add_soinfo(soinfo* si); | 
|  | 70 | bool solist_remove_soinfo(soinfo* si); | 
|  | 71 | soinfo* solist_get_head(); | 
|  | 72 | soinfo* solist_get_somain(); | 
| dimitry | 8b14256 | 2018-05-09 15:22:38 +0200 | [diff] [blame] | 73 | soinfo* solist_get_vdso(); |