Caricamento del resto di questo confronto.

Untitled diff

Creato Il diff non scade mai
37 rimozioni
925 linee
25 aggiunte
914 linee
/*
/*
* Copyright (C) 2008 The Android Open Source Project
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* modification, are permitted provided that the following conditions
* are met:
* are met:
* * Redistributions of source code must retain the above copyright
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* the documentation and/or other materials provided with the
* distribution.
* distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* SUCH DAMAGE.
*/
*/


#include <android/api-level.h>
#include <android/api-level.h>
#include <dlfcn.h>
#include <dlfcn.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <inttypes.h>
#include <inttypes.h>
#include <pthread.h>
#include <pthread.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/param.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <unistd.h>


#include <new>
#include <new>
#include <string>
#include <string>
#include <vector>
#include <vector>


// Private C library headers.
// Private C library headers.
#include "private/bionic_tls.h"
#include "private/bionic_tls.h"
#include "private/KernelArgumentBlock.h"
#include "private/KernelArgumentBlock.h"
#include "private/ScopedPthreadMutexLocker.h"
#include "private/ScopedPthreadMutexLocker.h"
#include "private/ScopeGuard.h"
#include "private/ScopeGuard.h"
#include "private/UniquePtr.h"
#include "private/UniquePtr.h"


#include "linker.h"
#include "linker.h"
#include "linker_block_allocator.h"
#include "linker_block_allocator.h"
#include "linker_debug.h"
#include "linker_debug.h"
#include "linker_sleb128.h"
#include "linker_sleb128.h"
#include "linker_phdr.h"
#include "linker_phdr.h"
#include "linker_relocs.h"
#include "linker_relocs.h"
#include "linker_reloc_iterators.h"
#include "linker_reloc_iterators.h"
#include "ziparchive/zip_archive.h"
#include "ziparchive/zip_archive.h"


extern void __libc_init_AT_SECURE(KernelArgumentBlock&);
extern void __libc_init_AT_SECURE(KernelArgumentBlock&);


// Override macros to use C++ style casts.
// Override macros to use C++ style casts.
#undef ELF_ST_TYPE
#undef ELF_ST_TYPE
#define ELF_ST_TYPE(x) (static_cast<uint32_t>(x) & 0xf)
#define ELF_ST_TYPE(x) (static_cast<uint32_t>(x) & 0xf)


static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf);
static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf);


static LinkerTypeAllocator<soinfo> g_soinfo_allocator;
static LinkerTypeAllocator<soinfo> g_soinfo_allocator;
static LinkerTypeAllocator<LinkedListEntry<soinfo>> g_soinfo_links_allocator;
static LinkerTypeAllocator<LinkedListEntry<soinfo>> g_soinfo_links_allocator;


static soinfo* solist;
static soinfo* solist;
static soinfo* sonext;
static soinfo* sonext;
static soinfo* somain; // main process, always the one after libdl_info
static soinfo* somain; // main process, always the one after libdl_info


static const char* const kDefaultLdPaths[] = {
static const char* const kDefaultLdPaths[] = {
#if defined(__LP64__)
#if defined(__LP64__)
"/vendor/lib64",
"/vendor/lib64",
"/system/lib64",
"/system/lib64",
#else
#else
"/vendor/lib",
"/vendor/lib",
"/system/lib",
"/system/lib",
#endif
#endif
nullptr
nullptr
};
};


static const ElfW(Versym) kVersymNotNeeded = 0;
static const ElfW(Versym) kVersymNotNeeded = 0;
static const ElfW(Versym) kVersymGlobal = 1;
static const ElfW(Versym) kVersymGlobal = 1;


static std::vector<std::string> g_ld_library_paths;
static std::vector<std::string> g_ld_library_paths;
static std::vector<std::string> g_ld_preload_names;
static std::vector<std::string> g_ld_preload_names;


static std::vector<soinfo*> g_ld_preloads;
static std::vector<soinfo*> g_ld_preloads;


__LIBC_HIDDEN__ int g_ld_debug_verbosity;
__LIBC_HIDDEN__ int g_ld_debug_verbosity;


__LIBC_HIDDEN__ abort_msg_t* g_abort_message = nullptr; // For debuggerd.
__LIBC_HIDDEN__ abort_msg_t* g_abort_message = nullptr; // For debuggerd.