summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Maste <emaste@freebsd.org>2016-04-14 14:17:42 +0000
committerEd Maste <emaste@freebsd.org>2016-04-14 14:17:42 +0000
commitfe2b70637c6af19ab196588bf007e0158c5a1d79 (patch)
tree0bba41d29b565cc1ce8743de329eb3101b9b6c47
parentd502f47726826e02cfca484e8eaae933260454b4 (diff)
downloadbcm5719-llvm-fe2b70637c6af19ab196588bf007e0158c5a1d79.tar.gz
bcm5719-llvm-fe2b70637c6af19ab196588bf007e0158c5a1d79.zip
[sanitizer] remove FreeBSD PS_STRINGS fallback
The PS_STRINGS constant can easily be incorrect with mismatched kernel/userland - e.g. when building i386 sanitizers on FreeBSD/amd64 with -m32. The kern.ps_strings sysctl was introduced over 20 years ago as the supported way to fetch the environment and argument string addresses from the kernel, so the fallback is never used. Differential Revision: http://reviews.llvm.org/D19027 llvm-svn: 266305
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index 6c1c8f7b27b..60dd1b4d3ba 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -490,12 +490,13 @@ static void GetArgsAndEnv(char ***argv, char ***envp) {
#else
// On FreeBSD, retrieving the argument and environment arrays is done via the
// kern.ps_strings sysctl, which returns a pointer to a structure containing
- // this information. If the sysctl is not available, a "hardcoded" address,
- // PS_STRINGS, must be used instead. See also <sys/exec.h>.
+ // this information. See also <sys/exec.h>.
ps_strings *pss;
size_t sz = sizeof(pss);
- if (sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1)
- pss = (ps_strings*)PS_STRINGS;
+ if (sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1) {
+ Printf("sysctl kern.ps_strings failed\n");
+ Die();
+ }
*argv = pss->ps_argvstr;
*envp = pss->ps_envstr;
#endif
OpenPOWER on IntegriCloud