11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/*
21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * All rights reserved.
41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Redistribution and use in source and binary forms, with or without
61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * modification, are permitted provided that the following conditions
71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * are met:
81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *  * Redistributions of source code must retain the above copyright
91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *  * Redistributions in binary form must reproduce the above copyright
111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    notice, this list of conditions and the following disclaimer in
121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    the documentation and/or other materials provided with the
131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    distribution.
141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * SUCH DAMAGE.
271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */
281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef _LINKER_H_
301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _LINKER_H_
311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
329ec0f03a0d0b17bbb94ac0b9fef6add28a133c3aNick Kralevich#include <elf.h>
330d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov#include <inttypes.h>
34b7beb6907599b36809effe1b4db76039ac649518Pavel Chupin#include <link.h>
351272dbd1d76c979358fff3beae9de0c1462345afElliott Hughes#include <unistd.h>
36012cb4583a5f8564059142bb1900ea3a31e7cfa9Torne (Richard Coles)#include <android/dlext.h>
37d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov#include <sys/stat.h>
384688279db5dcc4004941e7f133c4a1c3617d842cElliott Hughes
398f2a5a0b40fc82126c691d5c30131d908772aab7Elliott Hughes#include "private/libc_logging.h"
40d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov#include "linked_list.h"
41650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes
42aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov#include <string>
432a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov#include <vector>
44aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov
45650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes#define DL_ERR(fmt, x...) \
46650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes    do { \
47650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes      __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
48650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes      /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
49650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes      DEBUG("%s\n", linker_get_error_buffer()); \
507e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes    } while (false)
517e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes
527e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes#define DL_WARN(fmt, x...) \
537e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes    do { \
547e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes      __libc_format_log(ANDROID_LOG_WARN, "linker", fmt, ##x); \
557e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes      __libc_format_fd(2, "WARNING: linker: "); \
567e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes      __libc_format_fd(2, fmt, ##x); \
577e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes      __libc_format_fd(2, "\n"); \
587e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes    } while (false)
597e5a8cc5230dcc027686813e51a1b001cee4c602Elliott Hughes
600266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes#if defined(__LP64__)
610266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes#define ELFW(what) ELF64_ ## what
620266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes#else
630266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes#define ELFW(what) ELF32_ ## what
640266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes#endif
65650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes
669918665a45095ad135576f005c0e5307feb366a1Chris Dearman// mips64 interprets Elf64_Rel structures' r_info field differently.
679918665a45095ad135576f005c0e5307feb366a1Chris Dearman// bionic (like other C libraries) has macros that assume regular ELF files,
689918665a45095ad135576f005c0e5307feb366a1Chris Dearman// but the dynamic linker needs to be able to load mips64 ELF files.
699918665a45095ad135576f005c0e5307feb366a1Chris Dearman#if defined(__mips__) && defined(__LP64__)
709918665a45095ad135576f005c0e5307feb366a1Chris Dearman#undef ELF64_R_SYM
719918665a45095ad135576f005c0e5307feb366a1Chris Dearman#undef ELF64_R_TYPE
729918665a45095ad135576f005c0e5307feb366a1Chris Dearman#undef ELF64_R_INFO
739918665a45095ad135576f005c0e5307feb366a1Chris Dearman#define ELF64_R_SYM(info)   (((info) >> 0) & 0xffffffff)
749918665a45095ad135576f005c0e5307feb366a1Chris Dearman#define ELF64_R_SSYM(info)  (((info) >> 32) & 0xff)
759918665a45095ad135576f005c0e5307feb366a1Chris Dearman#define ELF64_R_TYPE3(info) (((info) >> 40) & 0xff)
769918665a45095ad135576f005c0e5307feb366a1Chris Dearman#define ELF64_R_TYPE2(info) (((info) >> 48) & 0xff)
779918665a45095ad135576f005c0e5307feb366a1Chris Dearman#define ELF64_R_TYPE(info)  (((info) >> 56) & 0xff)
789918665a45095ad135576f005c0e5307feb366a1Chris Dearman#endif
799918665a45095ad135576f005c0e5307feb366a1Chris Dearman
801a6961650c82168864afe040dbdc05977db701dfElliott Hughes// Returns the address of the page containing address 'x'.
811a6961650c82168864afe040dbdc05977db701dfElliott Hughes#define PAGE_START(x)  ((x) & PAGE_MASK)
82c1bd559d5b0fdcc25db2b6ae2705914103b24699David 'Digit' Turner
831a6961650c82168864afe040dbdc05977db701dfElliott Hughes// Returns the offset of address 'x' in its page.
841a6961650c82168864afe040dbdc05977db701dfElliott Hughes#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
85c1bd559d5b0fdcc25db2b6ae2705914103b24699David 'Digit' Turner
861a6961650c82168864afe040dbdc05977db701dfElliott Hughes// Returns the address of the next page after address 'x', unless 'x' is
871a6961650c82168864afe040dbdc05977db701dfElliott Hughes// itself at the start of a page.
88c1bd559d5b0fdcc25db2b6ae2705914103b24699David 'Digit' Turner#define PAGE_END(x)    PAGE_START((x) + (PAGE_SIZE-1))
891dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
901dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define FLAG_LINKED     0x00000001
911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define FLAG_EXE        0x00000004 // The main executable
92468319ce4f3f7383d788b76c09cda2a405311f36Nick Kralevich#define FLAG_LINKER     0x00000010 // The linker itself
93ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov#define FLAG_GNU_HASH   0x00000040 // uses gnu hash
94d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov#define FLAG_NEW_SOINFO 0x40000000 // new soinfo format
951dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
96d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov#define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE)
97d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov
98618f1a36f8635fa0f2d60c621fbf79ead2c3f3deDmitriy Ivanov#define SOINFO_VERSION 2
990d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov
10069a5fb951d69689dedd83cb033ae3dcd0ef05b65Dmitriy Ivanov#if defined(__work_around_b_19059885__)
1011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define SOINFO_NAME_LEN 128
102aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov#endif
1031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
104ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughestypedef void (*linker_function_t)();
105ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes
1069918665a45095ad135576f005c0e5307feb366a1Chris Dearman// Android uses RELA for aarch64 and x86_64. mips64 still uses REL.
1079918665a45095ad135576f005c0e5307feb366a1Chris Dearman#if defined(__aarch64__) || defined(__x86_64__)
1084eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes#define USE_RELA 1
1094eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes#endif
1104eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes
111d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanovstruct soinfo;
112d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
113d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanovclass SoinfoListAllocator {
114ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov public:
115d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  static LinkedListEntry<soinfo>* alloc();
116d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  static void free(LinkedListEntry<soinfo>* entry);
117ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
118ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov private:
119d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  // unconstructable
120d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  DISALLOW_IMPLICIT_CONSTRUCTORS(SoinfoListAllocator);
121d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov};
122d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
123ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanovclass SymbolName {
124ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov public:
125ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  explicit SymbolName(const char* name)
126ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov      : name_(name), has_elf_hash_(false), has_gnu_hash_(false),
127ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov        elf_hash_(0), gnu_hash_(0) { }
128ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
129ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  const char* get_name() {
130ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov    return name_;
131ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  }
132ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
133ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  uint32_t elf_hash();
134ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  uint32_t gnu_hash();
135ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
136ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov private:
137ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  const char* name_;
138ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  bool has_elf_hash_;
139ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  bool has_gnu_hash_;
140ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  uint32_t elf_hash_;
141ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  uint32_t gnu_hash_;
142ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
143ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolName);
144ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov};
145ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
1462a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanovstruct version_info {
1472a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  version_info() : elf_hash(0), name(nullptr), target_si(nullptr) {}
1482a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
1492a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  uint32_t elf_hash;
1502a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  const char* name;
1512a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  const soinfo* target_si;
1522a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov};
1532a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
1542a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov// Class used construct version dependency graph.
1552a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanovclass VersionTracker {
1562a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov public:
1572a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  VersionTracker() = default;
1582a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool init(const soinfo* si_from);
1592a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
1602a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  const version_info* get_version_info(ElfW(Versym) source_symver) const;
1612a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov private:
1622a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool init_verneed(const soinfo* si_from);
1632a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool init_verdef(const soinfo* si_from);
1642a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  void add_version_info(size_t source_index, ElfW(Word) elf_hash,
1652a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov      const char* ver_name, const soinfo* target_si);
1662a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
1672a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  std::vector<version_info> version_infos;
1682a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
1692a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  DISALLOW_COPY_AND_ASSIGN(VersionTracker);
1702a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov};
1712a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
17218a206c81d9743481e364384affd43306911283dElliott Hughesstruct soinfo {
173ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes public:
174d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  typedef LinkedList<soinfo, SoinfoListAllocator> soinfo_list_t;
17569a5fb951d69689dedd83cb033ae3dcd0ef05b65Dmitriy Ivanov#if defined(__work_around_b_19059885__)
176aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov private:
177aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov  char old_name_[SOINFO_NAME_LEN];
178aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov#endif
179d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov public:
1800266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes  const ElfW(Phdr)* phdr;
181ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes  size_t phnum;
1820266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes  ElfW(Addr) entry;
1830266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes  ElfW(Addr) base;
1845ceb889ac9a36e74e4e00c34c57cbb58d73e228cWeiwu Chen  size_t size;
1851dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
18669a5fb951d69689dedd83cb033ae3dcd0ef05b65Dmitriy Ivanov#if defined(__work_around_b_19059885__)
187ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes  uint32_t unused1;  // DO NOT USE, maintained for compatibility.
188c620059479c47a78d57086d73726c9adc2f337adElliott Hughes#endif
18938bccb271f121fc06eaa0d8fbd3c982bc44c36b7Nick Kralevich
1900266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes  ElfW(Dyn)* dynamic;
1911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
19269a5fb951d69689dedd83cb033ae3dcd0ef05b65Dmitriy Ivanov#if defined(__work_around_b_19059885__)
193ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes  uint32_t unused2; // DO NOT USE, maintained for compatibility
194ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes  uint32_t unused3; // DO NOT USE, maintained for compatibility
195c620059479c47a78d57086d73726c9adc2f337adElliott Hughes#endif
1961dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
197d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes  soinfo* next;
1986cdeb5234d7f4523fe9d83974f265d80f10512a6Dmitriy Ivanov private:
199ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  uint32_t flags_;
200ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov
201047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  const char* strtab_;
202047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Sym)* symtab_;
2031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
204047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t nbucket_;
205047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t nchain_;
206047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t* bucket_;
207047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t* chain_;
2081dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
2099918665a45095ad135576f005c0e5307feb366a1Chris Dearman#if defined(__mips__) || !defined(__LP64__)
2109918665a45095ad135576f005c0e5307feb366a1Chris Dearman  // This is only used by mips and mips64, but needs to be here for
2114eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes  // all 32-bit architectures to preserve binary compatibility.
212047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Addr)** plt_got_;
2134eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes#endif
2144eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes
2154eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes#if defined(USE_RELA)
216047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Rela)* plt_rela_;
217047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t plt_rela_count_;
218c00f2cb587630d5e954c7f548749f1e3170b3cb1Elliott Hughes
219047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Rela)* rela_;
220047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t rela_count_;
221c00f2cb587630d5e954c7f548749f1e3170b3cb1Elliott Hughes#else
222047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Rel)* plt_rel_;
223047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t plt_rel_count_;
2241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
225047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Rel)* rel_;
226047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t rel_count_;
227c00f2cb587630d5e954c7f548749f1e3170b3cb1Elliott Hughes#endif
2281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
229047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  linker_function_t* preinit_array_;
230047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t preinit_array_count_;
2311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
232047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  linker_function_t* init_array_;
233047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t init_array_count_;
234047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  linker_function_t* fini_array_;
235047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t fini_array_count_;
2361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
237047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  linker_function_t init_func_;
238047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  linker_function_t fini_func_;
2391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
2404eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5aElliott Hughes#if defined(__arm__)
241ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov public:
242d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes  // ARM EABI section used for stack unwinding.
2431b20dafdbe65e43b9f4c95057e8482380833ea91Dmitriy Ivanov  uint32_t* ARM_exidx;
244ca0c11bd823f37f03cc8067cb182876827d5275aElliott Hughes  size_t ARM_exidx_count;
245889409168322920ab6cddeb93f506c983d8b5878Dmitriy Ivanov private:
246ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov#elif defined(__mips__)
247047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t mips_symtabno_;
248047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t mips_local_gotno_;
249047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t mips_gotsym_;
250dc145b510640202a60b0dfaef9d56cd8fc1c05a9Dmitriy Ivanov  bool mips_relocate_got(const VersionTracker& version_tracker,
251dc145b510640202a60b0dfaef9d56cd8fc1c05a9Dmitriy Ivanov                         const soinfo_list_t& global_group,
252dc145b510640202a60b0dfaef9d56cd8fc1c05a9Dmitriy Ivanov                         const soinfo_list_t& local_group);
253fb3357e2eb9366d87a8da96e1a0744c9b1f22af9Dimitry Ivanov
2541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif
255ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  size_t ref_count_;
256047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov public:
2573a9c5d66dc8d41272f51482b713717af7049697eElliott Hughes  link_map link_map_head;
258e83c56dfbb6a9a61f0f18031620322af97e80162Evgeniy Stepanov
259d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes  bool constructors_called;
2609ec0f03a0d0b17bbb94ac0b9fef6add28a133c3aNick Kralevich
261d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes  // When you read a virtual address from the ELF file, add this
262d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes  // value to get the corresponding address in the process' address space.
2630266ae5f884d72da58f33a072e865ba131234a5eElliott Hughes  ElfW(Addr) load_bias;
2645ae44f302b7d1d19f25c4c6f125e32dc369961d9Ard Biesheuvel
26556be6ed9e4ac99fdd920090ee89c57e3cf55e885Dimitry Ivanov#if !defined(__LP64__)
26656be6ed9e4ac99fdd920090ee89c57e3cf55e885Dimitry Ivanov  bool has_text_relocations;
267e4d792adb8d6f9228b9ac9dc1ad7f43b271f085fElliott Hughes#endif
26896bc37f2e1093416a432135265fd7a4db6c3df17Dmitriy Ivanov  bool has_DT_SYMBOLIC;
2690d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov
270047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov public:
27107e5bc152d8a3ad4c50808bb86f3c0f2c5e2f514Dmitriy Ivanov  soinfo(const char* name, const struct stat* file_stat, off64_t file_offset, int rtld_flags);
2720d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov
273047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  void call_constructors();
274047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  void call_destructors();
275047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  void call_pre_init_constructors();
276047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  bool prelink_image();
27720d89cb5b0d5eb7546a8fe8da44bbd91564dbddaDmitriy Ivanov  bool link_image(const soinfo_list_t& global_group, const soinfo_list_t& local_group,
27820d89cb5b0d5eb7546a8fe8da44bbd91564dbddaDmitriy Ivanov                  const android_dlextinfo* extinfo);
279d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes
280d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  void add_child(soinfo* child);
281d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  void remove_all_links();
282d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
283d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov  ino_t get_st_ino() const;
284d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov  dev_t get_st_dev() const;
285d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov  off64_t get_file_offset() const;
286c5a13efa9bc4264be0a9a9e37c00633af01584edBrigid Smith
287d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov  uint32_t get_rtld_flags() const;
288d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov  uint32_t get_dt_flags_1() const;
289d225a5e65223b375a63548c4b780f04d8f3d7b60Dmitriy Ivanov  void set_dt_flags_1(uint32_t dt_flags_1);
290e8ba50fe0d51fbefee1a8f5bb62bf51d841512c8Dmitriy Ivanov
291d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  soinfo_list_t& get_children();
2922a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  const soinfo_list_t& get_children() const;
2932a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
29414669a939d113214a4a20b9318fca0992d5453f0Dmitriy Ivanov  soinfo_list_t& get_parents();
295d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
2962a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool find_symbol_by_name(SymbolName& symbol_name,
2972a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov                           const version_info* vi,
2982a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov                           const ElfW(Sym)** symbol) const;
2992a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
300ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  ElfW(Sym)* find_symbol_by_address(const void* addr);
3012a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  ElfW(Addr) resolve_symbol_address(const ElfW(Sym)* s) const;
3029aea164457c269c475592da36b4655d45f55c7bcDmitriy Ivanov
3036cdeb5234d7f4523fe9d83974f265d80f10512a6Dmitriy Ivanov  const char* get_string(ElfW(Word) index) const;
3041b20dafdbe65e43b9f4c95057e8482380833ea91Dmitriy Ivanov  bool can_unload() const;
305ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  bool is_gnu_hash() const;
3066cdeb5234d7f4523fe9d83974f265d80f10512a6Dmitriy Ivanov
307aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov  bool inline has_min_version(uint32_t min_version __unused) const {
30869a5fb951d69689dedd83cb033ae3dcd0ef05b65Dmitriy Ivanov#if defined(__work_around_b_19059885__)
309ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov    return (flags_ & FLAG_NEW_SOINFO) != 0 && version_ >= min_version;
310aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov#else
311aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov    return true;
312aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov#endif
3130d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov  }
3141b20dafdbe65e43b9f4c95057e8482380833ea91Dmitriy Ivanov
315ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  bool is_linked() const;
316ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  bool is_main_executable() const;
317ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov
318ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  void set_linked();
319ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  void set_linker_flag();
320ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  void set_main_executable();
321ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov
322ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  void increment_ref_count();
323ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  size_t decrement_ref_count();
324ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov
325ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  soinfo* get_local_group_root() const;
326ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov
327aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov  const char* get_soname() const;
328aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov  const char* get_realpath() const;
3292a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  const ElfW(Versym)* get_versym(size_t n) const;
3302a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  ElfW(Addr) get_verneed_ptr() const;
3312a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  size_t get_verneed_cnt() const;
3322a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  ElfW(Addr) get_verdef_ptr() const;
3332a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  size_t get_verdef_cnt() const;
3342a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
3352a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool find_verdef_version_index(const version_info* vi, ElfW(Versym)* versym) const;
336618f1a36f8635fa0f2d60c621fbf79ead2c3f3deDmitriy Ivanov
33704f7e3e955ba7de5f449c995e667659319dc1cceDmitriy Ivanov  uint32_t get_target_sdk_version() const;
33804f7e3e955ba7de5f449c995e667659319dc1cceDmitriy Ivanov
339d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes private:
3402a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool elf_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
341ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  ElfW(Sym)* elf_addr_lookup(const void* addr);
3422a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  bool gnu_lookup(SymbolName& symbol_name, const version_info* vi, uint32_t* symbol_index) const;
343ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  ElfW(Sym)* gnu_addr_lookup(const void* addr);
344ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
345114bd835a756f782c119ed7f76b6cacb2cd723dcDmitriy Ivanov  bool lookup_version_info(const VersionTracker& version_tracker, ElfW(Word) sym,
346114bd835a756f782c119ed7f76b6cacb2cd723dcDmitriy Ivanov                           const char* sym_name, const version_info** vi);
347114bd835a756f782c119ed7f76b6cacb2cd723dcDmitriy Ivanov
348047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  void call_array(const char* array_name, linker_function_t* functions, size_t count, bool reverse);
349047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  void call_function(const char* function_name, linker_function_t function);
350fa26eee77685e8dee7986e62a7d263003f5bd25aDmitriy Ivanov  template<typename ElfRelIteratorT>
351f92a417d07d70730fda15d7d98d36968a6a7362eDmitriy Ivanov  bool relocate(const VersionTracker& version_tracker, ElfRelIteratorT&& rel_iterator,
352f92a417d07d70730fda15d7d98d36968a6a7362eDmitriy Ivanov                const soinfo_list_t& global_group, const soinfo_list_t& local_group);
353d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
354d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov private:
355d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  // This part of the structure is only available
356d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  // when FLAG_NEW_SOINFO is set in this->flags.
357047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t version_;
358c5a13efa9bc4264be0a9a9e37c00633af01584edBrigid Smith
3590d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov  // version >= 0
360047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  dev_t st_dev_;
361047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ino_t st_ino_;
362d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
363d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov  // dependency graph
364047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  soinfo_list_t children_;
365047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  soinfo_list_t parents_;
366d59e50063ad708509f3ad83350be33f5612c4f54Dmitriy Ivanov
3670d15094287fe0f288d9c258953143fc1998b6b5aDmitriy Ivanov  // version >= 1
368047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  off64_t file_offset_;
369047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t rtld_flags_;
370047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t dt_flags_1_;
371047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  size_t strtab_size_;
3726cdeb5234d7f4523fe9d83974f265d80f10512a6Dmitriy Ivanov
373ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov  // version >= 2
3743597b8055da090ef3f1ee662e96dcb952bba2c30Dmitriy Ivanov
3753597b8055da090ef3f1ee662e96dcb952bba2c30Dmitriy Ivanov  size_t gnu_nbucket_;
3763597b8055da090ef3f1ee662e96dcb952bba2c30Dmitriy Ivanov  uint32_t* gnu_bucket_;
3773597b8055da090ef3f1ee662e96dcb952bba2c30Dmitriy Ivanov  uint32_t* gnu_chain_;
378047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t gnu_maskwords_;
379047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  uint32_t gnu_shift2_;
380047b5934b5f1c62502fc9262ce634529c6cc1420Dmitriy Ivanov  ElfW(Addr)* gnu_bloom_filter_;
381ec18ce06f2d007be40ad6f043058f5a4c7236573Dmitriy Ivanov
382ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov  soinfo* local_group_root_;
383ab972b9adf8789a9e1b03129cd7f0c22e6bba117Dmitriy Ivanov
38418a6956b76a071097fc658c5fe13ef010e31864aDmitriy Ivanov  uint8_t* android_relocs_;
38518a6956b76a071097fc658c5fe13ef010e31864aDmitriy Ivanov  size_t android_relocs_size_;
38618a6956b76a071097fc658c5fe13ef010e31864aDmitriy Ivanov
387618f1a36f8635fa0f2d60c621fbf79ead2c3f3deDmitriy Ivanov  const char* soname_;
388aae859cc3ca127d890e853cbf12b731e05624a22Dmitriy Ivanov  std::string realpath_;
389618f1a36f8635fa0f2d60c621fbf79ead2c3f3deDmitriy Ivanov
3902a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  const ElfW(Versym)* versym_;
3912a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
3922a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  ElfW(Addr) verdef_ptr_;
3932a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  size_t verdef_cnt_;
3942a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
3952a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  ElfW(Addr) verneed_ptr_;
3962a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov  size_t verneed_cnt_;
3972a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov
39804f7e3e955ba7de5f449c995e667659319dc1cceDmitriy Ivanov  uint32_t target_sdk_version_;
39904f7e3e955ba7de5f449c995e667659319dc1cceDmitriy Ivanov
4006cdeb5234d7f4523fe9d83974f265d80f10512a6Dmitriy Ivanov  friend soinfo* get_libdl_info();
4011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project};
4021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
4032a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanovbool soinfo_do_lookup(soinfo* si_from, const char* name, const version_info* vi,
4042a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov                      soinfo** si_found_in, const soinfo::soinfo_list_t& global_group,
4052a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanov                      const soinfo::soinfo_list_t& local_group, const ElfW(Sym)** symbol);
406114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov
407114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanovenum RelocationKind {
408114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov  kRelocAbsolute = 0,
409114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov  kRelocRelative,
410114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov  kRelocCopy,
411114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov  kRelocSymbol,
412114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov  kRelocMax
413114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov};
414114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov
415114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanovvoid count_relocation(RelocationKind kind);
416114ff69f1753c7fe4d749f8fb0c082b80e0d43f4Dmitriy Ivanov
4171b20dafdbe65e43b9f4c95057e8482380833ea91Dmitriy Ivanovsoinfo* get_libdl_info();
4181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
419a4aafd156068ee174012f28cd894dbecf0e4ab90Elliott Hughesvoid do_android_get_LD_LIBRARY_PATH(char*, size_t);
420cade4c36e7c9c62db3f476a0f9cfc329bac9acb7Elliott Hughesvoid do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
4211a586293400d0e1d73e6eb82f7dfe9d2d9ed3c4bElliott Hughessoinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo);
422b648a8a57ee42533a5bf127225a252f73ca2cbbcDmitriy Ivanovvoid do_dlclose(soinfo* si);
42316084168111cd7d2ac8a6b92e6fa6df5696928a5David 'Digit' Turner
424f7d5bf334dc4bc5b7399d4c8268e1b0bf676548fDmitriy Ivanovint do_dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data);
425f7d5bf334dc4bc5b7399d4c8268e1b0bf676548fDmitriy Ivanov
4262a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanovconst ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* caller, void* handle);
427d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughessoinfo* find_containing_library(const void* addr);
4281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
4292a815361448d01b0f4e575f507ce31913214c536Dmitriy Ivanovconst ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name);
430d23736e4f228e46304b7cbc674a1d0094d73e0f5Elliott Hughes
431d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81Brian Carlstromvoid debuggerd_init();
4321728b2396591853345507a063ed6075dfd251706Elliott Hughesextern "C" abort_msg_t* g_abort_message;
43318a206c81d9743481e364384affd43306911283dElliott Hughesextern "C" void notify_gdb_of_libraries();
4344688279db5dcc4004941e7f133c4a1c3617d842cElliott Hughes
435650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hugheschar* linker_get_error_buffer();
436650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughessize_t linker_get_error_buffer_size();
437650be4e584eeab3591b9e273bfd6d169eea60853Elliott Hughes
438d8ead18145cba98fdc7256f9a0e69b8c1c90cd1cDmitriy Ivanovvoid set_application_target_sdk_version(uint32_t target);
439d8ead18145cba98fdc7256f9a0e69b8c1c90cd1cDmitriy Ivanovuint32_t get_application_target_sdk_version();
440d8ead18145cba98fdc7256f9a0e69b8c1c90cd1cDmitriy Ivanov
4411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif
442