public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12575] New: dlopen RTLD_NOW does not apply to GNU-IFUNCs
@ 2011-03-13 10:15 jan.kratochvil at redhat dot com
  2011-03-13 10:16 ` [Bug libc/12575] " jan.kratochvil at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-03-13 10:15 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12575

           Summary: dlopen RTLD_NOW does not apply to GNU-IFUNCs
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: jan.kratochvil@redhat.com


`-Wl,-z,now' works and the GNU-IFUNC resolver is called before `main'.

But RTLD_NOW returns handle and GNU-IFUNC gets called only after `dlsym'.
Even if the executable calling dlopen(, RTLD_NOW) uses -Wl,-z,-now.

The first part of the test below is correct:
+ ./mc
f
main

But this part prints:
+ ./mcd
dlsym
f

while I expect:
+ ./mcd
f
dlsym

This behavior determines how the glibc Bug 2328 should be resolved in GDB.


cat >lc.c <<EOH
#include <stdio.h>
static int
fi (int a)
{
  return a + 1;
}
asm (".type f, @gnu_indirect_function");
int (*
f (void)) (int a)
{
  puts ("f");
  return fi;
}
EOH
cat >mc.c <<EOH
#include <stdio.h>
extern int f (int a);
int
main (void)
{
  puts ("main");
  return f (-1);
}
EOH
cat >mcd.c <<EOH
#include <stdio.h>
#include <dlfcn.h>
int
main (void)
{
  void *h = dlopen ("./lc.so", RTLD_NOW);
  puts ("dlsym");
  int (*fp) (int a) = (int (*) (int a)) dlsym (h, "f");
  return fp (-1);
}
EOH
gcc -o lc.so lc.c -Wall -g -shared -fPIC; gcc -o mc mc.c -Wall -g -Wl,-z,now
./lc.so; gcc -o mcd mcd.c -Wall -g -Wl,-z,now -ldl; (set -x; ./mc; ./mcd)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-27 13:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-13 10:15 [Bug libc/12575] New: dlopen RTLD_NOW does not apply to GNU-IFUNCs jan.kratochvil at redhat dot com
2011-03-13 10:16 ` [Bug libc/12575] " jan.kratochvil at redhat dot com
2011-05-12  3:10 ` drepper.fsp at gmail dot com
2011-06-02 13:13 ` jan.kratochvil at redhat dot com
2014-06-27 13:45 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).