diff options
author | Peter Bergner <bergner@linux.ibm.com> | 2019-11-25 16:57:04 +0000 |
---|---|---|
committer | Peter Bergner <bergner@linux.ibm.com> | 2019-11-25 16:57:04 +0000 |
commit | 710e6f3966c8738a8666a47cc9e8ff5e3fc1c1c4 (patch) | |
tree | 54c81df9c0f76ef350101038a92b2f4774af9207 /libgcc/config/pa/fptr.c | |
parent | b3875f87fbe002ad43f35ba5cc16efc80f809883 (diff) | |
parent | b370f9fa8c44e8f1e2e0cda6336030c3b06a3f7b (diff) |
Merge up to 278620.ibm/gcc-8-branch
* REVISION: Update subversion id.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ibm/gcc-8-branch@278692 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgcc/config/pa/fptr.c')
-rw-r--r-- | libgcc/config/pa/fptr.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libgcc/config/pa/fptr.c b/libgcc/config/pa/fptr.c index 944ed4495d9..f33e9c25259 100644 --- a/libgcc/config/pa/fptr.c +++ b/libgcc/config/pa/fptr.c @@ -53,7 +53,7 @@ typedef int (*fixup_t) (struct link_map *, unsigned int); extern unsigned int _GLOBAL_OFFSET_TABLE_; static inline int -_dl_read_access_allowed (unsigned int *addr) +_dl_read_access_allowed (unsigned int addr) { int result; @@ -76,7 +76,8 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) { static unsigned int fixup_plabel[2] __attribute__((used)); fixup_t fixup; - unsigned int *got, *iptr, *plabel; + volatile unsigned int *plabel; + unsigned int *got, *iptr, reloc_offset; int i; /* -1 and page 0 are special. -1 is used in crtend to mark the end of @@ -91,17 +92,20 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) to the entry of the PLT stub just before the global offset table. The second word in the plabel contains the relocation offset for the function. */ - plabel = (unsigned int *) ((unsigned int) fptr & ~3); - if (!_dl_read_access_allowed (plabel)) + plabel = (volatile unsigned int *) ((unsigned int) fptr & ~3); + if (!_dl_read_access_allowed ((unsigned int)plabel)) return (unsigned int) fptr; /* Load first word of candidate descriptor. It should be a pointer with word alignment and point to memory that can be read. */ got = (unsigned int *) plabel[0]; if (((unsigned int) got & 3) != 0 - || !_dl_read_access_allowed (got)) + || !_dl_read_access_allowed ((unsigned int)got)) return (unsigned int) fptr; + /* We need to load the relocation offset before the function address. */ + reloc_offset = plabel[1]; + __sync_synchronize(); got = (unsigned int *) (plabel[0] + GOT_FROM_PLT_STUB); /* Return the address of the function if the plabel has been resolved. */ @@ -137,7 +141,7 @@ __canonicalize_funcptr_for_compare (fptr_t fptr) /* 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]); + fixup ((struct link_map *) got[1], reloc_offset); return plabel[0]; } |