| 187 | } |
| 188 | |
| 189 | std::string DexFileLoader::GetDexCanonicalLocation(const char* dex_location) { |
| 190 | CHECK_NE(dex_location, static_cast<const char*>(nullptr)); |
| 191 | std::string base_location = GetBaseLocation(dex_location); |
| 192 | const char* suffix = dex_location + base_location.size(); |
| 193 | DCHECK(suffix[0] == 0 || suffix[0] == kMultiDexSeparator); |
| 194 | // Warning: Bionic implementation of realpath() allocates > 12KB on the stack. |
| 195 | // Do not run this code on a small stack, e.g. in signal handler. |
| 196 | UniqueCPtr<const char[]> path(realpath(base_location.c_str(), nullptr)); |
| 197 | if (path != nullptr && path.get() != base_location) { |
| 198 | return std::string(path.get()) + suffix; |
| 199 | } else if (suffix[0] == 0) { |
| 200 | return base_location; |
| 201 | } else { |
| 202 | return dex_location; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | // All of the implementations here should be independent of the runtime. |
| 207 | // TODO: implement all the virtual methods. |