This vector is populated by the kernel while loading an ELF, and is
available to user land without requiring any system calls. This is
specially interesting if programs are executed under a chroot where
/proc isn't available (and thus realpath("/proc/self/exe"), the current
method of obtaining the full path name for the executable).
Commit migrated from https://github.com/dotnet/coreclr/commit/
572be424ae932cdaba08585c922a9104684b408e
strike.cpp
sos.cpp
util.cpp
- ../../../coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
)
set(SOS_LIBRARY
# share the PAL in the dac module
mscordaccore
palrt
+ unixcoreruncommon
)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/sos_unixexports.src)
add_compile_options(-fPIE)
set(CORERUN_SOURCES
- ../unixcoreruncommon/coreruncommon.cpp
osxbundlerun.cpp
)
target_link_libraries(osxbundlerun
dl
+ unixcoreruncommon
)
add_dependencies(osxbundlerun
add_compile_options(-fPIC)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+include(configure.cmake)
+
_add_library(unixcoreruncommon
STATIC
coreruncommon.cpp
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#cmakedefine01 HAVE_GETAUXVAL
+
+#endif // __CONFIG_H__
--- /dev/null
+check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h)
// Code that is used by both the Unix corerun and coreconsole.
//
+#include "config.h"
+
#include <cstdlib>
#include <cstring>
#include <assert.h>
#include <sys/types.h>
#include <sys/param.h>
#endif
+#if HAVE_GETAUXVAL
+#include <sys/auxv.h>
+#endif
#if defined(HAVE_SYS_SYSCTL_H) || defined(__FreeBSD__)
#include <sys/sysctl.h>
#endif
result = false;
}
#else
+
+#if HAVE_GETAUXVAL && defined(AT_EXECFN)
+ const char *execfn = (const char *)getauxval(AT_EXECFN);
+
+ if (execfn)
+ {
+ entrypointExecutable.assign(execfn);
+ result = true;
+ }
+ else
+#endif
// On other OSs, return the symlink that will be resolved by GetAbsolutePath
// to fetch the entrypoint EXE absolute path, inclusive of filename.
result = GetAbsolutePath(symlinkEntrypointExecutable, entrypointExecutable);