On Thu, Jan 14, 2016 at 6:59 AM,  <noloa...@gmail.com> wrote:
>
>> >> If you want to bake in some options at compile time, there are a few
>> >> ways
>> >> to do it. -DASAN_DEFAULT_OPTIONS=check_initialization_order=true will
>> >> work,
>> >> or you can define the __asan_default_options function somewhere in the
>> >> binary like this:
>> >>
>> >
>> > Thanks, we are not compiling the compiler.
>>
>> You don't need to - just define this function somewhere in your exe
>> and libasan will automatically find it and take it's return value as
>> default option string. To control the string from cmdline you'll just
>> need to return a cmdline-controlled macro from it.
>
>
> Ah, OK, thanks.
>
> So I'm clear, I need to add the following:
>
>     #ifdef MYLIB_ASAN_CHECK_CXX_ORDER
>     bool check_initialization_order
>     {
>         reutn true;
>     }
>     #endif
>
> And then the following when building for the sanitizer:
>
>     export CXX=clang++
>     export CXXF:AGS+"-g3 -O2 -DMYLIB_ASAN_CHECK_CXX_ORDER"
>     make
>
> Is that correct?

I thought more like
  export CXXFLAGS=-DASAN_FLAGS='check_initialization_order=1'
and then in your source code
  #define STR(x) STR2(x)
  #define STR2(x) #x
  #ifdef ASAN_FLAGS
  const char *__asan_default_options() {
    return STR(ASAN_FLAGS);
  }
  #endif

> My last question is, how can I detect when initializer order checking is
> available? We currently use the following in our test script to detect when
> Address Sanitzer is available:
>
>     $CXX -x c++ -fsanitize=address adhoc.cpp.proto -c -o $TMP/adhoc >
> /dev/null 2>&1
>     if [ "$?" -eq "0" ] && [ "$IS_X86" -ne "0" ]; then
>         HAVE_ASAN=1
>     else
>         HAVE_ASAN=0
>     fi
>
> But its not clear to me how to determine when this particular feature is
> available.

I personally don't know a good answer to this. Perhaps just check
compiler version?

> Thanks again for the help.
>
> Jeff
>
> --
> You received this message because you are subscribed to the Google Groups
> "address-sanitizer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to address-sanitizer+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to address-sanitizer+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to