13f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov/* 23f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * Copyright (C) 2016 The Android Open Source Project 33f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * All rights reserved. 43f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * 53f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * Redistribution and use in source and binary forms, with or without 63f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * modification, are permitted provided that the following conditions 73f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * are met: 83f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * * Redistributions of source code must retain the above copyright 93f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * notice, this list of conditions and the following disclaimer. 103f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * * Redistributions in binary form must reproduce the above copyright 113f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * notice, this list of conditions and the following disclaimer in 123f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * the documentation and/or other materials provided with the 133f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * distribution. 143f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * 153f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 163f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 173f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 183f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 193f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 203f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 213f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 223f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 233f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 243f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 253f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 263f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov * SUCH DAMAGE. 273f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov */ 283f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 293f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov#ifndef __LINKER_MAIN_H 303f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov#define __LINKER_MAIN_H 313f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 323f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov#include <android/dlext.h> 333f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 343f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov#include "linker_namespaces.h" 353f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov#include "linker_soinfo.h" 363f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 373f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovclass ProtectedDataGuard { 383f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov public: 393f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov ProtectedDataGuard(); 403f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov ~ProtectedDataGuard(); 413f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 423f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov private: 433f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov void protect_data(int protection); 443f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov static size_t ref_count_; 453f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov}; 463f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 474cabfaad340c957ff691cfbc420b29da805c5dd8Dimitry Ivanovvoid init_default_namespace(const char* executable_path); 483f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovsoinfo* soinfo_alloc(android_namespace_t* ns, const char* name, 493f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov struct stat* file_stat, off64_t file_offset, 503f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov uint32_t rtld_flags); 513f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 523f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovbool find_libraries(android_namespace_t* ns, 533f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov soinfo* start_with, 543f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov const char* const library_names[], 553f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov size_t library_names_count, 563f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov soinfo* soinfos[], 573f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov std::vector<soinfo*>* ld_preloads, 583f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov size_t ld_preloads_count, 593f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov int rtld_flags, 603f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov const android_dlextinfo* extinfo, 617d429d3c480166e1013bcdf68f4be479209aa509Dimitry Ivanov bool add_as_children, 627d429d3c480166e1013bcdf68f4be479209aa509Dimitry Ivanov bool search_linked_namespaces); 633f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 643f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovvoid solist_add_soinfo(soinfo* si); 653f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovbool solist_remove_soinfo(soinfo* si); 663f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovsoinfo* solist_get_head(); 673f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanovsoinfo* solist_get_somain(); 683f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov 693f6605754464c0856862c4d66ed03227a60a6f4dDimitry Ivanov#endif 70