[PATCH] D54165: [sanitizer] Add char **GetEnviron() on all other platforms

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 6 11:25:49 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL346257: [sanitizer] Add char **GetEnviron() on all other platforms (authored by vitalybuka, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D54165?vs=172799&id=172806#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D54165

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_openbsd.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc


Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
@@ -1021,6 +1021,11 @@
   return 0;
 }
 
+char **GetEnviron() {
+  // FIXME: Actually implement this function.
+  return 0;
+}
+
 pid_t StartSubprocess(const char *program, const char *const argv[],
                       fd_t stdin_fd, fd_t stdout_fd, fd_t stderr_fd) {
   // FIXME: implement on this platform
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
@@ -623,8 +623,13 @@
   return argv;
 }
 
-void ReExec() {
+char **GetEnviron() {
   char **argv, **envp;
+  GetArgsAndEnv(&argv, &envp);
+  return envp;
+}
+
+void ReExec() {
   const char *pathname = "/proc/self/exe";
 
 #if SANITIZER_NETBSD
@@ -646,8 +651,7 @@
   pathname = reinterpret_cast<const char *>(getauxval(AT_EXECFN));
 #endif
 
-  GetArgsAndEnv(&argv, &envp);
-  uptr rv = internal_execve(pathname, argv, envp);
+  uptr rv = internal_execve(pathname, GetArgv(), GetEnviron());
   int rverrno;
   CHECK_EQ(internal_iserror(rv, &rverrno), true);
   Printf("execve failed, errno %d\n", rverrno);
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
@@ -224,6 +224,7 @@
 void ReExec();
 void CheckASLR();
 char **GetArgv();
+char **GetEnviron();
 void PrintCmdline();
 bool StackSizeIsUnlimited();
 uptr GetStackSizeLimitInBytes();
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
@@ -240,6 +240,7 @@
 }
 
 char **GetArgv() { return nullptr; }
+char **GetEnviron() { return nullptr; }
 
 const char *GetEnv(const char *name) {
   return getenv(name);
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_fuchsia.cc
@@ -451,6 +451,7 @@
 char **StoredEnviron;
 
 char **GetArgv() { return StoredArgv; }
+char **GetEnviron() { return StoredEnviron; }
 
 const char *GetEnv(const char *name) {
   if (StoredEnviron) {
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_openbsd.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_openbsd.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_openbsd.cc
@@ -99,6 +99,12 @@
   return argv;
 }
 
+char **GetEnviron() {
+  char **argv, **envp;
+  GetArgsAndEnv(&argv, &envp);
+  return envp;
+}
+
 void ReExec() {
   UNIMPLEMENTED();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54165.172806.patch
Type: text/x-patch
Size: 3197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181106/2649b85a/attachment.bin>


More information about the llvm-commits mailing list