[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:12:35 PST 2018
vitalybuka created this revision.
Herald added a subscriber: kubamracek.
Repository:
rL LLVM
https://reviews.llvm.org/D54165
Files:
compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/lib/sanitizer_common/sanitizer_openbsd.cc
compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc
compiler-rt/lib/sanitizer_common/sanitizer_win.cc
Index: compiler-rt/lib/sanitizer_common/sanitizer_win.cc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_win.cc
+++ compiler-rt/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/lib/sanitizer_common/sanitizer_rtems.cc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_rtems.cc
+++ compiler-rt/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/lib/sanitizer_common/sanitizer_openbsd.cc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_openbsd.cc
+++ compiler-rt/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();
}
Index: compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ compiler-rt/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/lib/sanitizer_common/sanitizer_fuchsia.cc
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cc
+++ compiler-rt/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/lib/sanitizer_common/sanitizer_common.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -224,6 +224,7 @@
void ReExec();
void CheckASLR();
char **GetArgv();
+char **GetEnviron();
void PrintCmdline();
bool StackSizeIsUnlimited();
uptr GetStackSizeLimitInBytes();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54165.172799.patch
Type: text/x-patch
Size: 3089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181106/885f33b7/attachment.bin>
More information about the llvm-commits
mailing list