[PATCH] D14921: [sanitizer] Don't use ARM_VFPREGS_SIZE for old kernels.

Maxim Ostapenko via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 23 05:55:10 PST 2015


m.ostepenko created this revision.
m.ostepenko added reviewers: kcc, samsonov, eugenis, rengolin.
m.ostepenko added subscribers: zatrazz, christophe.lyon, ygribov, llvm-commits.
m.ostepenko set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.

Hi,

after recent sanitzer library merge to GCC we have noticed, that for older kernel versions ARM_VFPREGS_SIZE is not defined that leads to such error on arm-none-linux-gnueabi:

```
libtool: compile:
/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/./gcc/xgcc
-shared-libgcc -B/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/g
cc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/./gcc -nostdinc++
-L/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/
libstdc++-v3/src
-L/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/src/.libs
-L/tmp/1800227_1.tmpdir/
aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-arm-none-linux-gnueabi/gcc3/arm-none-linux-gnueabi/libstdc++-v3/libsupc++/.libs
-B/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/t
ools/arm-none-linux-gnueabi/bin/
-B/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/lib/
-isystem /tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gc
c-fsf-gccsrc/tools/arm-none-linux-gnueabi/include -isystem
/tmp/1800227_1.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/tools/arm-none-linux-gnueabi/sys-include
-D_GNU_SOURCE -D_DEBU
G -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -DHAVE_RPC_XDR_H=1 -DHAVE_TIRPC_RPC_XDR_H=0 -I.
-I/tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsr
c/libsanitizer/sanitizer_common -I.. -I
/tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libsanitizer/include
-isystem /tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/
gccsrc/libsanitizer/include/system -Wall -W -Wno-unused-parameter
-Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin
-fno-exceptions -fno-rtti -fomit-frame-pointer -fun
wind-tables -fvisibility=hidden -Wno-variadic-macros
-I../../libstdc++-v3/include
-I../../libstdc++-v3/include/arm-none-linux-gnueabi
-I/tmp/1800227_1.tmpdir/aci-gcc-fsf/sources
/gcc-fsf/gccsrc/libsanitizer/../libstdc++-v3/libsupc++ -std=gnu++11
-DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE -I
/tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/
libsanitizer/../libbacktrace -I ../libbacktrace -I
/tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libsanitizer/../include
-include /tmp/1800227_1.tmpdir/aci-gcc-fsf/so
urces/gcc-fsf/gccsrc/libsanitizer/libbacktrace/backtrace-rename.h -g
-O2 -D_GNU_SOURCE -MT sanitizer_platform_limits_posix.lo -MD -MP -MF
.deps/sanitizer_platform_limits_posix.T
po -c /tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
 -fPIC -DPIC -o .libs/sanitizer_platform_limits_p
osix.o
/tmp/1800227_1.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:326:44:
error: 'ARM_VFPREGS_SIZE' was not declared in t
his scope
   unsigned struct_user_vfpregs_struct_sz = ARM_VFPREGS_SIZE;
                                            ^~~~~~~~~~~~~~~~

make[4]: *** [sanitizer_platform_limits_posix.lo] Error 1
```

After some investigation, I found out that ptrace_getvfpregs and ptrace_setvfpregs have a guard against such an issue:

```
   int ptrace_getfpxregs = -1;
   int ptrace_setfpxregs = -1;
 #endif // PTRACE_GETFPXREGS/PTRACE_SETFPXREGS
+#if defined(PTRACE_GETVFPREGS) && defined(PTRACE_SETVFPREGS)
+  int ptrace_getvfpregs = PTRACE_GETVFPREGS;
+  int ptrace_setvfpregs = PTRACE_SETVFPREGS;
+#else
+  int ptrace_getvfpregs = -1;
+  int ptrace_setvfpregs = -1;
+#endif
```

Perhaps we could do the same thing for ARM_VFPREGS_SIZE?

Repository:
  rL LLVM

http://reviews.llvm.org/D14921

Files:
  lib/sanitizer_common/sanitizer_platform_limits_posix.cc

Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -325,10 +325,14 @@
   unsigned struct_user_fpxregs_struct_sz = sizeof(struct user_fpxregs_struct);
 #endif // __x86_64 || __mips64 || __powerpc64__ || __aarch64__ || __arm__
 #ifdef __arm__
+#if defined(ARM_VFPREGS_SIZE)
   unsigned struct_user_vfpregs_struct_sz = ARM_VFPREGS_SIZE;
 #else
   unsigned struct_user_vfpregs_struct_sz = 0;
 #endif
+#else
+  unsigned struct_user_vfpregs_struct_sz = 0;
+#endif
 
   int ptrace_peektext = PTRACE_PEEKTEXT;
   int ptrace_peekdata = PTRACE_PEEKDATA;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14921.40917.patch
Type: text/x-patch
Size: 747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151123/5767ad6e/attachment.bin>


More information about the llvm-commits mailing list