Skip to content

Commit

Permalink
[plugin] update symbol resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpews committed Dec 17, 2020
1 parent c22abe5 commit e7dd908
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
13 changes: 5 additions & 8 deletions builtin-plugin/SymbolResolver/elf/dobby_symbol_resolver.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "dobby_symbol_resolver.h"
#include "common/headers/common_header.h"

#include <elf.h>
#include <jni.h>
#include <string>
Expand All @@ -8,13 +11,8 @@
#include <sys/stat.h>
#include <unistd.h>

#include "dobby_symbol_resolver.h"
#include "common/headers/common_header.h"

#include "PlatformUtil/ProcessRuntimeUtility.h"

#include "AndroidRestriction/android_restriction.h"

#include <vector>

#undef LOG_TAG
Expand Down Expand Up @@ -162,18 +160,17 @@ extern std::vector<void *> linker_get_solist();
PUBLIC void *DobbySymbolResolver(const char *image_name, const char *symbol_name_pattern) {
void *result = NULL;

#if 0
auto solist = linker_get_solist();
for (auto soinfo : solist) {
uintptr_t handle = linker_soinfo_to_handle(soinfo);
if (image_name == NULL || strstr(linker_soinfo_get_realpath(soinfo), image_name) != 0) {
#if 0
LOG(1, "DobbySymbolResolver::dlsym: %s", linker_soinfo_get_realpath(soinfo));
#endif
result = dlsym((void *)handle, symbol_name_pattern);
if (result)
return result;
}
}
#endif

result = resolve_elf_internal_symbol(image_name, symbol_name_pattern);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

#include <fcntl.h> // open

#include "shared_cache_internal.h"

#include "shared-cache/dyld_cache_format.h"
#include "macho/shared_cache_internal.h"
#include "macho/shared-cache/dyld_cache_format.h"

#include "logging/logging.h"

Expand Down Expand Up @@ -75,6 +74,8 @@ void mmap_dyld_shared_cache() {

// auto align
mmap_shared_cache_header = (struct dyld_cache_header *)get_shared_cache_load_addr();

// maybe shared cache is apple silicon
if (mmap_shared_cache_header->localSymbolsSize == 0) {
return;
}
Expand Down
10 changes: 8 additions & 2 deletions source/UserMode/PlatformUtil/Linux/ProcesssRuntimeUtility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ static std::vector<RuntimeModule> get_process_map_with_proc_maps() {
static std::vector<RuntimeModule> get_process_map_with_linker_iterator() {
std::vector<RuntimeModule> ProcessModuleMap;

dl_iterate_phdr(
static int (*dl_iterate_phdr_ptr)(int (*)(struct dl_phdr_info*, size_t, void*), void*);
dl_iterate_phdr_ptr = (typeof(dl_iterate_phdr_ptr))dlsym(RTLD_DEFAULT, "dl_iterate_phdr");
if(dl_iterate_phdr_ptr == NULL) {
return ProcessModuleMap;
}

dl_iterate_phdr_ptr(
[](dl_phdr_info *info, size_t size, void *data) {
RuntimeModule module = {0};
if (info->dlpi_name && info->dlpi_name[0] == '/')
Expand All @@ -197,7 +203,7 @@ static std::vector<RuntimeModule> get_process_map_with_linker_iterator() {
#endif

std::vector<RuntimeModule> ProcessRuntimeUtility::GetProcessModuleMap() {
#if defined(__LP64__) && 0
#if defined(__LP64__)
return get_process_map_with_linker_iterator();
#else
return get_process_map_with_proc_maps();
Expand Down

0 comments on commit e7dd908

Please sign in to comment.