this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Expand wildcard search paths and add in the configured LIB_PATH again (by crwulff)

+19 -4
+19 -4
src/dyld/ld.cpp
··· 44 44 #include <execinfo.h> 45 45 #include "GDBInterface.h" 46 46 #include "dyld.h" 47 + #include <glob.h> 47 48 48 49 static Darling::Mutex g_ldMutex; 49 50 static std::map<std::string, LoadedLibrary*> g_ldLibraries; ··· 77 78 78 79 #define RET_IF(x) { if (void* p = x) return p; } 79 80 80 - static void findSearchpaths(std::string ldconfig_file) 81 - { 81 + static void findSearchpathsWildcard(std::string ldconfig_file_pattern); 82 + 83 + static void findSearchpaths(std::string ldconfig_file){ 82 84 std::ifstream read(ldconfig_file); 83 85 84 86 if(!read.is_open()) ··· 97 99 if (line.find('*') == std::string::npos) 98 100 findSearchpaths(line); 99 101 else 100 - ; // TODO: handle wildcards 102 + findSearchpathsWildcard(line); 101 103 } 102 104 else 103 105 { ··· 106 108 } 107 109 } 108 110 111 + static void findSearchpathsWildcard(std::string ldconfig_file_pattern) 112 + { 113 + // Use glob to break down wildcards (ex. "/etc/ld.so.conf.d/*.conf") 114 + glob_t globbuf; 115 + 116 + glob(ldconfig_file_pattern.c_str(), GLOB_NOSORT, nullptr, &globbuf); 117 + 118 + for (size_t i = 0; i < globbuf.gl_pathc; i++) 119 + findSearchpaths(globbuf.gl_pathv[i]); 120 + 121 + globfree(&globbuf); 122 + } 109 123 110 124 static void initLD() 111 125 { ··· 128 142 std::cerr << e.what() << std::endl; 129 143 } 130 144 //add hardcoded library paths 145 + g_searchPath.push_back(LIB_PATH); 131 146 g_searchPath.push_back("/lib"); 132 147 g_searchPath.push_back("/usr/lib"); 133 148 //find paths from ldconfig 134 - findSearchpaths(LD_SO_CONFIG); 149 + findSearchpathsWildcard(LD_SO_CONFIG); 135 150 } 136 151 137 152 static std::string replacePathPrefix(const char* prefix, const char* prefixed, const char* replacement)