On Tue, Oct 29, 2013 at 05:15:24PM -0700, Konstantin Serebryany wrote: > Actually, I guessed the flags:
You don't have to guess them, if you look into testsuite/g++/g++.log (or testsuite/gcc/gcc.log etc.), you can find them there. > % ../gcc-inst/bin/g++ -g -fsanitize=address -static-libasan -O2 -flto > -fno-use-linker-plugin -flto-partition=none > ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c; ./a.out > 2>&1 > > /tmp/ccgSw6NI.lto.o: In function `main': > ../gcc/gcc/testsuite/c-c++-common/asan/stack-overflow-1.c:13: > undefined reference to `.LASANPC0.2585' > collect2: error: ld returned 1 exit status > > Looks like this patch is not friendly to -flto I guess if you do: ... - tree str_cst; + tree str_cst, decl, id; ... + ASM_GENERATE_INTERNAL_LABEL (buf, "LASANPC", current_function_funcdef_no); + id = get_identifier (buf); + decl = build_decl (DECL_SOURCE_LOCATION (current_function_decl), + VAR_DECL, id, char_type_node); + SET_DECL_ASSEMBLER_NAME (decl, id); + TREE_ADDRESSABLE (decl) = 1; ... it might work even for -flto. The problem with -flto is that the default set_decl_assembler_name langhook for -flto appends dot and some number to the non-exported names, which is undesirable here, because we already make sure those first numbers are unique for the whole compilation unit. Jakub