On 02/12/2010 00:12, Cary Coutant wrote: > Think about it -- any failure to bind to an interposed copy of memcpy > (or any other library call generated by gcc) is indistinguishable from > the compiler choosing to generate the code inline.
Indeed, replacing library functions is a tricky business in the presence of optimisations: > $ cat main.c > #include <stdio.h> > > int main (int argc, const char **argv) > { > printf ("hello world\n"); > return 0; > } > > $ cat myprintf.c > #include <stdlib.h> > > int printf (const char *fmt, ...) > { > abort (); > } > > $ gcc -O3 main.c myprintf.c -o test1 > > $ ./test1.exe > hello world > > $ cat main2.c > #include <stdio.h> > > int main (int argc, const char **argv) > { > printf ("<%s>", "hello world\n"); > return 0; > } > > $ gcc -O3 main2.c myprintf.c -o test2 > > $ ./test2.exe > Aborted (core dumped) > > $ I think the answer to this is that you have to use -fno-builtin if you want to interpose a library function, regardless of LTO or not. cheers, DaveK