https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61048

--- Comment #4 from Ilya Palachev <i.palachev at samsung dot com> ---
> g++ test.o -o test -Wl,-flto 
> /tmp/ccEhycoY.ltrans0.ltrans.o:ccEhycoY.ltrans0.o:function
> __static_initialization_and_destruction_0(int, int): error: undefined
> reference to '__asan_before_dynamic_init'
> /tmp/ccEhycoY.ltrans0.ltrans.o:ccEhycoY.ltrans0.o:function
> __static_initialization_and_destruction_0(int, int): error: undefined
> reference to '__asan_after_dynamic_init'
> collect2: error: ld returned 1 exit status

Such error is usual when option -fsanitize=address is not specified at the 2nd
stage. For example, without option -flto gcc prints the following error:

g++ -c test.cpp -fsanitize=address -o test_nolto.o
g++ test_nolto.o -o test_nolto
test_nolto.o:test.cpp:function main: error: undefined reference to
'__asan_report_load4'
test_nolto.o:test.cpp:function __static_initialization_and_destruction_0(int,
int): error: undefined reference to '__asan_before_dynamic_init'
test_nolto.o:test.cpp:function __static_initialization_and_destruction_0(int,
int): error: undefined reference to '__asan_after_dynamic_init'
test_nolto.o:test.cpp:function _GLOBAL__sub_D_00099_0_main: error: undefined
reference to '__asan_unregister_globals'
test_nolto.o:test.cpp:function _GLOBAL__sub_I_00099_1_main: error: undefined
reference to '__asan_init_v4'
test_nolto.o:test.cpp:function _GLOBAL__sub_I_00099_1_main: error: undefined
reference to '__asan_register_globals'
collect2: error: ld returned 1 exit status

So it seems that above patch provides that gcc produces correct output.

Reply via email to