[compiler-rt] r193098 - Use internal_memset to initialize this variable.

Chandler Carruth chandlerc at google.com
Mon Oct 21 11:29:13 PDT 2013


Any code which is expected to be built without libc should be built
-ffreestanding at least, and likely -fno-builtin.


On Mon, Oct 21, 2013 at 11:23 AM, Richard Smith <richard at metafoo.co.uk>wrote:

> This is pretty scary. Is there a flag we can use to avoid memset being
> implicitly called here? -fno-builtin or similar?
>
>
> On Mon, Oct 21, 2013 at 11:11 AM, Peter Collingbourne <peter at pcc.me.uk>wrote:
>
>> Author: pcc
>> Date: Mon Oct 21 13:11:57 2013
>> New Revision: 193098
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=193098&view=rev
>> Log:
>> Use internal_memset to initialize this variable.
>>
>> Otherwise, the compiler may use memset in non-optimized builds, which is
>> forbidden in the nolibc part of the runtime.
>>
>> Modified:
>>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
>>
>> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=193098&r1=193097&r2=193098&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
>> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Mon Oct 21
>> 13:11:57 2013
>> @@ -218,7 +218,8 @@ uptr GetTid() {
>>  }
>>
>>  u64 NanoTime() {
>> -  kernel_timeval tv = {};
>> +  kernel_timeval tv;
>> +  internal_memset(&tv, 0, sizeof(tv));
>>    internal_syscall(__NR_gettimeofday, &tv, 0);
>>    return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
>>  }
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131021/5c4172c9/attachment.html>


More information about the llvm-commits mailing list