This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc 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]

[Bug dynamic-link/16585] dlsym() shouldn't be declared as leaf


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

--- Comment #9 from Alexander Monakov <amonakov at gmail dot com> ---
Carlos, if you agree that the documentation can be adjusted to explicitely
mention this, can the summary be changed accordingly (suggest: "document that
leaf attribute assumes no interposition", or more generally "document
constraints for LD_PRELOAD interposers") and the bug reopened?

This:

> IFUNCs are AFAIK never processed lazily, the IRELATIVE relocs in the ports I've looked at are all handled at startup.

is confusing, IFUNC and IRELATIVE are not the same.  IFUNCs are resolved
lazily, and moreover, repeated calls to dlsym trigger the resolver repeatedly. 
Here's a testcase:

$ cat test.c 
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>

static int counter;

void bar(void) __attribute__((ifunc("bar_resolver")));

static void *bar_resolver(void)
{
  printf("bar_resolver(): counter == %d\n", counter);
  return NULL;
}

int main(void)
{
  counter++;
  dlsym(RTLD_DEFAULT, "bar");
  counter++;
  dlsym(RTLD_DEFAULT, "bar");
  counter++;
  return counter;
}
$ gcc -O test.c -ldl -rdynamic 
$ ./a.out ; echo $?
bar_resolver(): counter == 0
bar_resolver(): counter == 0
3

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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