From 787c102712b5fa83337be710763b24fd1a6556df Mon Sep 17 00:00:00 2001 From: John David Anglin Date: Thu, 10 Dec 2015 01:32:10 +0000 Subject: [PATCH] fptr.c (__canonicalize_funcptr_for_compare): Remove code to initialize call to __dl_fixup once. * config/pa/fptr.c (__canonicalize_funcptr_for_compare): Remove code to initialize call to __dl_fixup once. From-SVN: r231486 --- libgcc/ChangeLog | 5 +++ libgcc/config/pa/fptr.c | 70 +++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 42 deletions(-) diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 003971b0cdc..6c73ab852b7 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2015-12-09 John David Anglin + + * config/pa/fptr.c (__canonicalize_funcptr_for_compare): Remove code + to initialize call to __dl_fixup once. + 2015-12-04 Nick Clifton * config/msp430/mpy.c (__mulhi3): Use a faster algorithm. diff --git a/libgcc/config/pa/fptr.c b/libgcc/config/pa/fptr.c index 1fb0a9f14b2..dd0e15a054c 100644 --- a/libgcc/config/pa/fptr.c +++ b/libgcc/config/pa/fptr.c @@ -64,10 +64,10 @@ unsigned int __canonicalize_funcptr_for_compare (fptr_t) unsigned int __canonicalize_funcptr_for_compare (fptr_t fptr) { - static unsigned int fixup_plabel[2]; - static fixup_t fixup; - static unsigned int *init_fixup; - unsigned int *plabel, *got; + static unsigned int fixup_plabel[2] __attribute__((used)); + fixup_t fixup; + unsigned int *got, *iptr, *plabel; + int i; /* -1 and page 0 are special. -1 is used in crtend to mark the end of a list of function pointers. Also return immediately if the plabel @@ -88,47 +88,33 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) if (got != &_GLOBAL_OFFSET_TABLE_) return plabel[0]; - /* Initialize our plabel for calling fixup if we haven't done so already. - We can't rely on static initialization so we check that any previous - initialization was done for the current got address. This code needs - to be thread safe but we don't have to be too careful as the result - is invariant. */ - if (init_fixup != got) + /* Find the first "bl" branch in the offset search list. This is a + call to _dl_fixup or a magic branch to fixup at the beginning of the + trampoline template. The fixup function does the actual runtime + resolution of function descriptors. We only look for "bl" branches + with a 17-bit pc-relative displacement. */ + for (i = 0; i < NOFFSETS; i++) { - int i; - unsigned int *iptr; - - /* Find the first "bl" branch in the offset search list. This is a - call to fixup or a magic branch to fixup at the beginning of the - trampoline template. The fixup function does the actual runtime - resolution of function descriptors. We only look for "bl" branches - with a 17-bit pc-relative displacement. */ - for (i = 0; i < NOFFSETS; i++) - { - iptr = (unsigned int *) (got[-2] + fixup_branch_offset[i]); - if ((*iptr & 0xfc00e000) == 0xe8000000) - break; - } - - /* This should not happen... */ - if (i == NOFFSETS) - return ~0; - - /* Extract the 17-bit displacement from the instruction. */ - iptr += SIGN_EXTEND (GET_FIELD (*iptr, 19, 28) | - GET_FIELD (*iptr, 29, 29) << 10 | - GET_FIELD (*iptr, 11, 15) << 11 | - GET_FIELD (*iptr, 31, 31) << 16, 17); - - /* Build a plabel for an indirect call to fixup. */ - fixup_plabel[0] = (unsigned int) iptr + 8; /* address of fixup */ - fixup_plabel[1] = got[-1]; /* ltp for fixup */ - fixup = (fixup_t) ((int) fixup_plabel | 3); - - /* Save address of the global offset table. */ - init_fixup = got; + iptr = (unsigned int *) (got[-2] + fixup_branch_offset[i]); + if ((*iptr & 0xfc00e000) == 0xe8000000) + break; } + /* This should not happen... */ + if (i == NOFFSETS) + return ~0; + + /* Extract the 17-bit displacement from the instruction. */ + iptr += SIGN_EXTEND (GET_FIELD (*iptr, 19, 28) | + GET_FIELD (*iptr, 29, 29) << 10 | + GET_FIELD (*iptr, 11, 15) << 11 | + GET_FIELD (*iptr, 31, 31) << 16, 17); + + /* Build a plabel for an indirect call to _dl_fixup. */ + fixup_plabel[0] = (unsigned int) iptr + 8; /* address of fixup */ + fixup_plabel[1] = got[-1]; /* ltp for fixup */ + fixup = (fixup_t) ((int) fixup_plabel | 3); + /* Call fixup to resolve the function address. got[1] contains the link_map pointer and plabel[1] the relocation offset. */ fixup ((struct link_map *) got[1], plabel[1]); -- 2.30.2