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/20678] New: ifunc resolver function cannot call an ifunc resolved function with static linking


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

            Bug ID: 20678
           Summary: ifunc resolver function cannot call an ifunc resolved
                    function with static linking
           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: ---

related to bug 20673

with static linking, calling extern functions from an ifunc
resolver works usually (there are no dynamic relocations, so
no relocation ordering issues), however if the called function
is itself ifunc resolved then the ordering of iplt entries
determine if it works or crashes (iplts are processed in
apply_irel at early startup).

since a user cannot tell which c runtime functions are ifunc
resolved, this means libc functions cannot be called from
an ifunc resolver with static linking.

i don't see an easy fix (other than documenting the situation),
it implies to me that c language ifunc resolvers cannot be
supported or the compiler must not emit calls to ifunc resolved
functions when compiling resolvers (however the compiler might
not know which function is used as a resolver).

compile with -static -fno-builtin-strcpy:
$ cat main.c
static int foo1(void) { return 1; }
static int foo2(void) { return 2; }

char *strcpy(char *, const char *);

static int (*foo_resolver())()
{
        char a[2];
        strcpy(a,"x"); // ifunc resolved on x86_64
        return a[0] ? foo1 : foo2;
}

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

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]