diff mbox

[1/2] Libsanitizer merge from upstream r253555.

Message ID 565312DE.2020207@partner.samsung.com
State New
Headers show

Commit Message

max Nov. 23, 2015, 1:21 p.m. UTC
On 23/11/15 16:00, Christophe Lyon wrote:
> On 23 November 2015 at 13:41, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Mon, Nov 23, 2015 at 03:33:57PM +0300, Maxim Ostapenko wrote:
>>> + Adhemerval
>>>
>>> Christophe, it looks like your kernel headers (asm/ptrace.h) don't contain
>>> ARM_VFPREGS_SIZE. Do you use old kernel version?
> Yes, I do use old kernel headers.
> I could upgrade them, but I tend to avoid changing versions (binutils,
> glibc, newlib, kernel headers) unless really necessary.
>
>> Unlike LLVM, we do care to support older kernel headers.
>> So, if it is say a define, you could add
>> libsanitizer/include/system/linux/ptrace.h
>> or
>> libsanitizer/include/system/asm/ptrace.h
>> that would #include_next the original header and ifdef __arm__ and
>> that define is not defined (or some other condition, kernel version etc.),
>> define it.
>>
>>          Jakub
> So, given Jakub's answer I'll not upgrade them yet on my side :-)
>
>

Yeah, right. I've asked about kernel headers just to make sure I 
correctly understand the issue.

Actually, I see such code in 
lib/sanitizer_common/sanitizer_platform_limits_posix.cc:

#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

and in ptrace interceptor:

  else if (request == ptrace_setvfpregs)
     COMMON_INTERCEPTOR_READ_RANGE(ctx, data, 
struct_user_vfpregs_struct_sz);
  else if (request == ptrace_getvfpregs)
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, 
struct_user_vfpregs_struct_sz)

So, perhaps we can do the same thing with ARM_VFPREGS_SIZE, something 
like this?

Comments

Jakub Jelinek Nov. 23, 2015, 1:24 p.m. UTC | #1
On Mon, Nov 23, 2015 at 04:21:34PM +0300, Maxim Ostapenko wrote:
> Yeah, right. I've asked about kernel headers just to make sure I correctly
> understand the issue.
> 
> Actually, I see such code in
> lib/sanitizer_common/sanitizer_platform_limits_posix.cc:
> 
> #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
> 
> and in ptrace interceptor:
> 
>  else if (request == ptrace_setvfpregs)
>     COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_vfpregs_struct_sz);
>  else if (request == ptrace_getvfpregs)
>     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_vfpregs_struct_sz)
> 
> So, perhaps we can do the same thing with ARM_VFPREGS_SIZE, something like
> this?
> 
> diff --git
> a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
> b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
> index 9866cc9..20ff224 100644
> --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
> +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
> @@ -323,10 +323,14 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
>    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

Maybe, but then it would need to be approved upstream.
If you just define ARM_VFPREGS_SIZE to 0 or whatever else in
the GCC owned wrapper headers, you can avoid that.
I guess talk to upstream.

	Jakub
diff mbox

Patch

diff --git 
a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc 
b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
index 9866cc9..20ff224 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -323,10 +323,14 @@  unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
    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