Index: lib/Support/Unix/Path.inc =================================================================== --- lib/Support/Unix/Path.inc +++ lib/Support/Unix/Path.inc @@ -180,8 +180,22 @@ if (sys::fs::exists(aPath)) { // /proc is not always mounted under Linux (chroot for example). ssize_t len = readlink(aPath.str().c_str(), exe_path, sizeof(exe_path)); - if (len >= 0) - return std::string(exe_path, len); + if (len >= 0) { + if (len >= sizeof(exe_path)) + len = sizeof(exe_path)-1; + exe_path[len] = '\0'; + +#if _POSIX_VERSION >= 200112 || defined(__GLIBC__) + char *real_path = realpath(exe_path, NULL); + std::string ret = std::string(real_path); + free(real_path); + return ret; +#else + char real_path[MAXPATHLEN]; + realpath(exe_path, real_path); + return std::string(real_path); +#endif + } } else { // Fall back to the classical detection. if (getprogpath(exe_path, argv0))