RFC: Add DT_FLAGS_2 and DF_2_GNU_IFUNC

Florian Weimer fweimer@redhat.com
Fri May 25 21:26:00 GMT 2018


On 05/25/2018 11:18 PM, H.J. Lu wrote:

>> Still I don't see what this buys you if the LD_PRELOAD object has IFUNCs,
>> too.
> 
> [hjl@gnu-cfl-1 ifunc-2]$ cat bar.c
> void
> bar (char *dst, const char *src, unsigned int size)
> {
>    __builtin_memmove (dst, src, size);
> }
> [hjl@gnu-cfl-1 ifunc-2]$ cat main.c
> extern void bar (char *, const char *, unsigned int);
> 
> int
> main ()
> {
>    char dst[50];
>    const char src[] =
>      {
>        "This is a test"
>      };
>    bar (dst, src, sizeof (src));
>    if (__builtin_memcmp (dst, src, sizeof (src)) != 0)
>      __builtin_abort ();
>    return 0;
> }
> [hjl@gnu-cfl-1 ifunc-2]$ make
> gcc -O2 -g   -c -o main.o main.c
> gcc -O2 -g -fPIC   -c -o bar.o bar.c
> gcc -shared -z now -o libbar.so bar.o
> gcc -z now -o x main.o libbar.so -Wl,-R,.
> ./x
> [hjl@gnu-cfl-1 ifunc-2]$ LD_PRELOAD=./libmemmove.so ./x
> ./x: Relink `./libbar.so' with `./libmemmove.so' for IFUNC symbol `memmove'
> [hjl@gnu-cfl-1 ifunc-2]$

This doesn't reproduce for me.  The commands above do not produce 
libmemmove.so.  “LD_PRELOAD=./libbar.so ./x” does not crash here (with a 
glibc 2.26-derived library that hasn't got my IFUNC scheduler).

Thanks,
Florian



More information about the Binutils mailing list