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 libc/20673] New: ifunc resolver function cannot call extern functions


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

            Bug ID: 20673
           Summary: ifunc resolver function cannot call extern functions
           Product: glibc
           Version: 2.24
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: nszabolcs at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

extern calls don't work from ifunc resolvers in general,
because ifunc resolver may be called at relocation processing time
(even with lazy binding) when the relocations for extern function
calls (jump slot relocs for pltgot entries) are not done yet (even
the minimal initialization in case of lazy binding).

this happens if the address of the ifunc resolved function is
used (so there is a non-plt reloc for it, which is processed
earlier than the plt relocs for extern functions).

this can be made to work if the dynamic linker guarantees that
any reloc that depends on ifunc is processed after relocs
that don't (this strategy still fails if there are circular
deps between ifunc resolvers).

without extern function support in ifunc resolvers it's
very problematic to use them on the c language level
outside the libc (simple compiler instrumentation can
break them, no syscalls/libc calls can be made to do
the dispatch).

e.g. main segfaults if foo is built as a dso:

$ cat foo.c
static int foo1(void) { return 1; }
static int foo2(void) { return 2; }

int cond(void);

static int (*foo_resolver())()
{
        return cond() ? foo1 : foo2;
}

int foo(void) __attribute__((ifunc("foo_resolver")));

void *p = foo; // force a non-plt reloc calling the resolver

$ cat main.c 
int foo();
int cond() { return 1; }

int main()
{
        foo();
}

-- 
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]