This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Update LTO plugin interface


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]