How to build gas with ASAN/UBSAN?

Martin Liška mliska@suse.cz
Thu Aug 20 07:17:36 GMT 2020


On 8/19/20 11:50 PM, Fangrui Song wrote:
> On 2020-08-19, Nick Clifton via Binutils wrote:
>> Hi Martin,
>>
>>> One can't do that with CFLAGS="..." ../configure as it would
>>> build all .a file with that as well. And test would fail then due to unresolved
>>> sanitizer-related symbols.
>>
>> Err, I use that particular method and it works for me.  You just need to
>> add in a definition of LDFLAGS so that the appropriate library is included
>> as well.  For example:
>>
>>  % $BINUTILS_SRCDIR/configure \
>>             --enable-targets=all \
>>             --enable-64-bit-bfd \
>>             CFLAGS='-g -O2 -fsanitize=address' \
>>             CXXFLAGS='-g -O2 -fsanitize=address' \
>>             LDFLAGS='-ldl' \
>>
> 
> Emmm, is LDFLAGS='-fsanitize=address' needed?

No, -ldl is enough!

> 
> See the *link_command section in the output of gcc -dumpspecs, -fsanitize=address also affects linking.

And it helps here.

Martin



More information about the Binutils mailing list