Skip to content

Instantly share code, notes, and snippets.

@danslo
Created July 15, 2013 12:58
Show Gist options
  • Save danslo/5999737 to your computer and use it in GitHub Desktop.
Save danslo/5999737 to your computer and use it in GitHub Desktop.
work around lack of /proc/self/exe
diff --git hphp/util/embedded_data.cpp hphp/util/embedded_data.cpp
index a0bdeb0..98f8dca 100644
--- hphp/util/embedded_data.cpp
+++ hphp/util/embedded_data.cpp
@@ -29,6 +29,8 @@
#ifdef __APPLE__
#include <mach-o/getsect.h>
+#include <mach-o/dyld.h>
+#include <limits.h>
#endif
namespace HPHP { namespace Util {
@@ -76,7 +78,11 @@ bool get_embedded_data(const char *section, embedded_data* desc) {
#else // __APPLE__
const struct section_64 *sect = getsectbyname("__text", section);
if (sect) {
- desc->m_filename = "hhvm";
+ char path[PATH_MAX];
+ uint32_t size = sizeof(path);
+ if (_NSGetExecutablePath(path, &size) == 0) {
+ desc->m_filename = path;
+ }
desc->m_start = sect->offset;
desc->m_len = sect->size;
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment