2009-03-04 04:28:35 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LINKER_H_
|
|
|
|
#define _LINKER_H_
|
|
|
|
|
2015-12-11 01:08:14 +01:00
|
|
|
#include <dlfcn.h>
|
2015-07-28 23:58:37 +02:00
|
|
|
#include <android/dlext.h>
|
2012-02-28 19:40:00 +01:00
|
|
|
#include <elf.h>
|
2014-08-22 21:25:04 +02:00
|
|
|
#include <inttypes.h>
|
2012-08-17 10:53:29 +02:00
|
|
|
#include <link.h>
|
2014-05-09 18:10:14 +02:00
|
|
|
#include <sys/stat.h>
|
2015-07-28 23:58:37 +02:00
|
|
|
#include <unistd.h>
|
2012-08-04 01:49:39 +02:00
|
|
|
|
2015-07-28 23:58:37 +02:00
|
|
|
#include "private/bionic_page.h"
|
2013-03-15 23:30:25 +01:00
|
|
|
#include "private/libc_logging.h"
|
2014-05-09 18:10:14 +02:00
|
|
|
#include "linked_list.h"
|
2013-03-06 03:47:58 +01:00
|
|
|
|
2015-03-31 20:14:03 +02:00
|
|
|
#include <string>
|
2015-04-09 22:42:33 +02:00
|
|
|
#include <vector>
|
2015-03-31 20:14:03 +02:00
|
|
|
|
2013-03-06 03:47:58 +01:00
|
|
|
#define DL_ERR(fmt, x...) \
|
|
|
|
do { \
|
|
|
|
__libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
|
|
|
|
/* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
|
|
|
|
DEBUG("%s\n", linker_get_error_buffer()); \
|
2013-06-18 22:15:00 +02:00
|
|
|
} while (false)
|
|
|
|
|
|
|
|
#define DL_WARN(fmt, x...) \
|
|
|
|
do { \
|
|
|
|
__libc_format_log(ANDROID_LOG_WARN, "linker", fmt, ##x); \
|
|
|
|
__libc_format_fd(2, "WARNING: linker: "); \
|
|
|
|
__libc_format_fd(2, fmt, ##x); \
|
|
|
|
__libc_format_fd(2, "\n"); \
|
|
|
|
} while (false)
|
|
|
|
|
2014-02-11 02:46:57 +01:00
|
|
|
#if defined(__LP64__)
|
|
|
|
#define ELFW(what) ELF64_ ## what
|
|
|
|
#else
|
|
|
|
#define ELFW(what) ELF32_ ## what
|
|
|
|
#endif
|
2013-03-06 03:47:58 +01:00
|
|
|
|
2014-02-07 05:36:51 +01:00
|
|
|
// mips64 interprets Elf64_Rel structures' r_info field differently.
|
|
|
|
// bionic (like other C libraries) has macros that assume regular ELF files,
|
|
|
|
// but the dynamic linker needs to be able to load mips64 ELF files.
|
|
|
|
#if defined(__mips__) && defined(__LP64__)
|
|
|
|
#undef ELF64_R_SYM
|
|
|
|
#undef ELF64_R_TYPE
|
|
|
|
#undef ELF64_R_INFO
|
|
|
|
#define ELF64_R_SYM(info) (((info) >> 0) & 0xffffffff)
|
|
|
|
#define ELF64_R_SSYM(info) (((info) >> 32) & 0xff)
|
|
|
|
#define ELF64_R_TYPE3(info) (((info) >> 40) & 0xff)
|
|
|
|
#define ELF64_R_TYPE2(info) (((info) >> 48) & 0xff)
|
|
|
|
#define ELF64_R_TYPE(info) (((info) >> 56) & 0xff)
|
|
|
|
#endif
|
|
|
|
|
2016-01-15 20:13:35 +01:00
|
|
|
#define FLAG_LINKED 0x00000001
|
|
|
|
#define FLAG_EXE 0x00000004 // The main executable
|
|
|
|
#define FLAG_LINKER 0x00000010 // The linker itself
|
|
|
|
#define FLAG_GNU_HASH 0x00000040 // uses gnu hash
|
|
|
|
#define FLAG_MAPPED_BY_CALLER 0x00000080 // the map is reserved by the caller
|
|
|
|
// and should not be unmapped
|
|
|
|
#define FLAG_NEW_SOINFO 0x40000000 // new soinfo format
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-08-28 23:12:12 +02:00
|
|
|
#define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE)
|
|
|
|
|
2015-10-30 01:01:24 +01:00
|
|
|
#define SOINFO_VERSION 3
|
2014-08-22 21:25:04 +02:00
|
|
|
|
2015-09-28 19:14:17 +02:00
|
|
|
#if defined(__work_around_b_24465209__)
|
2009-03-04 04:28:35 +01:00
|
|
|
#define SOINFO_NAME_LEN 128
|
2015-03-31 20:14:03 +02:00
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2013-03-12 18:40:45 +01:00
|
|
|
typedef void (*linker_function_t)();
|
|
|
|
|
2014-02-07 05:36:51 +01:00
|
|
|
// Android uses RELA for aarch64 and x86_64. mips64 still uses REL.
|
|
|
|
#if defined(__aarch64__) || defined(__x86_64__)
|
2013-10-26 02:38:02 +02:00
|
|
|
#define USE_RELA 1
|
|
|
|
#endif
|
|
|
|
|
2014-05-09 18:10:14 +02:00
|
|
|
struct soinfo;
|
|
|
|
|
|
|
|
class SoinfoListAllocator {
|
2014-11-10 04:27:20 +01:00
|
|
|
public:
|
2014-05-09 18:10:14 +02:00
|
|
|
static LinkedListEntry<soinfo>* alloc();
|
|
|
|
static void free(LinkedListEntry<soinfo>* entry);
|
2014-11-10 04:27:20 +01:00
|
|
|
|
|
|
|
private:
|
2014-05-09 18:10:14 +02:00
|
|
|
// unconstructable
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(SoinfoListAllocator);
|
|
|
|
};
|
|
|
|
|
2014-11-10 04:27:20 +01:00
|
|
|
class SymbolName {
|
|
|
|
public:
|
|
|
|
explicit SymbolName(const char* name)
|
|
|
|
: name_(name), has_elf_hash_(false), has_gnu_hash_(false),
|
|
|
|
elf_hash_(0), gnu_hash_(0) { }
|
|
|
|
|
|
|
|
const char* get_name() {
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t elf_hash();
|
|
|
|
uint32_t gnu_hash();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* name_;
|
|
|
|
bool has_elf_hash_;
|
|
|
|
bool has_gnu_hash_;
|
|
|
|
uint32_t elf_hash_;
|
|
|
|
uint32_t gnu_hash_;
|
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolName);
|
|
|
|
};
|
|
|
|
|
2015-04-09 22:42:33 +02:00
|
|
|
struct version_info {
|
2015-12-11 01:08:14 +01:00
|
|
|
constexpr version_info() : elf_hash(0), name(nullptr), target_si(nullptr) {}
|
2015-04-09 22:42:33 +02:00
|
|
|
|
|
|
|
uint32_t elf_hash;
|
|
|
|
const char* name;
|
|
|
|
const soinfo* target_si;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Class used construct version dependency graph.
|
|
|
|
class VersionTracker {
|
|
|
|
public:
|
|
|
|
VersionTracker() = default;
|
|
|
|
bool init(const soinfo* si_from);
|
|
|
|
|
|
|
|
const version_info* get_version_info(ElfW(Versym) source_symver) const;
|
|
|
|
private:
|
|
|
|
bool init_verneed(const soinfo* si_from);
|
|
|
|
bool init_verdef(const soinfo* si_from);
|
|
|
|
void add_version_info(size_t source_index, ElfW(Word) elf_hash,
|
|
|
|
const char* ver_name, const soinfo* target_si);
|
|
|
|
|
|
|
|
std::vector<version_info> version_infos;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(VersionTracker);
|
|
|
|
};
|
|
|
|
|
2012-10-30 01:37:13 +01:00
|
|
|
struct soinfo {
|
2014-05-09 18:10:14 +02:00
|
|
|
public:
|
|
|
|
typedef LinkedList<soinfo, SoinfoListAllocator> soinfo_list_t;
|
2015-09-28 19:14:17 +02:00
|
|
|
#if defined(__work_around_b_24465209__)
|
2015-03-31 20:14:03 +02:00
|
|
|
private:
|
|
|
|
char old_name_[SOINFO_NAME_LEN];
|
|
|
|
#endif
|
2013-03-12 18:40:45 +01:00
|
|
|
public:
|
2014-02-11 02:46:57 +01:00
|
|
|
const ElfW(Phdr)* phdr;
|
2013-03-12 18:40:45 +01:00
|
|
|
size_t phnum;
|
2014-02-11 02:46:57 +01:00
|
|
|
ElfW(Addr) entry;
|
|
|
|
ElfW(Addr) base;
|
2013-12-03 12:47:34 +01:00
|
|
|
size_t size;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2015-09-28 19:14:17 +02:00
|
|
|
#if defined(__work_around_b_24465209__)
|
2013-03-12 18:40:45 +01:00
|
|
|
uint32_t unused1; // DO NOT USE, maintained for compatibility.
|
2013-10-01 03:43:46 +02:00
|
|
|
#endif
|
2011-08-29 22:49:22 +02:00
|
|
|
|
2014-02-11 02:46:57 +01:00
|
|
|
ElfW(Dyn)* dynamic;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2015-09-28 19:14:17 +02:00
|
|
|
#if defined(__work_around_b_24465209__)
|
2013-03-12 18:40:45 +01:00
|
|
|
uint32_t unused2; // DO NOT USE, maintained for compatibility
|
|
|
|
uint32_t unused3; // DO NOT USE, maintained for compatibility
|
2013-10-01 03:43:46 +02:00
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2012-11-01 23:16:56 +01:00
|
|
|
soinfo* next;
|
2014-09-30 04:14:45 +02:00
|
|
|
private:
|
2014-11-29 22:57:41 +01:00
|
|
|
uint32_t flags_;
|
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
const char* strtab_;
|
|
|
|
ElfW(Sym)* symtab_;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
size_t nbucket_;
|
|
|
|
size_t nchain_;
|
|
|
|
uint32_t* bucket_;
|
|
|
|
uint32_t* chain_;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-02-07 05:36:51 +01:00
|
|
|
#if defined(__mips__) || !defined(__LP64__)
|
|
|
|
// This is only used by mips and mips64, but needs to be here for
|
2013-10-26 02:38:02 +02:00
|
|
|
// all 32-bit architectures to preserve binary compatibility.
|
2014-11-13 18:39:20 +01:00
|
|
|
ElfW(Addr)** plt_got_;
|
2013-10-26 02:38:02 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(USE_RELA)
|
2014-11-13 18:39:20 +01:00
|
|
|
ElfW(Rela)* plt_rela_;
|
|
|
|
size_t plt_rela_count_;
|
2013-10-05 02:01:33 +02:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
ElfW(Rela)* rela_;
|
|
|
|
size_t rela_count_;
|
2013-10-05 02:01:33 +02:00
|
|
|
#else
|
2014-11-13 18:39:20 +01:00
|
|
|
ElfW(Rel)* plt_rel_;
|
|
|
|
size_t plt_rel_count_;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
ElfW(Rel)* rel_;
|
|
|
|
size_t rel_count_;
|
2013-10-05 02:01:33 +02:00
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
linker_function_t* preinit_array_;
|
|
|
|
size_t preinit_array_count_;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
linker_function_t* init_array_;
|
|
|
|
size_t init_array_count_;
|
|
|
|
linker_function_t* fini_array_;
|
|
|
|
size_t fini_array_count_;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
linker_function_t init_func_;
|
|
|
|
linker_function_t fini_func_;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2013-10-26 02:38:02 +02:00
|
|
|
#if defined(__arm__)
|
2014-11-29 22:57:41 +01:00
|
|
|
public:
|
2012-11-01 23:16:56 +01:00
|
|
|
// ARM EABI section used for stack unwinding.
|
2014-05-20 00:06:58 +02:00
|
|
|
uint32_t* ARM_exidx;
|
2013-03-12 18:40:45 +01:00
|
|
|
size_t ARM_exidx_count;
|
2014-11-13 03:20:39 +01:00
|
|
|
private:
|
2014-11-29 22:57:41 +01:00
|
|
|
#elif defined(__mips__)
|
2014-11-13 18:39:20 +01:00
|
|
|
uint32_t mips_symtabno_;
|
|
|
|
uint32_t mips_local_gotno_;
|
|
|
|
uint32_t mips_gotsym_;
|
2015-05-01 05:17:03 +02:00
|
|
|
bool mips_relocate_got(const VersionTracker& version_tracker,
|
|
|
|
const soinfo_list_t& global_group,
|
|
|
|
const soinfo_list_t& local_group);
|
2015-06-02 01:29:14 +02:00
|
|
|
#if !defined(__LP64__)
|
|
|
|
bool mips_check_and_adjust_fp_modes();
|
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
#endif
|
2014-11-29 22:57:41 +01:00
|
|
|
size_t ref_count_;
|
2014-11-13 18:39:20 +01:00
|
|
|
public:
|
2014-02-10 22:31:13 +01:00
|
|
|
link_map link_map_head;
|
2011-12-21 10:03:54 +01:00
|
|
|
|
2012-11-01 23:16:56 +01:00
|
|
|
bool constructors_called;
|
2012-02-28 19:40:00 +01:00
|
|
|
|
2012-11-01 23:16:56 +01:00
|
|
|
// When you read a virtual address from the ELF file, add this
|
|
|
|
// value to get the corresponding address in the process' address space.
|
2014-02-11 02:46:57 +01:00
|
|
|
ElfW(Addr) load_bias;
|
2012-08-30 12:48:32 +02:00
|
|
|
|
2015-04-01 23:18:48 +02:00
|
|
|
#if !defined(__LP64__)
|
|
|
|
bool has_text_relocations;
|
2013-10-28 22:19:05 +01:00
|
|
|
#endif
|
2014-09-29 21:10:36 +02:00
|
|
|
bool has_DT_SYMBOLIC;
|
2014-08-22 21:25:04 +02:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
public:
|
2015-10-30 01:01:24 +01:00
|
|
|
soinfo(android_namespace_t* ns, const char* name, const struct stat* file_stat,
|
|
|
|
off64_t file_offset, int rtld_flags);
|
2016-03-24 23:30:30 +01:00
|
|
|
~soinfo();
|
2014-08-22 21:25:04 +02:00
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
void call_constructors();
|
|
|
|
void call_destructors();
|
|
|
|
void call_pre_init_constructors();
|
|
|
|
bool prelink_image();
|
2015-03-31 03:43:38 +02:00
|
|
|
bool link_image(const soinfo_list_t& global_group, const soinfo_list_t& local_group,
|
|
|
|
const android_dlextinfo* extinfo);
|
2015-11-12 08:02:14 +01:00
|
|
|
bool protect_relro();
|
2012-11-01 23:16:56 +01:00
|
|
|
|
2014-05-09 18:10:14 +02:00
|
|
|
void add_child(soinfo* child);
|
|
|
|
void remove_all_links();
|
|
|
|
|
2014-08-28 23:12:12 +02:00
|
|
|
ino_t get_st_ino() const;
|
|
|
|
dev_t get_st_dev() const;
|
|
|
|
off64_t get_file_offset() const;
|
2014-07-23 20:22:25 +02:00
|
|
|
|
2014-08-28 23:12:12 +02:00
|
|
|
uint32_t get_rtld_flags() const;
|
|
|
|
uint32_t get_dt_flags_1() const;
|
|
|
|
void set_dt_flags_1(uint32_t dt_flags_1);
|
2014-09-16 02:00:10 +02:00
|
|
|
|
2014-05-09 18:10:14 +02:00
|
|
|
soinfo_list_t& get_children();
|
2015-04-09 22:42:33 +02:00
|
|
|
const soinfo_list_t& get_children() const;
|
|
|
|
|
2014-09-06 01:42:53 +02:00
|
|
|
soinfo_list_t& get_parents();
|
2014-05-09 18:10:14 +02:00
|
|
|
|
2015-04-09 22:42:33 +02:00
|
|
|
bool find_symbol_by_name(SymbolName& symbol_name,
|
|
|
|
const version_info* vi,
|
|
|
|
const ElfW(Sym)** symbol) const;
|
|
|
|
|
2014-11-10 04:27:20 +01:00
|
|
|
ElfW(Sym)* find_symbol_by_address(const void* addr);
|
2015-04-09 22:42:33 +02:00
|
|
|
ElfW(Addr) resolve_symbol_address(const ElfW(Sym)* s) const;
|
2014-09-12 00:16:03 +02:00
|
|
|
|
2014-09-30 04:14:45 +02:00
|
|
|
const char* get_string(ElfW(Word) index) const;
|
2014-05-20 00:06:58 +02:00
|
|
|
bool can_unload() const;
|
2014-11-10 04:27:20 +01:00
|
|
|
bool is_gnu_hash() const;
|
2014-09-30 04:14:45 +02:00
|
|
|
|
2015-03-31 20:14:03 +02:00
|
|
|
bool inline has_min_version(uint32_t min_version __unused) const {
|
2015-09-28 19:14:17 +02:00
|
|
|
#if defined(__work_around_b_24465209__)
|
2014-11-29 22:57:41 +01:00
|
|
|
return (flags_ & FLAG_NEW_SOINFO) != 0 && version_ >= min_version;
|
2015-03-31 20:14:03 +02:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
2014-08-22 21:25:04 +02:00
|
|
|
}
|
2014-05-20 00:06:58 +02:00
|
|
|
|
2014-11-29 22:57:41 +01:00
|
|
|
bool is_linked() const;
|
2016-03-02 00:55:56 +01:00
|
|
|
bool is_linker() const;
|
2014-11-29 22:57:41 +01:00
|
|
|
bool is_main_executable() const;
|
|
|
|
|
|
|
|
void set_linked();
|
|
|
|
void set_linker_flag();
|
|
|
|
void set_main_executable();
|
2015-10-30 01:01:24 +01:00
|
|
|
void set_nodelete();
|
2014-11-29 22:57:41 +01:00
|
|
|
|
|
|
|
void increment_ref_count();
|
|
|
|
size_t decrement_ref_count();
|
|
|
|
|
|
|
|
soinfo* get_local_group_root() const;
|
|
|
|
|
2015-10-15 21:07:25 +02:00
|
|
|
void set_soname(const char* soname);
|
2015-03-31 20:14:03 +02:00
|
|
|
const char* get_soname() const;
|
|
|
|
const char* get_realpath() const;
|
2015-04-09 22:42:33 +02:00
|
|
|
const ElfW(Versym)* get_versym(size_t n) const;
|
|
|
|
ElfW(Addr) get_verneed_ptr() const;
|
|
|
|
size_t get_verneed_cnt() const;
|
|
|
|
ElfW(Addr) get_verdef_ptr() const;
|
|
|
|
size_t get_verdef_cnt() const;
|
|
|
|
|
|
|
|
bool find_verdef_version_index(const version_info* vi, ElfW(Versym)* versym) const;
|
2015-03-18 04:06:36 +01:00
|
|
|
|
2015-06-03 02:36:54 +02:00
|
|
|
uint32_t get_target_sdk_version() const;
|
|
|
|
|
2015-10-15 21:07:25 +02:00
|
|
|
void set_dt_runpath(const char *);
|
2015-06-10 22:38:39 +02:00
|
|
|
const std::vector<std::string>& get_dt_runpath() const;
|
2015-10-30 01:01:24 +01:00
|
|
|
android_namespace_t* get_namespace();
|
2015-06-10 22:38:39 +02:00
|
|
|
|
2016-01-15 20:13:35 +01:00
|
|
|
void set_mapped_by_caller(bool reserved_map);
|
|
|
|
bool is_mapped_by_caller() const;
|
|
|
|
|
2016-03-24 23:30:30 +01:00
|
|
|
uintptr_t get_handle() const;
|
|
|
|
void generate_handle();
|
|
|
|
void* to_handle();
|
|
|
|
|
2012-11-01 23:16:56 +01:00
|
|
|
private:
|
2015-04-09 22:42:33 +02:00
|
|
|
bool elf_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
|
2014-11-10 04:27:20 +01:00
|
|
|
ElfW(Sym)* elf_addr_lookup(const void* addr);
|
2015-04-09 22:42:33 +02:00
|
|
|
bool gnu_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
|
2014-11-10 04:27:20 +01:00
|
|
|
ElfW(Sym)* gnu_addr_lookup(const void* addr);
|
|
|
|
|
2015-05-01 01:11:48 +02:00
|
|
|
bool lookup_version_info(const VersionTracker& version_tracker, ElfW(Word) sym,
|
|
|
|
const char* sym_name, const version_info** vi);
|
|
|
|
|
2014-11-13 18:39:20 +01:00
|
|
|
void call_array(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
|
|
|
|
void call_function(const char* function_name, linker_function_t function);
|
2015-02-04 01:06:47 +01:00
|
|
|
template<typename ElfRelIteratorT>
|
2015-05-01 04:49:19 +02:00
|
|
|
bool relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& rel_iterator,
|
|
|
|
const soinfo_list_t& global_group, const soinfo_list_t& local_group);
|
2014-05-09 18:10:14 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// This part of the structure is only available
|
|
|
|
// when FLAG_NEW_SOINFO is set in this->flags.
|
2014-11-13 18:39:20 +01:00
|
|
|
uint32_t version_;
|
2014-07-23 20:22:25 +02:00
|
|
|
|
2014-08-22 21:25:04 +02:00
|
|
|
// version >= 0
|
2014-11-13 18:39:20 +01:00
|
|
|
dev_t st_dev_;
|
|
|
|
ino_t st_ino_;
|
2014-05-09 18:10:14 +02:00
|
|
|
|
|
|
|
// dependency graph
|
2014-11-13 18:39:20 +01:00
|
|
|
soinfo_list_t children_;
|
|
|
|
soinfo_list_t parents_;
|
2014-05-09 18:10:14 +02:00
|
|
|
|
2014-08-22 21:25:04 +02:00
|
|
|
// version >= 1
|
2014-11-13 18:39:20 +01:00
|
|
|
off64_t file_offset_;
|
|
|
|
uint32_t rtld_flags_;
|
|
|
|
uint32_t dt_flags_1_;
|
|
|
|
size_t strtab_size_;
|
2014-09-30 04:14:45 +02:00
|
|
|
|
2014-11-10 04:27:20 +01:00
|
|
|
// version >= 2
|
2015-03-09 20:02:02 +01:00
|
|
|
|
|
|
|
size_t gnu_nbucket_;
|
|
|
|
uint32_t* gnu_bucket_;
|
|
|
|
uint32_t* gnu_chain_;
|
2014-11-13 18:39:20 +01:00
|
|
|
uint32_t gnu_maskwords_;
|
|
|
|
uint32_t gnu_shift2_;
|
|
|
|
ElfW(Addr)* gnu_bloom_filter_;
|
2014-11-10 04:27:20 +01:00
|
|
|
|
2014-11-29 22:57:41 +01:00
|
|
|
soinfo* local_group_root_;
|
|
|
|
|
2015-02-05 01:05:30 +01:00
|
|
|
uint8_t* android_relocs_;
|
|
|
|
size_t android_relocs_size_;
|
|
|
|
|
2015-03-18 04:06:36 +01:00
|
|
|
const char* soname_;
|
2015-03-31 20:14:03 +02:00
|
|
|
std::string realpath_;
|
2015-03-18 04:06:36 +01:00
|
|
|
|
2015-04-09 22:42:33 +02:00
|
|
|
const ElfW(Versym)* versym_;
|
|
|
|
|
|
|
|
ElfW(Addr) verdef_ptr_;
|
|
|
|
size_t verdef_cnt_;
|
|
|
|
|
|
|
|
ElfW(Addr) verneed_ptr_;
|
|
|
|
size_t verneed_cnt_;
|
|
|
|
|
2015-06-03 02:36:54 +02:00
|
|
|
uint32_t target_sdk_version_;
|
|
|
|
|
2015-10-30 01:01:24 +01:00
|
|
|
// version >= 3
|
2015-06-10 22:38:39 +02:00
|
|
|
std::vector<std::string> dt_runpath_;
|
2015-10-30 01:01:24 +01:00
|
|
|
android_namespace_t* namespace_;
|
2016-03-24 23:30:30 +01:00
|
|
|
uintptr_t handle_;
|
2015-06-10 22:38:39 +02:00
|
|
|
|
2014-09-30 04:14:45 +02:00
|
|
|
friend soinfo* get_libdl_info();
|
2009-03-04 04:28:35 +01:00
|
|
|
};
|
|
|
|
|
2015-04-09 22:42:33 +02:00
|
|
|
bool soinfo_do_lookup(soinfo* si_from, const char* name, const version_info* vi,
|
|
|
|
soinfo** si_found_in, const soinfo::soinfo_list_t& global_group,
|
|
|
|
const soinfo::soinfo_list_t& local_group, const ElfW(Sym)** symbol);
|
2015-01-14 20:36:38 +01:00
|
|
|
|
|
|
|
enum RelocationKind {
|
|
|
|
kRelocAbsolute = 0,
|
|
|
|
kRelocRelative,
|
|
|
|
kRelocCopy,
|
|
|
|
kRelocSymbol,
|
|
|
|
kRelocMax
|
|
|
|
};
|
|
|
|
|
|
|
|
void count_relocation(RelocationKind kind);
|
|
|
|
|
2014-05-20 00:06:58 +02:00
|
|
|
soinfo* get_libdl_info();
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-01-14 01:37:47 +01:00
|
|
|
void do_android_get_LD_LIBRARY_PATH(char*, size_t);
|
2012-12-20 23:42:14 +01:00
|
|
|
void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
|
2016-03-24 23:30:30 +01:00
|
|
|
void* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo, void* caller_addr);
|
|
|
|
int do_dlclose(void* handle);
|
2012-06-12 16:25:37 +02:00
|
|
|
|
2015-06-29 23:48:25 +02:00
|
|
|
int do_dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data);
|
|
|
|
|
2015-12-11 01:08:14 +01:00
|
|
|
bool do_dlsym(void* handle, const char* sym_name, const char* sym_ver,
|
|
|
|
void* caller_addr, void** symbol);
|
2015-10-30 01:01:24 +01:00
|
|
|
|
2015-12-11 01:08:14 +01:00
|
|
|
int do_dladdr(const void* addr, Dl_info* info);
|
2012-11-01 23:16:56 +01:00
|
|
|
|
2013-03-01 00:58:45 +01:00
|
|
|
void debuggerd_init();
|
2014-05-14 19:02:03 +02:00
|
|
|
extern "C" abort_msg_t* g_abort_message;
|
2012-08-04 01:49:39 +02:00
|
|
|
|
2013-03-06 03:47:58 +01:00
|
|
|
char* linker_get_error_buffer();
|
|
|
|
size_t linker_get_error_buffer_size();
|
|
|
|
|
2015-05-22 02:43:49 +02:00
|
|
|
void set_application_target_sdk_version(uint32_t target);
|
|
|
|
uint32_t get_application_target_sdk_version();
|
|
|
|
|
2015-11-23 20:26:35 +01:00
|
|
|
bool init_namespaces(const char* public_ns_sonames, const char* anon_ns_library_path);
|
2015-12-14 23:11:17 +01:00
|
|
|
android_namespace_t* create_namespace(const void* caller_addr, const char* name,
|
|
|
|
const char* ld_library_path, const char* default_library_path,
|
|
|
|
uint64_t type, const char* permitted_when_isolated_path);
|
2015-10-30 01:01:24 +01:00
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
#endif
|