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: RFC: Add DT_FLAGS_2 and DF_2_GNU_IFUNC


On 05/25/2018 11:58 PM, H.J. Lu wrote:
On Fri, May 25, 2018 at 2:26 PM, Florian Weimer <fweimer@redhat.com> wrote:
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).

(some commands are missing from the reproduction steps)

https://sourceware.org/bugzilla/show_bug.cgi?id=23240

This is just the old known issue related to symbol interposition and IFUNC resolvers, where even complete DT_NEEDED information is not sufficient to perform the relocations in the correct order.

A single bit will not solve this. In your reproducer, add an IFUNC resolver to libbar.so, and I'm sure the bug will resurface again.

Thanks,
Florian


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