am 83b637fa: Merge "Replace NULL with nullptr"
				
					
				
			* commit '83b637fa28e072aa73691b5ddc588293f06cb54b': Replace NULL with nullptr
This commit is contained in:
		@@ -162,12 +162,12 @@ static void log_signal_summary(int signum, const siginfo_t* info) {
 | 
				
			|||||||
    thread_name[MAX_TASK_NAME_LEN] = 0;
 | 
					    thread_name[MAX_TASK_NAME_LEN] = 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // "info" will be NULL if the siginfo_t information was not available.
 | 
					  // "info" will be null if the siginfo_t information was not available.
 | 
				
			||||||
  // Many signals don't have an address or a code.
 | 
					  // Many signals don't have an address or a code.
 | 
				
			||||||
  char code_desc[32]; // ", code -6"
 | 
					  char code_desc[32]; // ", code -6"
 | 
				
			||||||
  char addr_desc[32]; // ", fault addr 0x1234"
 | 
					  char addr_desc[32]; // ", fault addr 0x1234"
 | 
				
			||||||
  addr_desc[0] = code_desc[0] = 0;
 | 
					  addr_desc[0] = code_desc[0] = 0;
 | 
				
			||||||
  if (info != NULL) {
 | 
					  if (info != nullptr) {
 | 
				
			||||||
    // For a rethrown signal, this si_code will be right and the one debuggerd shows will
 | 
					    // For a rethrown signal, this si_code will be right and the one debuggerd shows will
 | 
				
			||||||
    // always be SI_TKILL.
 | 
					    // always be SI_TKILL.
 | 
				
			||||||
    __libc_format_buffer(code_desc, sizeof(code_desc), ", code %d", info->si_code);
 | 
					    __libc_format_buffer(code_desc, sizeof(code_desc), ", code %d", info->si_code);
 | 
				
			||||||
@@ -198,7 +198,7 @@ static bool have_siginfo(int signum) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  bool result = (old_action.sa_flags & SA_SIGINFO) != 0;
 | 
					  bool result = (old_action.sa_flags & SA_SIGINFO) != 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (sigaction(signum, &old_action, NULL) == -1) {
 | 
					  if (sigaction(signum, &old_action, nullptr) == -1) {
 | 
				
			||||||
    __libc_format_log(ANDROID_LOG_WARN, "libc", "Restore failed in test for SA_SIGINFO: %s",
 | 
					    __libc_format_log(ANDROID_LOG_WARN, "libc", "Restore failed in test for SA_SIGINFO: %s",
 | 
				
			||||||
                      strerror(errno));
 | 
					                      strerror(errno));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -230,7 +230,7 @@ static void send_debuggerd_packet(siginfo_t* info) {
 | 
				
			|||||||
  msg.action = DEBUGGER_ACTION_CRASH;
 | 
					  msg.action = DEBUGGER_ACTION_CRASH;
 | 
				
			||||||
  msg.tid = gettid();
 | 
					  msg.tid = gettid();
 | 
				
			||||||
  msg.abort_msg_address = reinterpret_cast<uintptr_t>(g_abort_message);
 | 
					  msg.abort_msg_address = reinterpret_cast<uintptr_t>(g_abort_message);
 | 
				
			||||||
  msg.original_si_code = (info != NULL) ? info->si_code : 0;
 | 
					  msg.original_si_code = (info != nullptr) ? info->si_code : 0;
 | 
				
			||||||
  int ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg)));
 | 
					  int ret = TEMP_FAILURE_RETRY(write(s, &msg, sizeof(msg)));
 | 
				
			||||||
  if (ret == sizeof(msg)) {
 | 
					  if (ret == sizeof(msg)) {
 | 
				
			||||||
    char debuggerd_ack;
 | 
					    char debuggerd_ack;
 | 
				
			||||||
@@ -255,7 +255,7 @@ static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void*)
 | 
				
			|||||||
  // It's possible somebody cleared the SA_SIGINFO flag, which would mean
 | 
					  // It's possible somebody cleared the SA_SIGINFO flag, which would mean
 | 
				
			||||||
  // our "info" arg holds an undefined value.
 | 
					  // our "info" arg holds an undefined value.
 | 
				
			||||||
  if (!have_siginfo(signal_number)) {
 | 
					  if (!have_siginfo(signal_number)) {
 | 
				
			||||||
    info = NULL;
 | 
					    info = nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  log_signal_summary(signal_number, info);
 | 
					  log_signal_summary(signal_number, info);
 | 
				
			||||||
@@ -296,14 +296,14 @@ __LIBC_HIDDEN__ void debuggerd_init() {
 | 
				
			|||||||
  // Use the alternate signal stack if available so we can catch stack overflows.
 | 
					  // Use the alternate signal stack if available so we can catch stack overflows.
 | 
				
			||||||
  action.sa_flags |= SA_ONSTACK;
 | 
					  action.sa_flags |= SA_ONSTACK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  sigaction(SIGABRT, &action, NULL);
 | 
					  sigaction(SIGABRT, &action, nullptr);
 | 
				
			||||||
  sigaction(SIGBUS, &action, NULL);
 | 
					  sigaction(SIGBUS, &action, nullptr);
 | 
				
			||||||
  sigaction(SIGFPE, &action, NULL);
 | 
					  sigaction(SIGFPE, &action, nullptr);
 | 
				
			||||||
  sigaction(SIGILL, &action, NULL);
 | 
					  sigaction(SIGILL, &action, nullptr);
 | 
				
			||||||
  sigaction(SIGPIPE, &action, NULL);
 | 
					  sigaction(SIGPIPE, &action, nullptr);
 | 
				
			||||||
  sigaction(SIGSEGV, &action, NULL);
 | 
					  sigaction(SIGSEGV, &action, nullptr);
 | 
				
			||||||
#if defined(SIGSTKFLT)
 | 
					#if defined(SIGSTKFLT)
 | 
				
			||||||
  sigaction(SIGSTKFLT, &action, NULL);
 | 
					  sigaction(SIGSTKFLT, &action, nullptr);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  sigaction(SIGTRAP, &action, NULL);
 | 
					  sigaction(SIGTRAP, &action, nullptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@ static const char* __bionic_set_dlerror(char* new_value) {
 | 
				
			|||||||
static void __bionic_format_dlerror(const char* msg, const char* detail) {
 | 
					static void __bionic_format_dlerror(const char* msg, const char* detail) {
 | 
				
			||||||
  char* buffer = __get_thread()->dlerror_buffer;
 | 
					  char* buffer = __get_thread()->dlerror_buffer;
 | 
				
			||||||
  strlcpy(buffer, msg, __BIONIC_DLERROR_BUFFER_SIZE);
 | 
					  strlcpy(buffer, msg, __BIONIC_DLERROR_BUFFER_SIZE);
 | 
				
			||||||
  if (detail != NULL) {
 | 
					  if (detail != nullptr) {
 | 
				
			||||||
    strlcat(buffer, ": ", __BIONIC_DLERROR_BUFFER_SIZE);
 | 
					    strlcat(buffer, ": ", __BIONIC_DLERROR_BUFFER_SIZE);
 | 
				
			||||||
    strlcat(buffer, detail, __BIONIC_DLERROR_BUFFER_SIZE);
 | 
					    strlcat(buffer, detail, __BIONIC_DLERROR_BUFFER_SIZE);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -51,7 +51,7 @@ static void __bionic_format_dlerror(const char* msg, const char* detail) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char* dlerror() {
 | 
					const char* dlerror() {
 | 
				
			||||||
  const char* old_value = __bionic_set_dlerror(NULL);
 | 
					  const char* old_value = __bionic_set_dlerror(nullptr);
 | 
				
			||||||
  return old_value;
 | 
					  return old_value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -68,9 +68,9 @@ void android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
 | 
				
			|||||||
static void* dlopen_ext(const char* filename, int flags, const android_dlextinfo* extinfo) {
 | 
					static void* dlopen_ext(const char* filename, int flags, const android_dlextinfo* extinfo) {
 | 
				
			||||||
  ScopedPthreadMutexLocker locker(&g_dl_mutex);
 | 
					  ScopedPthreadMutexLocker locker(&g_dl_mutex);
 | 
				
			||||||
  soinfo* result = do_dlopen(filename, flags, extinfo);
 | 
					  soinfo* result = do_dlopen(filename, flags, extinfo);
 | 
				
			||||||
  if (result == NULL) {
 | 
					  if (result == nullptr) {
 | 
				
			||||||
    __bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
 | 
					    __bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return result;
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -80,33 +80,33 @@ void* android_dlopen_ext(const char* filename, int flags, const android_dlextinf
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void* dlopen(const char* filename, int flags) {
 | 
					void* dlopen(const char* filename, int flags) {
 | 
				
			||||||
  return dlopen_ext(filename, flags, NULL);
 | 
					  return dlopen_ext(filename, flags, nullptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void* dlsym(void* handle, const char* symbol) {
 | 
					void* dlsym(void* handle, const char* symbol) {
 | 
				
			||||||
  ScopedPthreadMutexLocker locker(&g_dl_mutex);
 | 
					  ScopedPthreadMutexLocker locker(&g_dl_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(__LP64__)
 | 
					#if !defined(__LP64__)
 | 
				
			||||||
  if (handle == NULL) {
 | 
					  if (handle == nullptr) {
 | 
				
			||||||
    __bionic_format_dlerror("dlsym library handle is null", NULL);
 | 
					    __bionic_format_dlerror("dlsym library handle is null", nullptr);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (symbol == NULL) {
 | 
					  if (symbol == nullptr) {
 | 
				
			||||||
    __bionic_format_dlerror("dlsym symbol name is null", NULL);
 | 
					    __bionic_format_dlerror("dlsym symbol name is null", nullptr);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  soinfo* found = NULL;
 | 
					  soinfo* found = nullptr;
 | 
				
			||||||
  ElfW(Sym)* sym = NULL;
 | 
					  ElfW(Sym)* sym = nullptr;
 | 
				
			||||||
  if (handle == RTLD_DEFAULT) {
 | 
					  if (handle == RTLD_DEFAULT) {
 | 
				
			||||||
    sym = dlsym_linear_lookup(symbol, &found, NULL);
 | 
					    sym = dlsym_linear_lookup(symbol, &found, nullptr);
 | 
				
			||||||
  } else if (handle == RTLD_NEXT) {
 | 
					  } else if (handle == RTLD_NEXT) {
 | 
				
			||||||
    void* caller_addr = __builtin_return_address(0);
 | 
					    void* caller_addr = __builtin_return_address(0);
 | 
				
			||||||
    soinfo* si = find_containing_library(caller_addr);
 | 
					    soinfo* si = find_containing_library(caller_addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sym = NULL;
 | 
					    sym = nullptr;
 | 
				
			||||||
    if (si && si->next) {
 | 
					    if (si && si->next) {
 | 
				
			||||||
      sym = dlsym_linear_lookup(symbol, &found, si->next);
 | 
					      sym = dlsym_linear_lookup(symbol, &found, si->next);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -114,7 +114,7 @@ void* dlsym(void* handle, const char* symbol) {
 | 
				
			|||||||
    sym = dlsym_handle_lookup(reinterpret_cast<soinfo*>(handle), &found, symbol);
 | 
					    sym = dlsym_handle_lookup(reinterpret_cast<soinfo*>(handle), &found, symbol);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (sym != NULL) {
 | 
					  if (sym != nullptr) {
 | 
				
			||||||
    unsigned bind = ELF_ST_BIND(sym->st_info);
 | 
					    unsigned bind = ELF_ST_BIND(sym->st_info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((bind == STB_GLOBAL || bind == STB_WEAK) && sym->st_shndx != 0) {
 | 
					    if ((bind == STB_GLOBAL || bind == STB_WEAK) && sym->st_shndx != 0) {
 | 
				
			||||||
@@ -122,10 +122,10 @@ void* dlsym(void* handle, const char* symbol) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    __bionic_format_dlerror("symbol found but not global", symbol);
 | 
					    __bionic_format_dlerror("symbol found but not global", symbol);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    __bionic_format_dlerror("undefined symbol", symbol);
 | 
					    __bionic_format_dlerror("undefined symbol", symbol);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,7 +134,7 @@ int dladdr(const void* addr, Dl_info* info) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Determine if this address can be found in any library currently mapped.
 | 
					  // Determine if this address can be found in any library currently mapped.
 | 
				
			||||||
  soinfo* si = find_containing_library(addr);
 | 
					  soinfo* si = find_containing_library(addr);
 | 
				
			||||||
  if (si == NULL) {
 | 
					  if (si == nullptr) {
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -146,7 +146,7 @@ int dladdr(const void* addr, Dl_info* info) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Determine if any symbol in the library contains the specified address.
 | 
					  // Determine if any symbol in the library contains the specified address.
 | 
				
			||||||
  ElfW(Sym)* sym = dladdr_find_symbol(si, addr);
 | 
					  ElfW(Sym)* sym = dladdr_find_symbol(si, addr);
 | 
				
			||||||
  if (sym != NULL) {
 | 
					  if (sym != nullptr) {
 | 
				
			||||||
    info->dli_sname = si->strtab + sym->st_name;
 | 
					    info->dli_sname = si->strtab + sym->st_name;
 | 
				
			||||||
    info->dli_saddr = reinterpret_cast<void*>(si->load_bias + sym->st_value);
 | 
					    info->dli_saddr = reinterpret_cast<void*>(si->load_bias + sym->st_value);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -164,7 +164,7 @@ int dlclose(void* handle) {
 | 
				
			|||||||
// name_offset: starting index of the name in libdl_info.strtab
 | 
					// name_offset: starting index of the name in libdl_info.strtab
 | 
				
			||||||
#define ELF32_SYM_INITIALIZER(name_offset, value, shndx) \
 | 
					#define ELF32_SYM_INITIALIZER(name_offset, value, shndx) \
 | 
				
			||||||
    { name_offset, \
 | 
					    { name_offset, \
 | 
				
			||||||
      reinterpret_cast<Elf32_Addr>(reinterpret_cast<void*>(value)), \
 | 
					      reinterpret_cast<Elf32_Addr>(value), \
 | 
				
			||||||
      /* st_size */ 0, \
 | 
					      /* st_size */ 0, \
 | 
				
			||||||
      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
 | 
					      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
 | 
				
			||||||
      /* st_other */ 0, \
 | 
					      /* st_other */ 0, \
 | 
				
			||||||
@@ -176,7 +176,7 @@ int dlclose(void* handle) {
 | 
				
			|||||||
      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
 | 
					      (shndx == 0) ? 0 : (STB_GLOBAL << 4), \
 | 
				
			||||||
      /* st_other */ 0, \
 | 
					      /* st_other */ 0, \
 | 
				
			||||||
      shndx, \
 | 
					      shndx, \
 | 
				
			||||||
      reinterpret_cast<Elf64_Addr>(reinterpret_cast<void*>(value)), \
 | 
					      reinterpret_cast<Elf64_Addr>(value), \
 | 
				
			||||||
      /* st_size */ 0, \
 | 
					      /* st_size */ 0, \
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -199,7 +199,7 @@ static ElfW(Sym) g_libdl_symtab[] = {
 | 
				
			|||||||
  // This is actually the STH_UNDEF entry. Technically, it's
 | 
					  // This is actually the STH_UNDEF entry. Technically, it's
 | 
				
			||||||
  // supposed to have st_name == 0, but instead, it points to an index
 | 
					  // supposed to have st_name == 0, but instead, it points to an index
 | 
				
			||||||
  // in the strtab with a \0 to make iterating through the symtab easier.
 | 
					  // in the strtab with a \0 to make iterating through the symtab easier.
 | 
				
			||||||
  ELFW(SYM_INITIALIZER)(sizeof(ANDROID_LIBDL_STRTAB) - 1, NULL, 0),
 | 
					  ELFW(SYM_INITIALIZER)(sizeof(ANDROID_LIBDL_STRTAB) - 1, nullptr, 0),
 | 
				
			||||||
  ELFW(SYM_INITIALIZER)(  0, &dlopen, 1),
 | 
					  ELFW(SYM_INITIALIZER)(  0, &dlopen, 1),
 | 
				
			||||||
  ELFW(SYM_INITIALIZER)(  7, &dlclose, 1),
 | 
					  ELFW(SYM_INITIALIZER)(  7, &dlclose, 1),
 | 
				
			||||||
  ELFW(SYM_INITIALIZER)( 15, &dlsym, 1),
 | 
					  ELFW(SYM_INITIALIZER)( 15, &dlsym, 1),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -97,7 +97,7 @@ static const char* const kDefaultLdPaths[] = {
 | 
				
			|||||||
  "/vendor/lib",
 | 
					  "/vendor/lib",
 | 
				
			||||||
  "/system/lib",
 | 
					  "/system/lib",
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  NULL
 | 
					  nullptr
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define LDPATH_BUFSIZE (LDPATH_MAX*64)
 | 
					#define LDPATH_BUFSIZE (LDPATH_MAX*64)
 | 
				
			||||||
@@ -116,7 +116,7 @@ static soinfo* g_ld_preloads[LDPRELOAD_MAX + 1];
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
__LIBC_HIDDEN__ int g_ld_debug_verbosity;
 | 
					__LIBC_HIDDEN__ int g_ld_debug_verbosity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__LIBC_HIDDEN__ abort_msg_t* g_abort_message = NULL; // For debuggerd.
 | 
					__LIBC_HIDDEN__ abort_msg_t* g_abort_message = nullptr; // For debuggerd.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum RelocationKind {
 | 
					enum RelocationKind {
 | 
				
			||||||
    kRelocAbsolute = 0,
 | 
					    kRelocAbsolute = 0,
 | 
				
			||||||
@@ -189,7 +189,7 @@ size_t linker_get_error_buffer_size() {
 | 
				
			|||||||
extern "C" void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity();
 | 
					extern "C" void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static pthread_mutex_t g__r_debug_mutex = PTHREAD_MUTEX_INITIALIZER;
 | 
					static pthread_mutex_t g__r_debug_mutex = PTHREAD_MUTEX_INITIALIZER;
 | 
				
			||||||
static r_debug _r_debug = {1, NULL, reinterpret_cast<uintptr_t>(&rtld_db_dlactivity), r_debug::RT_CONSISTENT, 0};
 | 
					static r_debug _r_debug = {1, nullptr, reinterpret_cast<uintptr_t>(&rtld_db_dlactivity), r_debug::RT_CONSISTENT, 0};
 | 
				
			||||||
static link_map* r_debug_tail = 0;
 | 
					static link_map* r_debug_tail = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void insert_soinfo_into_debug_map(soinfo* info) {
 | 
					static void insert_soinfo_into_debug_map(soinfo* info) {
 | 
				
			||||||
@@ -288,7 +288,7 @@ static void protect_data(int protection) {
 | 
				
			|||||||
static soinfo* soinfo_alloc(const char* name, struct stat* file_stat) {
 | 
					static soinfo* soinfo_alloc(const char* name, struct stat* file_stat) {
 | 
				
			||||||
  if (strlen(name) >= SOINFO_NAME_LEN) {
 | 
					  if (strlen(name) >= SOINFO_NAME_LEN) {
 | 
				
			||||||
    DL_ERR("library name \"%s\" too long", name);
 | 
					    DL_ERR("library name \"%s\" too long", name);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  soinfo* si = new (g_soinfo_allocator.alloc()) soinfo(name, file_stat);
 | 
					  soinfo* si = new (g_soinfo_allocator.alloc()) soinfo(name, file_stat);
 | 
				
			||||||
@@ -301,7 +301,7 @@ static soinfo* soinfo_alloc(const char* name, struct stat* file_stat) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void soinfo_free(soinfo* si) {
 | 
					static void soinfo_free(soinfo* si) {
 | 
				
			||||||
    if (si == NULL) {
 | 
					    if (si == nullptr) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -309,16 +309,16 @@ static void soinfo_free(soinfo* si) {
 | 
				
			|||||||
      munmap(reinterpret_cast<void*>(si->base), si->size);
 | 
					      munmap(reinterpret_cast<void*>(si->base), si->size);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    soinfo *prev = NULL, *trav;
 | 
					    soinfo *prev = nullptr, *trav;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TRACE("name %s: freeing soinfo @ %p", si->name, si);
 | 
					    TRACE("name %s: freeing soinfo @ %p", si->name, si);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (trav = solist; trav != NULL; trav = trav->next) {
 | 
					    for (trav = solist; trav != nullptr; trav = trav->next) {
 | 
				
			||||||
        if (trav == si)
 | 
					        if (trav == si)
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        prev = trav;
 | 
					        prev = trav;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (trav == NULL) {
 | 
					    if (trav == nullptr) {
 | 
				
			||||||
        /* si was not in solist */
 | 
					        /* si was not in solist */
 | 
				
			||||||
        DL_ERR("name \"%s\" is not in solist!", si->name);
 | 
					        DL_ERR("name \"%s\" is not in solist!", si->name);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
@@ -327,7 +327,7 @@ static void soinfo_free(soinfo* si) {
 | 
				
			|||||||
    // clear links to/from si
 | 
					    // clear links to/from si
 | 
				
			||||||
    si->remove_all_links();
 | 
					    si->remove_all_links();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* prev will never be NULL, because the first entry in solist is
 | 
					    /* prev will never be null, because the first entry in solist is
 | 
				
			||||||
       always the static libdl_info.
 | 
					       always the static libdl_info.
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
    prev->next = si->next;
 | 
					    prev->next = si->next;
 | 
				
			||||||
@@ -341,7 +341,7 @@ static void soinfo_free(soinfo* si) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void parse_path(const char* path, const char* delimiters,
 | 
					static void parse_path(const char* path, const char* delimiters,
 | 
				
			||||||
                       const char** array, char* buf, size_t buf_size, size_t max_count) {
 | 
					                       const char** array, char* buf, size_t buf_size, size_t max_count) {
 | 
				
			||||||
  if (path == NULL) {
 | 
					  if (path == nullptr) {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -358,9 +358,9 @@ static void parse_path(const char* path, const char* delimiters,
 | 
				
			|||||||
  // Forget the last path if we had to truncate; this occurs if the 2nd to
 | 
					  // Forget the last path if we had to truncate; this occurs if the 2nd to
 | 
				
			||||||
  // last char isn't '\0' (i.e. wasn't originally a delimiter).
 | 
					  // last char isn't '\0' (i.e. wasn't originally a delimiter).
 | 
				
			||||||
  if (i > 0 && len >= buf_size && buf[buf_size - 2] != '\0') {
 | 
					  if (i > 0 && len >= buf_size && buf[buf_size - 2] != '\0') {
 | 
				
			||||||
    array[i - 1] = NULL;
 | 
					    array[i - 1] = nullptr;
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    array[i] = NULL;
 | 
					    array[i] = nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -396,7 +396,7 @@ _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    *pcount = 0;
 | 
					    *pcount = 0;
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -405,7 +405,7 @@ _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
 | 
				
			|||||||
 * loaded libraries. gcc_eh does the rest. */
 | 
					 * loaded libraries. gcc_eh does the rest. */
 | 
				
			||||||
int dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data) {
 | 
					int dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data) {
 | 
				
			||||||
    int rv = 0;
 | 
					    int rv = 0;
 | 
				
			||||||
    for (soinfo* si = solist; si != NULL; si = si->next) {
 | 
					    for (soinfo* si = solist; si != nullptr; si = si->next) {
 | 
				
			||||||
        dl_phdr_info dl_info;
 | 
					        dl_phdr_info dl_info;
 | 
				
			||||||
        dl_info.dlpi_addr = si->link_map_head.l_addr;
 | 
					        dl_info.dlpi_addr = si->link_map_head.l_addr;
 | 
				
			||||||
        dl_info.dlpi_name = si->link_map_head.l_name;
 | 
					        dl_info.dlpi_name = si->link_map_head.l_name;
 | 
				
			||||||
@@ -454,7 +454,7 @@ static ElfW(Sym)* soinfo_elf_lookup(soinfo* si, unsigned hash, const char* name)
 | 
				
			|||||||
             name, si->name, reinterpret_cast<void*>(si->base), hash, hash % si->nbucket);
 | 
					             name, si->name, reinterpret_cast<void*>(si->base), hash, hash % si->nbucket);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return NULL;
 | 
					  return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
soinfo::soinfo(const char* name, const struct stat* file_stat) {
 | 
					soinfo::soinfo(const char* name, const struct stat* file_stat) {
 | 
				
			||||||
@@ -464,7 +464,7 @@ soinfo::soinfo(const char* name, const struct stat* file_stat) {
 | 
				
			|||||||
  flags = FLAG_NEW_SOINFO;
 | 
					  flags = FLAG_NEW_SOINFO;
 | 
				
			||||||
  version = SOINFO_VERSION;
 | 
					  version = SOINFO_VERSION;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (file_stat != NULL) {
 | 
					  if (file_stat != nullptr) {
 | 
				
			||||||
    set_st_dev(file_stat->st_dev);
 | 
					    set_st_dev(file_stat->st_dev);
 | 
				
			||||||
    set_st_ino(file_stat->st_ino);
 | 
					    set_st_ino(file_stat->st_ino);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -511,9 +511,9 @@ static unsigned elfhash(const char* _name) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, soinfo* needed[]) {
 | 
					static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, soinfo* needed[]) {
 | 
				
			||||||
    unsigned elf_hash = elfhash(name);
 | 
					    unsigned elf_hash = elfhash(name);
 | 
				
			||||||
    ElfW(Sym)* s = NULL;
 | 
					    ElfW(Sym)* s = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (si != NULL && somain != NULL) {
 | 
					    if (si != nullptr && somain != nullptr) {
 | 
				
			||||||
        /*
 | 
					        /*
 | 
				
			||||||
         * Local scope is executable scope. Just start looking into it right away
 | 
					         * Local scope is executable scope. Just start looking into it right away
 | 
				
			||||||
         * for the shortcut.
 | 
					         * for the shortcut.
 | 
				
			||||||
@@ -521,7 +521,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (si == somain) {
 | 
					        if (si == somain) {
 | 
				
			||||||
            s = soinfo_elf_lookup(si, elf_hash, name);
 | 
					            s = soinfo_elf_lookup(si, elf_hash, name);
 | 
				
			||||||
            if (s != NULL) {
 | 
					            if (s != nullptr) {
 | 
				
			||||||
                *lsi = si;
 | 
					                *lsi = si;
 | 
				
			||||||
                goto done;
 | 
					                goto done;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -538,7 +538,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
 | 
				
			|||||||
                DEBUG("%s: looking up %s in executable %s",
 | 
					                DEBUG("%s: looking up %s in executable %s",
 | 
				
			||||||
                      si->name, name, somain->name);
 | 
					                      si->name, name, somain->name);
 | 
				
			||||||
                s = soinfo_elf_lookup(somain, elf_hash, name);
 | 
					                s = soinfo_elf_lookup(somain, elf_hash, name);
 | 
				
			||||||
                if (s != NULL) {
 | 
					                if (s != nullptr) {
 | 
				
			||||||
                    *lsi = somain;
 | 
					                    *lsi = somain;
 | 
				
			||||||
                    goto done;
 | 
					                    goto done;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -555,7 +555,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
 | 
				
			|||||||
             * Here we return the first definition found for simplicity.  */
 | 
					             * Here we return the first definition found for simplicity.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            s = soinfo_elf_lookup(si, elf_hash, name);
 | 
					            s = soinfo_elf_lookup(si, elf_hash, name);
 | 
				
			||||||
            if (s != NULL) {
 | 
					            if (s != nullptr) {
 | 
				
			||||||
                *lsi = si;
 | 
					                *lsi = si;
 | 
				
			||||||
                goto done;
 | 
					                goto done;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -569,7 +569,7 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
 | 
				
			|||||||
                DEBUG("%s: looking up %s in executable %s after local scope",
 | 
					                DEBUG("%s: looking up %s in executable %s after local scope",
 | 
				
			||||||
                      si->name, name, somain->name);
 | 
					                      si->name, name, somain->name);
 | 
				
			||||||
                s = soinfo_elf_lookup(somain, elf_hash, name);
 | 
					                s = soinfo_elf_lookup(somain, elf_hash, name);
 | 
				
			||||||
                if (s != NULL) {
 | 
					                if (s != nullptr) {
 | 
				
			||||||
                    *lsi = somain;
 | 
					                    *lsi = somain;
 | 
				
			||||||
                    goto done;
 | 
					                    goto done;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -578,26 +578,26 @@ static ElfW(Sym)* soinfo_do_lookup(soinfo* si, const char* name, soinfo** lsi, s
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Next, look for it in the preloads list */
 | 
					    /* Next, look for it in the preloads list */
 | 
				
			||||||
    for (int i = 0; g_ld_preloads[i] != NULL; i++) {
 | 
					    for (int i = 0; g_ld_preloads[i] != nullptr; i++) {
 | 
				
			||||||
        s = soinfo_elf_lookup(g_ld_preloads[i], elf_hash, name);
 | 
					        s = soinfo_elf_lookup(g_ld_preloads[i], elf_hash, name);
 | 
				
			||||||
        if (s != NULL) {
 | 
					        if (s != nullptr) {
 | 
				
			||||||
            *lsi = g_ld_preloads[i];
 | 
					            *lsi = g_ld_preloads[i];
 | 
				
			||||||
            goto done;
 | 
					            goto done;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i = 0; needed[i] != NULL; i++) {
 | 
					    for (int i = 0; needed[i] != nullptr; i++) {
 | 
				
			||||||
        DEBUG("%s: looking up %s in %s",
 | 
					        DEBUG("%s: looking up %s in %s",
 | 
				
			||||||
              si->name, name, needed[i]->name);
 | 
					              si->name, name, needed[i]->name);
 | 
				
			||||||
        s = soinfo_elf_lookup(needed[i], elf_hash, name);
 | 
					        s = soinfo_elf_lookup(needed[i], elf_hash, name);
 | 
				
			||||||
        if (s != NULL) {
 | 
					        if (s != nullptr) {
 | 
				
			||||||
            *lsi = needed[i];
 | 
					            *lsi = needed[i];
 | 
				
			||||||
            goto done;
 | 
					            goto done;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
done:
 | 
					done:
 | 
				
			||||||
    if (s != NULL) {
 | 
					    if (s != nullptr) {
 | 
				
			||||||
        TRACE_TYPE(LOOKUP, "si %s sym %s s->st_value = %p, "
 | 
					        TRACE_TYPE(LOOKUP, "si %s sym %s s->st_value = %p, "
 | 
				
			||||||
                   "found in %s, base = %p, load bias = %p",
 | 
					                   "found in %s, base = %p, load bias = %p",
 | 
				
			||||||
                   si->name, name, reinterpret_cast<void*>(s->st_value),
 | 
					                   si->name, name, reinterpret_cast<void*>(s->st_value),
 | 
				
			||||||
@@ -606,7 +606,7 @@ done:
 | 
				
			|||||||
        return s;
 | 
					        return s;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Another soinfo list allocator to use in dlsym. We don't reuse
 | 
					// Another soinfo list allocator to use in dlsym. We don't reuse
 | 
				
			||||||
@@ -659,20 +659,20 @@ ElfW(Sym)* dlsym_handle_lookup(soinfo* si, soinfo** found, const char* name) {
 | 
				
			|||||||
ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start) {
 | 
					ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start) {
 | 
				
			||||||
  unsigned elf_hash = elfhash(name);
 | 
					  unsigned elf_hash = elfhash(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (start == NULL) {
 | 
					  if (start == nullptr) {
 | 
				
			||||||
    start = solist;
 | 
					    start = solist;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ElfW(Sym)* s = NULL;
 | 
					  ElfW(Sym)* s = nullptr;
 | 
				
			||||||
  for (soinfo* si = start; (s == NULL) && (si != NULL); si = si->next) {
 | 
					  for (soinfo* si = start; (s == nullptr) && (si != nullptr); si = si->next) {
 | 
				
			||||||
    s = soinfo_elf_lookup(si, elf_hash, name);
 | 
					    s = soinfo_elf_lookup(si, elf_hash, name);
 | 
				
			||||||
    if (s != NULL) {
 | 
					    if (s != nullptr) {
 | 
				
			||||||
      *found = si;
 | 
					      *found = si;
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (s != NULL) {
 | 
					  if (s != nullptr) {
 | 
				
			||||||
    TRACE_TYPE(LOOKUP, "%s s->st_value = %p, found->base = %p",
 | 
					    TRACE_TYPE(LOOKUP, "%s s->st_value = %p, found->base = %p",
 | 
				
			||||||
               name, reinterpret_cast<void*>(s->st_value), reinterpret_cast<void*>((*found)->base));
 | 
					               name, reinterpret_cast<void*>(s->st_value), reinterpret_cast<void*>((*found)->base));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -682,12 +682,12 @@ ElfW(Sym)* dlsym_linear_lookup(const char* name, soinfo** found, soinfo* start)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
soinfo* find_containing_library(const void* p) {
 | 
					soinfo* find_containing_library(const void* p) {
 | 
				
			||||||
  ElfW(Addr) address = reinterpret_cast<ElfW(Addr)>(p);
 | 
					  ElfW(Addr) address = reinterpret_cast<ElfW(Addr)>(p);
 | 
				
			||||||
  for (soinfo* si = solist; si != NULL; si = si->next) {
 | 
					  for (soinfo* si = solist; si != nullptr; si = si->next) {
 | 
				
			||||||
    if (address >= si->base && address - si->base < si->size) {
 | 
					    if (address >= si->base && address - si->base < si->size) {
 | 
				
			||||||
      return si;
 | 
					      return si;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return NULL;
 | 
					  return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ElfW(Sym)* dladdr_find_symbol(soinfo* si, const void* addr) {
 | 
					ElfW(Sym)* dladdr_find_symbol(soinfo* si, const void* addr) {
 | 
				
			||||||
@@ -704,12 +704,12 @@ ElfW(Sym)* dladdr_find_symbol(soinfo* si, const void* addr) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return NULL;
 | 
					  return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int open_library_on_path(const char* name, const char* const paths[]) {
 | 
					static int open_library_on_path(const char* name, const char* const paths[]) {
 | 
				
			||||||
  char buf[512];
 | 
					  char buf[512];
 | 
				
			||||||
  for (size_t i = 0; paths[i] != NULL; ++i) {
 | 
					  for (size_t i = 0; paths[i] != nullptr; ++i) {
 | 
				
			||||||
    int n = __libc_format_buffer(buf, sizeof(buf), "%s/%s", paths[i], name);
 | 
					    int n = __libc_format_buffer(buf, sizeof(buf), "%s/%s", paths[i], name);
 | 
				
			||||||
    if (n < 0 || n >= static_cast<int>(sizeof(buf))) {
 | 
					    if (n < 0 || n >= static_cast<int>(sizeof(buf))) {
 | 
				
			||||||
      PRINT("Warning: ignoring very long library path: %s/%s", paths[i], name);
 | 
					      PRINT("Warning: ignoring very long library path: %s/%s", paths[i], name);
 | 
				
			||||||
@@ -727,7 +727,7 @@ static int open_library(const char* name) {
 | 
				
			|||||||
  TRACE("[ opening %s ]", name);
 | 
					  TRACE("[ opening %s ]", name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // If the name contains a slash, we should attempt to open it directly and not search the paths.
 | 
					  // If the name contains a slash, we should attempt to open it directly and not search the paths.
 | 
				
			||||||
  if (strchr(name, '/') != NULL) {
 | 
					  if (strchr(name, '/') != nullptr) {
 | 
				
			||||||
    int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CLOEXEC));
 | 
					    int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CLOEXEC));
 | 
				
			||||||
    if (fd != -1) {
 | 
					    if (fd != -1) {
 | 
				
			||||||
      return fd;
 | 
					      return fd;
 | 
				
			||||||
@@ -750,14 +750,14 @@ static soinfo* load_library(const char* name, int dlflags, const android_dlextin
 | 
				
			|||||||
    int fd = -1;
 | 
					    int fd = -1;
 | 
				
			||||||
    ScopedFd file_guard(-1);
 | 
					    ScopedFd file_guard(-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (extinfo != NULL && (extinfo->flags & ANDROID_DLEXT_USE_LIBRARY_FD) != 0) {
 | 
					    if (extinfo != nullptr && (extinfo->flags & ANDROID_DLEXT_USE_LIBRARY_FD) != 0) {
 | 
				
			||||||
      fd = extinfo->library_fd;
 | 
					      fd = extinfo->library_fd;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      // Open the file.
 | 
					      // Open the file.
 | 
				
			||||||
      fd = open_library(name);
 | 
					      fd = open_library(name);
 | 
				
			||||||
      if (fd == -1) {
 | 
					      if (fd == -1) {
 | 
				
			||||||
        DL_ERR("library \"%s\" not found", name);
 | 
					        DL_ERR("library \"%s\" not found", name);
 | 
				
			||||||
        return NULL;
 | 
					        return nullptr;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      file_guard.reset(fd);
 | 
					      file_guard.reset(fd);
 | 
				
			||||||
@@ -768,12 +768,12 @@ static soinfo* load_library(const char* name, int dlflags, const android_dlextin
 | 
				
			|||||||
    struct stat file_stat;
 | 
					    struct stat file_stat;
 | 
				
			||||||
    if (TEMP_FAILURE_RETRY(fstat(fd, &file_stat)) != 0) {
 | 
					    if (TEMP_FAILURE_RETRY(fstat(fd, &file_stat)) != 0) {
 | 
				
			||||||
      DL_ERR("unable to stat file for the library %s: %s", name, strerror(errno));
 | 
					      DL_ERR("unable to stat file for the library %s: %s", name, strerror(errno));
 | 
				
			||||||
      return NULL;
 | 
					      return nullptr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check for symlink and other situations where
 | 
					    // Check for symlink and other situations where
 | 
				
			||||||
    // file can have different names.
 | 
					    // file can have different names.
 | 
				
			||||||
    for (soinfo* si = solist; si != NULL; si = si->next) {
 | 
					    for (soinfo* si = solist; si != nullptr; si = si->next) {
 | 
				
			||||||
      if (si->get_st_dev() != 0 &&
 | 
					      if (si->get_st_dev() != 0 &&
 | 
				
			||||||
          si->get_st_ino() != 0 &&
 | 
					          si->get_st_ino() != 0 &&
 | 
				
			||||||
          si->get_st_dev() == file_stat.st_dev &&
 | 
					          si->get_st_dev() == file_stat.st_dev &&
 | 
				
			||||||
@@ -784,17 +784,17 @@ static soinfo* load_library(const char* name, int dlflags, const android_dlextin
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((dlflags & RTLD_NOLOAD) != 0) {
 | 
					    if ((dlflags & RTLD_NOLOAD) != 0) {
 | 
				
			||||||
      return NULL;
 | 
					      return nullptr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Read the ELF header and load the segments.
 | 
					    // Read the ELF header and load the segments.
 | 
				
			||||||
    if (!elf_reader.Load(extinfo)) {
 | 
					    if (!elf_reader.Load(extinfo)) {
 | 
				
			||||||
        return NULL;
 | 
					        return nullptr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    soinfo* si = soinfo_alloc(SEARCH_NAME(name), &file_stat);
 | 
					    soinfo* si = soinfo_alloc(SEARCH_NAME(name), &file_stat);
 | 
				
			||||||
    if (si == NULL) {
 | 
					    if (si == nullptr) {
 | 
				
			||||||
        return NULL;
 | 
					        return nullptr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    si->base = elf_reader.load_start();
 | 
					    si->base = elf_reader.load_start();
 | 
				
			||||||
    si->size = elf_reader.load_size();
 | 
					    si->size = elf_reader.load_size();
 | 
				
			||||||
@@ -809,7 +809,7 @@ static soinfo* load_library(const char* name, int dlflags, const android_dlextin
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (!soinfo_link_image(si, extinfo)) {
 | 
					    if (!soinfo_link_image(si, extinfo)) {
 | 
				
			||||||
      soinfo_free(si);
 | 
					      soinfo_free(si);
 | 
				
			||||||
      return NULL;
 | 
					      return nullptr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return si;
 | 
					    return si;
 | 
				
			||||||
@@ -817,16 +817,16 @@ static soinfo* load_library(const char* name, int dlflags, const android_dlextin
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static soinfo *find_loaded_library_by_name(const char* name) {
 | 
					static soinfo *find_loaded_library_by_name(const char* name) {
 | 
				
			||||||
  const char* search_name = SEARCH_NAME(name);
 | 
					  const char* search_name = SEARCH_NAME(name);
 | 
				
			||||||
  for (soinfo* si = solist; si != NULL; si = si->next) {
 | 
					  for (soinfo* si = solist; si != nullptr; si = si->next) {
 | 
				
			||||||
    if (!strcmp(search_name, si->name)) {
 | 
					    if (!strcmp(search_name, si->name)) {
 | 
				
			||||||
      return si;
 | 
					      return si;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return NULL;
 | 
					  return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static soinfo* find_library_internal(const char* name, int dlflags, const android_dlextinfo* extinfo) {
 | 
					static soinfo* find_library_internal(const char* name, int dlflags, const android_dlextinfo* extinfo) {
 | 
				
			||||||
  if (name == NULL) {
 | 
					  if (name == nullptr) {
 | 
				
			||||||
    return somain;
 | 
					    return somain;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -834,14 +834,14 @@ static soinfo* find_library_internal(const char* name, int dlflags, const androi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Library might still be loaded, the accurate detection
 | 
					  // Library might still be loaded, the accurate detection
 | 
				
			||||||
  // of this fact is done by load_library
 | 
					  // of this fact is done by load_library
 | 
				
			||||||
  if (si == NULL) {
 | 
					  if (si == nullptr) {
 | 
				
			||||||
    TRACE("[ '%s' has not been found by name.  Trying harder...]", name);
 | 
					    TRACE("[ '%s' has not been found by name.  Trying harder...]", name);
 | 
				
			||||||
    si = load_library(name, dlflags, extinfo);
 | 
					    si = load_library(name, dlflags, extinfo);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (si != NULL && (si->flags & FLAG_LINKED) == 0) {
 | 
					  if (si != nullptr && (si->flags & FLAG_LINKED) == 0) {
 | 
				
			||||||
    DL_ERR("recursive link to \"%s\"", si->name);
 | 
					    DL_ERR("recursive link to \"%s\"", si->name);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return si;
 | 
					  return si;
 | 
				
			||||||
@@ -849,7 +849,7 @@ static soinfo* find_library_internal(const char* name, int dlflags, const androi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static soinfo* find_library(const char* name, int dlflags, const android_dlextinfo* extinfo) {
 | 
					static soinfo* find_library(const char* name, int dlflags, const android_dlextinfo* extinfo) {
 | 
				
			||||||
  soinfo* si = find_library_internal(name, dlflags, extinfo);
 | 
					  soinfo* si = find_library_internal(name, dlflags, extinfo);
 | 
				
			||||||
  if (si != NULL) {
 | 
					  if (si != nullptr) {
 | 
				
			||||||
    si->ref_count++;
 | 
					    si->ref_count++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return si;
 | 
					  return si;
 | 
				
			||||||
@@ -870,8 +870,8 @@ static void soinfo_unload(soinfo* si) {
 | 
				
			|||||||
        if (d->d_tag == DT_NEEDED) {
 | 
					        if (d->d_tag == DT_NEEDED) {
 | 
				
			||||||
          const char* library_name = si->strtab + d->d_un.d_val;
 | 
					          const char* library_name = si->strtab + d->d_un.d_val;
 | 
				
			||||||
          TRACE("%s needs to unload %s", si->name, library_name);
 | 
					          TRACE("%s needs to unload %s", si->name, library_name);
 | 
				
			||||||
          soinfo* needed = find_library(library_name, RTLD_NOLOAD, NULL);
 | 
					          soinfo* needed = find_library(library_name, RTLD_NOLOAD, nullptr);
 | 
				
			||||||
          if (needed != NULL) {
 | 
					          if (needed != nullptr) {
 | 
				
			||||||
            soinfo_unload(needed);
 | 
					            soinfo_unload(needed);
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            // Not found: for example if symlink was deleted between dlopen and dlclose
 | 
					            // Not found: for example if symlink was deleted between dlopen and dlclose
 | 
				
			||||||
@@ -918,15 +918,15 @@ void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
 | 
				
			|||||||
soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo) {
 | 
					soinfo* do_dlopen(const char* name, int flags, const android_dlextinfo* extinfo) {
 | 
				
			||||||
  if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL|RTLD_NOLOAD)) != 0) {
 | 
					  if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL|RTLD_NOLOAD)) != 0) {
 | 
				
			||||||
    DL_ERR("invalid flags to dlopen: %x", flags);
 | 
					    DL_ERR("invalid flags to dlopen: %x", flags);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (extinfo != NULL && ((extinfo->flags & ~(ANDROID_DLEXT_VALID_FLAG_BITS)) != 0)) {
 | 
					  if (extinfo != nullptr && ((extinfo->flags & ~(ANDROID_DLEXT_VALID_FLAG_BITS)) != 0)) {
 | 
				
			||||||
    DL_ERR("invalid extended flags to android_dlopen_ext: %" PRIx64, extinfo->flags);
 | 
					    DL_ERR("invalid extended flags to android_dlopen_ext: %" PRIx64, extinfo->flags);
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  protect_data(PROT_READ | PROT_WRITE);
 | 
					  protect_data(PROT_READ | PROT_WRITE);
 | 
				
			||||||
  soinfo* si = find_library(name, flags, extinfo);
 | 
					  soinfo* si = find_library(name, flags, extinfo);
 | 
				
			||||||
  if (si != NULL) {
 | 
					  if (si != nullptr) {
 | 
				
			||||||
    si->CallConstructors();
 | 
					    si->CallConstructors();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  protect_data(PROT_READ);
 | 
					  protect_data(PROT_READ);
 | 
				
			||||||
@@ -949,7 +949,7 @@ static void soinfo_ifunc_relocate(soinfo* si, ElfW(Rel)* rel, unsigned count, so
 | 
				
			|||||||
    unsigned sym = ELFW(R_SYM)(rel->r_info);
 | 
					    unsigned sym = ELFW(R_SYM)(rel->r_info);
 | 
				
			||||||
    ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rel->r_offset + si->load_bias);
 | 
					    ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rel->r_offset + si->load_bias);
 | 
				
			||||||
    ElfW(Addr) sym_addr = 0;
 | 
					    ElfW(Addr) sym_addr = 0;
 | 
				
			||||||
    const char* sym_name = NULL;
 | 
					    const char* sym_name = nullptr;
 | 
				
			||||||
    sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
					    sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
				
			||||||
    s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
					    s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -972,7 +972,7 @@ static void soinfo_ifunc_relocate(soinfo* si, ElfW(Rela)* rela, unsigned count,
 | 
				
			|||||||
    unsigned sym = ELFW(R_SYM)(rela->r_info);
 | 
					    unsigned sym = ELFW(R_SYM)(rela->r_info);
 | 
				
			||||||
    ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rela->r_offset + si->load_bias);
 | 
					    ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rela->r_offset + si->load_bias);
 | 
				
			||||||
    ElfW(Addr) sym_addr = 0;
 | 
					    ElfW(Addr) sym_addr = 0;
 | 
				
			||||||
    const char* sym_name = NULL;
 | 
					    const char* sym_name = nullptr;
 | 
				
			||||||
    sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
					    sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
				
			||||||
    s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
					    s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -996,7 +996,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rela)* rela, unsigned count, soinfo*
 | 
				
			|||||||
    unsigned sym = ELFW(R_SYM)(rela->r_info);
 | 
					    unsigned sym = ELFW(R_SYM)(rela->r_info);
 | 
				
			||||||
    ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rela->r_offset + si->load_bias);
 | 
					    ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rela->r_offset + si->load_bias);
 | 
				
			||||||
    ElfW(Addr) sym_addr = 0;
 | 
					    ElfW(Addr) sym_addr = 0;
 | 
				
			||||||
    const char* sym_name = NULL;
 | 
					    const char* sym_name = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DEBUG("Processing '%s' relocation at index %zd", si->name, idx);
 | 
					    DEBUG("Processing '%s' relocation at index %zd", si->name, idx);
 | 
				
			||||||
    if (type == 0) { // R_*_NONE
 | 
					    if (type == 0) { // R_*_NONE
 | 
				
			||||||
@@ -1005,7 +1005,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rela)* rela, unsigned count, soinfo*
 | 
				
			|||||||
    if (sym != 0) {
 | 
					    if (sym != 0) {
 | 
				
			||||||
      sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
					      sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
				
			||||||
      s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
					      s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
				
			||||||
      if (s == NULL) {
 | 
					      if (s == nullptr) {
 | 
				
			||||||
        // We only allow an undefined symbol if this is a weak reference...
 | 
					        // We only allow an undefined symbol if this is a weak reference...
 | 
				
			||||||
        s = &si->symtab[sym];
 | 
					        s = &si->symtab[sym];
 | 
				
			||||||
        if (ELF_ST_BIND(s->st_info) != STB_WEAK) {
 | 
					        if (ELF_ST_BIND(s->st_info) != STB_WEAK) {
 | 
				
			||||||
@@ -1061,7 +1061,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rela)* rela, unsigned count, soinfo*
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      count_relocation(kRelocSymbol);
 | 
					      count_relocation(kRelocSymbol);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      s = NULL;
 | 
					      s = nullptr;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (type) {
 | 
					    switch (type) {
 | 
				
			||||||
@@ -1265,7 +1265,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rel)* rel, unsigned count, soinfo* n
 | 
				
			|||||||
        unsigned sym = ELFW(R_SYM)(rel->r_info);
 | 
					        unsigned sym = ELFW(R_SYM)(rel->r_info);
 | 
				
			||||||
        ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rel->r_offset + si->load_bias);
 | 
					        ElfW(Addr) reloc = static_cast<ElfW(Addr)>(rel->r_offset + si->load_bias);
 | 
				
			||||||
        ElfW(Addr) sym_addr = 0;
 | 
					        ElfW(Addr) sym_addr = 0;
 | 
				
			||||||
        const char* sym_name = NULL;
 | 
					        const char* sym_name = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DEBUG("Processing '%s' relocation at index %zd", si->name, idx);
 | 
					        DEBUG("Processing '%s' relocation at index %zd", si->name, idx);
 | 
				
			||||||
        if (type == 0) { // R_*_NONE
 | 
					        if (type == 0) { // R_*_NONE
 | 
				
			||||||
@@ -1274,7 +1274,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rel)* rel, unsigned count, soinfo* n
 | 
				
			|||||||
        if (sym != 0) {
 | 
					        if (sym != 0) {
 | 
				
			||||||
            sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
					            sym_name = reinterpret_cast<const char*>(si->strtab + si->symtab[sym].st_name);
 | 
				
			||||||
            s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
					            s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
				
			||||||
            if (s == NULL) {
 | 
					            if (s == nullptr) {
 | 
				
			||||||
                // We only allow an undefined symbol if this is a weak reference...
 | 
					                // We only allow an undefined symbol if this is a weak reference...
 | 
				
			||||||
                s = &si->symtab[sym];
 | 
					                s = &si->symtab[sym];
 | 
				
			||||||
                if (ELF_ST_BIND(s->st_info) != STB_WEAK) {
 | 
					                if (ELF_ST_BIND(s->st_info) != STB_WEAK) {
 | 
				
			||||||
@@ -1333,7 +1333,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rel)* rel, unsigned count, soinfo* n
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            count_relocation(kRelocSymbol);
 | 
					            count_relocation(kRelocSymbol);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            s = NULL;
 | 
					            s = nullptr;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (type) {
 | 
					        switch (type) {
 | 
				
			||||||
@@ -1458,7 +1458,7 @@ static int soinfo_relocate(soinfo* si, ElfW(Rel)* rel, unsigned count, soinfo* n
 | 
				
			|||||||
#if defined(__mips__)
 | 
					#if defined(__mips__)
 | 
				
			||||||
static bool mips_relocate_got(soinfo* si, soinfo* needed[]) {
 | 
					static bool mips_relocate_got(soinfo* si, soinfo* needed[]) {
 | 
				
			||||||
    ElfW(Addr)** got = si->plt_got;
 | 
					    ElfW(Addr)** got = si->plt_got;
 | 
				
			||||||
    if (got == NULL) {
 | 
					    if (got == nullptr) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    unsigned local_gotno = si->mips_local_gotno;
 | 
					    unsigned local_gotno = si->mips_local_gotno;
 | 
				
			||||||
@@ -1490,7 +1490,7 @@ static bool mips_relocate_got(soinfo* si, soinfo* needed[]) {
 | 
				
			|||||||
        const char* sym_name = si->strtab + sym->st_name;
 | 
					        const char* sym_name = si->strtab + sym->st_name;
 | 
				
			||||||
        soinfo* lsi;
 | 
					        soinfo* lsi;
 | 
				
			||||||
        ElfW(Sym)* s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
					        ElfW(Sym)* s = soinfo_do_lookup(si, sym_name, &lsi, needed);
 | 
				
			||||||
        if (s == NULL) {
 | 
					        if (s == nullptr) {
 | 
				
			||||||
            // We only allow an undefined symbol if this is a weak reference.
 | 
					            // We only allow an undefined symbol if this is a weak reference.
 | 
				
			||||||
            s = &symtab[g];
 | 
					            s = &symtab[g];
 | 
				
			||||||
            if (ELF_ST_BIND(s->st_info) != STB_WEAK) {
 | 
					            if (ELF_ST_BIND(s->st_info) != STB_WEAK) {
 | 
				
			||||||
@@ -1510,7 +1510,7 @@ static bool mips_relocate_got(soinfo* si, soinfo* needed[]) {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void soinfo::CallArray(const char* array_name __unused, linker_function_t* functions, size_t count, bool reverse) {
 | 
					void soinfo::CallArray(const char* array_name __unused, linker_function_t* functions, size_t count, bool reverse) {
 | 
				
			||||||
  if (functions == NULL) {
 | 
					  if (functions == nullptr) {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1529,7 +1529,7 @@ void soinfo::CallArray(const char* array_name __unused, linker_function_t* funct
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void soinfo::CallFunction(const char* function_name __unused, linker_function_t function) {
 | 
					void soinfo::CallFunction(const char* function_name __unused, linker_function_t function) {
 | 
				
			||||||
  if (function == NULL || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
 | 
					  if (function == nullptr || reinterpret_cast<uintptr_t>(function) == static_cast<uintptr_t>(-1)) {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1565,7 +1565,7 @@ void soinfo::CallConstructors() {
 | 
				
			|||||||
  //    out above, the libc constructor will be called again (recursively!).
 | 
					  //    out above, the libc constructor will be called again (recursively!).
 | 
				
			||||||
  constructors_called = true;
 | 
					  constructors_called = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if ((flags & FLAG_EXE) == 0 && preinit_array != NULL) {
 | 
					  if ((flags & FLAG_EXE) == 0 && preinit_array != nullptr) {
 | 
				
			||||||
    // The GNU dynamic linker silently ignores these, but we warn the developer.
 | 
					    // The GNU dynamic linker silently ignores these, but we warn the developer.
 | 
				
			||||||
    PRINT("\"%s\": ignoring %zd-entry DT_PREINIT_ARRAY in shared library!",
 | 
					    PRINT("\"%s\": ignoring %zd-entry DT_PREINIT_ARRAY in shared library!",
 | 
				
			||||||
          name, preinit_array_count);
 | 
					          name, preinit_array_count);
 | 
				
			||||||
@@ -1761,7 +1761,7 @@ static bool soinfo_link_image(soinfo* si, const android_dlextinfo* extinfo) {
 | 
				
			|||||||
    ElfW(Word) dynamic_flags;
 | 
					    ElfW(Word) dynamic_flags;
 | 
				
			||||||
    phdr_table_get_dynamic_section(phdr, phnum, base, &si->dynamic,
 | 
					    phdr_table_get_dynamic_section(phdr, phnum, base, &si->dynamic,
 | 
				
			||||||
                                   &dynamic_count, &dynamic_flags);
 | 
					                                   &dynamic_count, &dynamic_flags);
 | 
				
			||||||
    if (si->dynamic == NULL) {
 | 
					    if (si->dynamic == nullptr) {
 | 
				
			||||||
        if (!relocating_linker) {
 | 
					        if (!relocating_linker) {
 | 
				
			||||||
            DL_ERR("missing PT_DYNAMIC in \"%s\"", si->name);
 | 
					            DL_ERR("missing PT_DYNAMIC in \"%s\"", si->name);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -1979,9 +1979,9 @@ static bool soinfo_link_image(soinfo* si, const android_dlextinfo* extinfo) {
 | 
				
			|||||||
    if (si->flags & FLAG_EXE) {
 | 
					    if (si->flags & FLAG_EXE) {
 | 
				
			||||||
        memset(g_ld_preloads, 0, sizeof(g_ld_preloads));
 | 
					        memset(g_ld_preloads, 0, sizeof(g_ld_preloads));
 | 
				
			||||||
        size_t preload_count = 0;
 | 
					        size_t preload_count = 0;
 | 
				
			||||||
        for (size_t i = 0; g_ld_preload_names[i] != NULL; i++) {
 | 
					        for (size_t i = 0; g_ld_preload_names[i] != nullptr; i++) {
 | 
				
			||||||
            soinfo* lsi = find_library(g_ld_preload_names[i], 0, NULL);
 | 
					            soinfo* lsi = find_library(g_ld_preload_names[i], 0, nullptr);
 | 
				
			||||||
            if (lsi != NULL) {
 | 
					            if (lsi != nullptr) {
 | 
				
			||||||
                g_ld_preloads[preload_count++] = lsi;
 | 
					                g_ld_preloads[preload_count++] = lsi;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                // As with glibc, failure to load an LD_PRELOAD library is just a warning.
 | 
					                // As with glibc, failure to load an LD_PRELOAD library is just a warning.
 | 
				
			||||||
@@ -1998,8 +1998,8 @@ static bool soinfo_link_image(soinfo* si, const android_dlextinfo* extinfo) {
 | 
				
			|||||||
        if (d->d_tag == DT_NEEDED) {
 | 
					        if (d->d_tag == DT_NEEDED) {
 | 
				
			||||||
            const char* library_name = si->strtab + d->d_un.d_val;
 | 
					            const char* library_name = si->strtab + d->d_un.d_val;
 | 
				
			||||||
            DEBUG("%s needs %s", si->name, library_name);
 | 
					            DEBUG("%s needs %s", si->name, library_name);
 | 
				
			||||||
            soinfo* lsi = find_library(library_name, 0, NULL);
 | 
					            soinfo* lsi = find_library(library_name, 0, nullptr);
 | 
				
			||||||
            if (lsi == NULL) {
 | 
					            if (lsi == nullptr) {
 | 
				
			||||||
                strlcpy(tmp_err_buf, linker_get_error_buffer(), sizeof(tmp_err_buf));
 | 
					                strlcpy(tmp_err_buf, linker_get_error_buffer(), sizeof(tmp_err_buf));
 | 
				
			||||||
                DL_ERR("could not load library \"%s\" needed by \"%s\"; caused by %s",
 | 
					                DL_ERR("could not load library \"%s\" needed by \"%s\"; caused by %s",
 | 
				
			||||||
                       library_name, si->name, tmp_err_buf);
 | 
					                       library_name, si->name, tmp_err_buf);
 | 
				
			||||||
@@ -2010,7 +2010,7 @@ static bool soinfo_link_image(soinfo* si, const android_dlextinfo* extinfo) {
 | 
				
			|||||||
            *pneeded++ = lsi;
 | 
					            *pneeded++ = lsi;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    *pneeded = NULL;
 | 
					    *pneeded = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(__LP64__)
 | 
					#if !defined(__LP64__)
 | 
				
			||||||
    if (si->has_text_relocations) {
 | 
					    if (si->has_text_relocations) {
 | 
				
			||||||
@@ -2027,26 +2027,26 @@ static bool soinfo_link_image(soinfo* si, const android_dlextinfo* extinfo) {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(USE_RELA)
 | 
					#if defined(USE_RELA)
 | 
				
			||||||
    if (si->plt_rela != NULL) {
 | 
					    if (si->plt_rela != nullptr) {
 | 
				
			||||||
        DEBUG("[ relocating %s plt ]\n", si->name);
 | 
					        DEBUG("[ relocating %s plt ]\n", si->name);
 | 
				
			||||||
        if (soinfo_relocate(si, si->plt_rela, si->plt_rela_count, needed)) {
 | 
					        if (soinfo_relocate(si, si->plt_rela, si->plt_rela_count, needed)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (si->rela != NULL) {
 | 
					    if (si->rela != nullptr) {
 | 
				
			||||||
        DEBUG("[ relocating %s ]\n", si->name);
 | 
					        DEBUG("[ relocating %s ]\n", si->name);
 | 
				
			||||||
        if (soinfo_relocate(si, si->rela, si->rela_count, needed)) {
 | 
					        if (soinfo_relocate(si, si->rela, si->rela_count, needed)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    if (si->plt_rel != NULL) {
 | 
					    if (si->plt_rel != nullptr) {
 | 
				
			||||||
        DEBUG("[ relocating %s plt ]", si->name);
 | 
					        DEBUG("[ relocating %s plt ]", si->name);
 | 
				
			||||||
        if (soinfo_relocate(si, si->plt_rel, si->plt_rel_count, needed)) {
 | 
					        if (soinfo_relocate(si, si->plt_rel, si->plt_rel_count, needed)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (si->rel != NULL) {
 | 
					    if (si->rel != nullptr) {
 | 
				
			||||||
        DEBUG("[ relocating %s ]", si->name);
 | 
					        DEBUG("[ relocating %s ]", si->name);
 | 
				
			||||||
        if (soinfo_relocate(si, si->rel, si->rel_count, needed)) {
 | 
					        if (soinfo_relocate(si, si->rel, si->rel_count, needed)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
@@ -2122,11 +2122,11 @@ static bool soinfo_link_image(soinfo* si, const android_dlextinfo* extinfo) {
 | 
				
			|||||||
static void add_vdso(KernelArgumentBlock& args __unused) {
 | 
					static void add_vdso(KernelArgumentBlock& args __unused) {
 | 
				
			||||||
#if defined(AT_SYSINFO_EHDR)
 | 
					#if defined(AT_SYSINFO_EHDR)
 | 
				
			||||||
  ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(args.getauxval(AT_SYSINFO_EHDR));
 | 
					  ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(args.getauxval(AT_SYSINFO_EHDR));
 | 
				
			||||||
  if (ehdr_vdso == NULL) {
 | 
					  if (ehdr_vdso == nullptr) {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  soinfo* si = soinfo_alloc("[vdso]", NULL);
 | 
					  soinfo* si = soinfo_alloc("[vdso]", nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
 | 
					  si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
 | 
				
			||||||
  si->phnum = ehdr_vdso->e_phnum;
 | 
					  si->phnum = ehdr_vdso->e_phnum;
 | 
				
			||||||
@@ -2134,7 +2134,7 @@ static void add_vdso(KernelArgumentBlock& args __unused) {
 | 
				
			|||||||
  si->size = phdr_table_get_load_size(si->phdr, si->phnum);
 | 
					  si->size = phdr_table_get_load_size(si->phdr, si->phnum);
 | 
				
			||||||
  si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
 | 
					  si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  soinfo_link_image(si, NULL);
 | 
					  soinfo_link_image(si, nullptr);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2167,7 +2167,7 @@ static void init_linker_info_for_gdb(ElfW(Addr) linker_base) {
 | 
				
			|||||||
  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_base);
 | 
					  ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_base);
 | 
				
			||||||
  ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_base + elf_hdr->e_phoff);
 | 
					  ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_base + elf_hdr->e_phoff);
 | 
				
			||||||
  phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
 | 
					  phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
 | 
				
			||||||
                                 &linker_soinfo_for_gdb.dynamic, NULL, NULL);
 | 
					                                 &linker_soinfo_for_gdb.dynamic, nullptr, nullptr);
 | 
				
			||||||
  insert_soinfo_into_debug_map(&linker_soinfo_for_gdb);
 | 
					  insert_soinfo_into_debug_map(&linker_soinfo_for_gdb);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2195,14 +2195,14 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Get a few environment variables.
 | 
					    // Get a few environment variables.
 | 
				
			||||||
    const char* LD_DEBUG = linker_env_get("LD_DEBUG");
 | 
					    const char* LD_DEBUG = linker_env_get("LD_DEBUG");
 | 
				
			||||||
    if (LD_DEBUG != NULL) {
 | 
					    if (LD_DEBUG != nullptr) {
 | 
				
			||||||
      g_ld_debug_verbosity = atoi(LD_DEBUG);
 | 
					      g_ld_debug_verbosity = atoi(LD_DEBUG);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Normally, these are cleaned by linker_env_init, but the test
 | 
					    // Normally, these are cleaned by linker_env_init, but the test
 | 
				
			||||||
    // doesn't cost us anything.
 | 
					    // doesn't cost us anything.
 | 
				
			||||||
    const char* ldpath_env = NULL;
 | 
					    const char* ldpath_env = nullptr;
 | 
				
			||||||
    const char* ldpreload_env = NULL;
 | 
					    const char* ldpreload_env = nullptr;
 | 
				
			||||||
    if (!get_AT_SECURE()) {
 | 
					    if (!get_AT_SECURE()) {
 | 
				
			||||||
      ldpath_env = linker_env_get("LD_LIBRARY_PATH");
 | 
					      ldpath_env = linker_env_get("LD_LIBRARY_PATH");
 | 
				
			||||||
      ldpreload_env = linker_env_get("LD_PRELOAD");
 | 
					      ldpreload_env = linker_env_get("LD_PRELOAD");
 | 
				
			||||||
@@ -2210,8 +2210,8 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    INFO("[ android linker & debugger ]");
 | 
					    INFO("[ android linker & debugger ]");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    soinfo* si = soinfo_alloc(args.argv[0], NULL);
 | 
					    soinfo* si = soinfo_alloc(args.argv[0], nullptr);
 | 
				
			||||||
    if (si == NULL) {
 | 
					    if (si == nullptr) {
 | 
				
			||||||
        exit(EXIT_FAILURE);
 | 
					        exit(EXIT_FAILURE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2221,8 +2221,8 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    map->l_addr = 0;
 | 
					    map->l_addr = 0;
 | 
				
			||||||
    map->l_name = args.argv[0];
 | 
					    map->l_name = args.argv[0];
 | 
				
			||||||
    map->l_prev = NULL;
 | 
					    map->l_prev = nullptr;
 | 
				
			||||||
    map->l_next = NULL;
 | 
					    map->l_next = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _r_debug.r_map = map;
 | 
					    _r_debug.r_map = map;
 | 
				
			||||||
    r_debug_tail = map;
 | 
					    r_debug_tail = map;
 | 
				
			||||||
@@ -2248,7 +2248,7 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
        break;
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    si->dynamic = NULL;
 | 
					    si->dynamic = nullptr;
 | 
				
			||||||
    si->ref_count = 1;
 | 
					    si->ref_count = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
 | 
					    ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
 | 
				
			||||||
@@ -2263,7 +2263,7 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    somain = si;
 | 
					    somain = si;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!soinfo_link_image(si, NULL)) {
 | 
					    if (!soinfo_link_image(si, nullptr)) {
 | 
				
			||||||
        __libc_format_fd(2, "CANNOT LINK EXECUTABLE: %s\n", linker_get_error_buffer());
 | 
					        __libc_format_fd(2, "CANNOT LINK EXECUTABLE: %s\n", linker_get_error_buffer());
 | 
				
			||||||
        exit(EXIT_FAILURE);
 | 
					        exit(EXIT_FAILURE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -2272,7 +2272,7 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    si->CallPreInitConstructors();
 | 
					    si->CallPreInitConstructors();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (size_t i = 0; g_ld_preloads[i] != NULL; ++i) {
 | 
					    for (size_t i = 0; g_ld_preloads[i] != nullptr; ++i) {
 | 
				
			||||||
        g_ld_preloads[i]->CallConstructors();
 | 
					        g_ld_preloads[i]->CallConstructors();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2285,7 +2285,7 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
 | 
				
			|||||||
    si->CallConstructors();
 | 
					    si->CallConstructors();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if TIMING
 | 
					#if TIMING
 | 
				
			||||||
    gettimeofday(&t1, NULL);
 | 
					    gettimeofday(&t1, nullptr);
 | 
				
			||||||
    PRINT("LINKER TIME: %s: %d microseconds", args.argv[0], (int) (
 | 
					    PRINT("LINKER TIME: %s: %d microseconds", args.argv[0], (int) (
 | 
				
			||||||
               (((long long)t1.tv_sec * 1000000LL) + (long long)t1.tv_usec) -
 | 
					               (((long long)t1.tv_sec * 1000000LL) + (long long)t1.tv_usec) -
 | 
				
			||||||
               (((long long)t0.tv_sec * 1000000LL) + (long long)t0.tv_usec)));
 | 
					               (((long long)t0.tv_sec * 1000000LL) + (long long)t0.tv_usec)));
 | 
				
			||||||
@@ -2386,12 +2386,12 @@ extern "C" ElfW(Addr) __linker_init(void* raw_args) {
 | 
				
			|||||||
  linker_so.base = linker_addr;
 | 
					  linker_so.base = linker_addr;
 | 
				
			||||||
  linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
 | 
					  linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
 | 
				
			||||||
  linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
 | 
					  linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
 | 
				
			||||||
  linker_so.dynamic = NULL;
 | 
					  linker_so.dynamic = nullptr;
 | 
				
			||||||
  linker_so.phdr = phdr;
 | 
					  linker_so.phdr = phdr;
 | 
				
			||||||
  linker_so.phnum = elf_hdr->e_phnum;
 | 
					  linker_so.phnum = elf_hdr->e_phnum;
 | 
				
			||||||
  linker_so.flags |= FLAG_LINKER;
 | 
					  linker_so.flags |= FLAG_LINKER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!soinfo_link_image(&linker_so, NULL)) {
 | 
					  if (!soinfo_link_image(&linker_so, nullptr)) {
 | 
				
			||||||
    // It would be nice to print an error message, but if the linker
 | 
					    // It would be nice to print an error message, but if the linker
 | 
				
			||||||
    // can't link itself, there's no guarantee that we'll be able to
 | 
					    // can't link itself, there's no guarantee that we'll be able to
 | 
				
			||||||
    // call write() (because it involves a GOT reference). We may as
 | 
					    // call write() (because it involves a GOT reference). We may as
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,7 +58,7 @@ static void __init_AT_SECURE(KernelArgumentBlock& args) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Check if the environment variable definition at 'envstr'
 | 
					// Check if the environment variable definition at 'envstr'
 | 
				
			||||||
// starts with '<name>=', and if so return the address of the
 | 
					// starts with '<name>=', and if so return the address of the
 | 
				
			||||||
// first character after the equal sign. Otherwise return NULL.
 | 
					// first character after the equal sign. Otherwise return null.
 | 
				
			||||||
static const char* env_match(const char* envstr, const char* name) {
 | 
					static const char* env_match(const char* envstr, const char* name) {
 | 
				
			||||||
  size_t i = 0;
 | 
					  size_t i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -70,7 +70,7 @@ static const char* env_match(const char* envstr, const char* name) {
 | 
				
			|||||||
    return envstr + i + 1;
 | 
					    return envstr + i + 1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return NULL;
 | 
					  return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool __is_valid_environment_variable(const char* name) {
 | 
					static bool __is_valid_environment_variable(const char* name) {
 | 
				
			||||||
@@ -78,7 +78,7 @@ static bool __is_valid_environment_variable(const char* name) {
 | 
				
			|||||||
  // as the maximum size for an env. variable definition.
 | 
					  // as the maximum size for an env. variable definition.
 | 
				
			||||||
  const int MAX_ENV_LEN = 32*4096;
 | 
					  const int MAX_ENV_LEN = 32*4096;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (name == NULL) {
 | 
					  if (name == nullptr) {
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -136,10 +136,10 @@ static bool __is_unsafe_environment_variable(const char* name) {
 | 
				
			|||||||
      "RES_OPTIONS",
 | 
					      "RES_OPTIONS",
 | 
				
			||||||
      "TMPDIR",
 | 
					      "TMPDIR",
 | 
				
			||||||
      "TZDIR",
 | 
					      "TZDIR",
 | 
				
			||||||
      NULL
 | 
					      nullptr
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
  for (size_t i = 0; UNSAFE_VARIABLE_NAMES[i] != NULL; ++i) {
 | 
					  for (size_t i = 0; UNSAFE_VARIABLE_NAMES[i] != nullptr; ++i) {
 | 
				
			||||||
    if (env_match(name, UNSAFE_VARIABLE_NAMES[i]) != NULL) {
 | 
					    if (env_match(name, UNSAFE_VARIABLE_NAMES[i]) != nullptr) {
 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -149,7 +149,7 @@ static bool __is_unsafe_environment_variable(const char* name) {
 | 
				
			|||||||
static void __sanitize_environment_variables() {
 | 
					static void __sanitize_environment_variables() {
 | 
				
			||||||
  char** src  = _envp;
 | 
					  char** src  = _envp;
 | 
				
			||||||
  char** dst = _envp;
 | 
					  char** dst = _envp;
 | 
				
			||||||
  for (; src[0] != NULL; ++src) {
 | 
					  for (; src[0] != nullptr; ++src) {
 | 
				
			||||||
    if (!__is_valid_environment_variable(src[0])) {
 | 
					    if (!__is_valid_environment_variable(src[0])) {
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -160,11 +160,11 @@ static void __sanitize_environment_variables() {
 | 
				
			|||||||
    dst[0] = src[0];
 | 
					    dst[0] = src[0];
 | 
				
			||||||
    ++dst;
 | 
					    ++dst;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  dst[0] = NULL;
 | 
					  dst[0] = nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void linker_env_init(KernelArgumentBlock& args) {
 | 
					void linker_env_init(KernelArgumentBlock& args) {
 | 
				
			||||||
  // Store environment pointer - can't be NULL.
 | 
					  // Store environment pointer - can't be null.
 | 
				
			||||||
  _envp = args.envp;
 | 
					  _envp = args.envp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  __init_AT_SECURE(args);
 | 
					  __init_AT_SECURE(args);
 | 
				
			||||||
@@ -172,18 +172,18 @@ void linker_env_init(KernelArgumentBlock& args) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const char* linker_env_get(const char* name) {
 | 
					const char* linker_env_get(const char* name) {
 | 
				
			||||||
  if (name == NULL || name[0] == '\0') {
 | 
					  if (name == nullptr || name[0] == '\0') {
 | 
				
			||||||
    return NULL;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (char** p = _envp; p[0] != NULL; ++p) {
 | 
					  for (char** p = _envp; p[0] != nullptr; ++p) {
 | 
				
			||||||
    const char* val = env_match(p[0], name);
 | 
					    const char* val = env_match(p[0], name);
 | 
				
			||||||
    if (val != NULL) {
 | 
					    if (val != nullptr) {
 | 
				
			||||||
      if (val[0] == '\0') {
 | 
					      if (val[0] == '\0') {
 | 
				
			||||||
        return NULL; // Return NULL for empty strings.
 | 
					        return nullptr; // Return null for empty strings.
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return val;
 | 
					      return val;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return NULL;
 | 
					  return nullptr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ class KernelArgumentBlock;
 | 
				
			|||||||
extern void linker_env_init(KernelArgumentBlock& args);
 | 
					extern void linker_env_init(KernelArgumentBlock& args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns the value of environment variable 'name' if defined and not
 | 
					// Returns the value of environment variable 'name' if defined and not
 | 
				
			||||||
// empty, or NULL otherwise.
 | 
					// empty, or null otherwise.
 | 
				
			||||||
extern const char* linker_env_get(const char* name);
 | 
					extern const char* linker_env_get(const char* name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Returns the value of this program's AT_SECURE variable.
 | 
					// Returns the value of this program's AT_SECURE variable.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -121,13 +121,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ElfReader::ElfReader(const char* name, int fd)
 | 
					ElfReader::ElfReader(const char* name, int fd)
 | 
				
			||||||
    : name_(name), fd_(fd),
 | 
					    : name_(name), fd_(fd),
 | 
				
			||||||
      phdr_num_(0), phdr_mmap_(NULL), phdr_table_(NULL), phdr_size_(0),
 | 
					      phdr_num_(0), phdr_mmap_(nullptr), phdr_table_(nullptr), phdr_size_(0),
 | 
				
			||||||
      load_start_(NULL), load_size_(0), load_bias_(0),
 | 
					      load_start_(nullptr), load_size_(0), load_bias_(0),
 | 
				
			||||||
      loaded_phdr_(NULL) {
 | 
					      loaded_phdr_(nullptr) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ElfReader::~ElfReader() {
 | 
					ElfReader::~ElfReader() {
 | 
				
			||||||
  if (phdr_mmap_ != NULL) {
 | 
					  if (phdr_mmap_ != nullptr) {
 | 
				
			||||||
    munmap(phdr_mmap_, phdr_size_);
 | 
					    munmap(phdr_mmap_, phdr_size_);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -225,7 +225,7 @@ bool ElfReader::ReadProgramHeader() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  phdr_size_ = page_max - page_min;
 | 
					  phdr_size_ = page_max - page_min;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void* mmap_result = mmap(NULL, phdr_size_, PROT_READ, MAP_PRIVATE, fd_, page_min);
 | 
					  void* mmap_result = mmap(nullptr, phdr_size_, PROT_READ, MAP_PRIVATE, fd_, page_min);
 | 
				
			||||||
  if (mmap_result == MAP_FAILED) {
 | 
					  if (mmap_result == MAP_FAILED) {
 | 
				
			||||||
    DL_ERR("\"%s\" phdr mmap failed: %s", name_, strerror(errno));
 | 
					    DL_ERR("\"%s\" phdr mmap failed: %s", name_, strerror(errno));
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
@@ -242,7 +242,7 @@ bool ElfReader::ReadProgramHeader() {
 | 
				
			|||||||
 * process' address space. If there are no loadable segments, 0 is
 | 
					 * process' address space. If there are no loadable segments, 0 is
 | 
				
			||||||
 * returned.
 | 
					 * returned.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * If out_min_vaddr or out_max_vaddr are non-NULL, they will be
 | 
					 * If out_min_vaddr or out_max_vaddr are not null, they will be
 | 
				
			||||||
 * set to the minimum and maximum addresses of pages to be reserved,
 | 
					 * set to the minimum and maximum addresses of pages to be reserved,
 | 
				
			||||||
 * or 0 if there is nothing to load.
 | 
					 * or 0 if there is nothing to load.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -276,10 +276,10 @@ size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count,
 | 
				
			|||||||
  min_vaddr = PAGE_START(min_vaddr);
 | 
					  min_vaddr = PAGE_START(min_vaddr);
 | 
				
			||||||
  max_vaddr = PAGE_END(max_vaddr);
 | 
					  max_vaddr = PAGE_END(max_vaddr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (out_min_vaddr != NULL) {
 | 
					  if (out_min_vaddr != nullptr) {
 | 
				
			||||||
    *out_min_vaddr = min_vaddr;
 | 
					    *out_min_vaddr = min_vaddr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if (out_max_vaddr != NULL) {
 | 
					  if (out_max_vaddr != nullptr) {
 | 
				
			||||||
    *out_max_vaddr = max_vaddr;
 | 
					    *out_max_vaddr = max_vaddr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return max_vaddr - min_vaddr;
 | 
					  return max_vaddr - min_vaddr;
 | 
				
			||||||
@@ -301,7 +301,7 @@ bool ElfReader::ReserveAddressSpace(const android_dlextinfo* extinfo) {
 | 
				
			|||||||
  size_t reserved_size = 0;
 | 
					  size_t reserved_size = 0;
 | 
				
			||||||
  bool reserved_hint = true;
 | 
					  bool reserved_hint = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (extinfo != NULL) {
 | 
					  if (extinfo != nullptr) {
 | 
				
			||||||
    if (extinfo->flags & ANDROID_DLEXT_RESERVED_ADDRESS) {
 | 
					    if (extinfo->flags & ANDROID_DLEXT_RESERVED_ADDRESS) {
 | 
				
			||||||
      reserved_size = extinfo->reserved_size;
 | 
					      reserved_size = extinfo->reserved_size;
 | 
				
			||||||
      reserved_hint = false;
 | 
					      reserved_hint = false;
 | 
				
			||||||
@@ -585,9 +585,9 @@ int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, El
 | 
				
			|||||||
    return -1;
 | 
					    return -1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  off_t file_size = file_stat.st_size;
 | 
					  off_t file_size = file_stat.st_size;
 | 
				
			||||||
  void* temp_mapping = NULL;
 | 
					  void* temp_mapping = nullptr;
 | 
				
			||||||
  if (file_size > 0) {
 | 
					  if (file_size > 0) {
 | 
				
			||||||
    temp_mapping = mmap(NULL, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
 | 
					    temp_mapping = mmap(nullptr, file_size, PROT_READ, MAP_PRIVATE, fd, 0);
 | 
				
			||||||
    if (temp_mapping == MAP_FAILED) {
 | 
					    if (temp_mapping == MAP_FAILED) {
 | 
				
			||||||
      return -1;
 | 
					      return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -667,7 +667,7 @@ int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count, El
 | 
				
			|||||||
 *   phdr_count  -> number of entries in tables
 | 
					 *   phdr_count  -> number of entries in tables
 | 
				
			||||||
 *   load_bias   -> load bias
 | 
					 *   load_bias   -> load bias
 | 
				
			||||||
 * Output:
 | 
					 * Output:
 | 
				
			||||||
 *   arm_exidx       -> address of table in memory (NULL on failure).
 | 
					 *   arm_exidx       -> address of table in memory (null on failure).
 | 
				
			||||||
 *   arm_exidx_count -> number of items in table (0 on failure).
 | 
					 *   arm_exidx_count -> number of items in table (0 on failure).
 | 
				
			||||||
 * Return:
 | 
					 * Return:
 | 
				
			||||||
 *   0 on error, -1 on failure (_no_ error code in errno)
 | 
					 *   0 on error, -1 on failure (_no_ error code in errno)
 | 
				
			||||||
@@ -687,21 +687,21 @@ int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count,
 | 
				
			|||||||
    *arm_exidx_count = (unsigned)(phdr->p_memsz / 8);
 | 
					    *arm_exidx_count = (unsigned)(phdr->p_memsz / 8);
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  *arm_exidx = NULL;
 | 
					  *arm_exidx = nullptr;
 | 
				
			||||||
  *arm_exidx_count = 0;
 | 
					  *arm_exidx_count = 0;
 | 
				
			||||||
  return -1;
 | 
					  return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Return the address and size of the ELF file's .dynamic section in memory,
 | 
					/* Return the address and size of the ELF file's .dynamic section in memory,
 | 
				
			||||||
 * or NULL if missing.
 | 
					 * or null if missing.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Input:
 | 
					 * Input:
 | 
				
			||||||
 *   phdr_table  -> program header table
 | 
					 *   phdr_table  -> program header table
 | 
				
			||||||
 *   phdr_count  -> number of entries in tables
 | 
					 *   phdr_count  -> number of entries in tables
 | 
				
			||||||
 *   load_bias   -> load bias
 | 
					 *   load_bias   -> load bias
 | 
				
			||||||
 * Output:
 | 
					 * Output:
 | 
				
			||||||
 *   dynamic       -> address of table in memory (NULL on failure).
 | 
					 *   dynamic       -> address of table in memory (null on failure).
 | 
				
			||||||
 *   dynamic_count -> number of items in table (0 on failure).
 | 
					 *   dynamic_count -> number of items in table (0 on failure).
 | 
				
			||||||
 *   dynamic_flags -> protection flags for section (unset on failure)
 | 
					 *   dynamic_flags -> protection flags for section (unset on failure)
 | 
				
			||||||
 * Return:
 | 
					 * Return:
 | 
				
			||||||
@@ -727,7 +727,7 @@ void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_co
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  *dynamic = NULL;
 | 
					  *dynamic = nullptr;
 | 
				
			||||||
  if (dynamic_count) {
 | 
					  if (dynamic_count) {
 | 
				
			||||||
    *dynamic_count = 0;
 | 
					    *dynamic_count = 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,7 @@ class ElfReader {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count,
 | 
					size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count,
 | 
				
			||||||
                                ElfW(Addr)* min_vaddr = NULL, ElfW(Addr)* max_vaddr = NULL);
 | 
					                                ElfW(Addr)* min_vaddr = nullptr, ElfW(Addr)* max_vaddr = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias);
 | 
					int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user