summaryrefslogtreecommitdiff
path: root/libgcc/config/pa
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2018-03-07 00:17:32 +0000
committerJohn David Anglin <danglin@gcc.gnu.org>2018-03-07 00:17:32 +0000
commit66a00b11a0eeff5f2737593ada5ac5acf334adeb (patch)
treeaf52292cd811e7eb3d43b1bf5802824a723adb96 /libgcc/config/pa
parentc0423c3e7119e40256db376c590bc88b5aec39de (diff)
fptr.c (_dl_read_access_allowed): New.
* config/pa/fptr.c (_dl_read_access_allowed): New. (__canonicalize_funcptr_for_compare): Use it. From-SVN: r258310
Diffstat (limited to 'libgcc/config/pa')
-rw-r--r--libgcc/config/pa/fptr.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libgcc/config/pa/fptr.c b/libgcc/config/pa/fptr.c
index 02f7e4b0e4b..944ed4495d9 100644
--- a/libgcc/config/pa/fptr.c
+++ b/libgcc/config/pa/fptr.c
@@ -52,6 +52,16 @@ typedef int (*fptr_t) (void);
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)
+{
+ int result;
+
+ asm ("proberi (%1),3,%0" : "=r" (result) : "r" (addr) : );
+
+ return result;
+}
+
/* __canonicalize_funcptr_for_compare must be hidden so that it is not
placed in the dynamic symbol table. Like millicode functions, it
must be linked into all binaries in order access the got table of
@@ -82,6 +92,16 @@ __canonicalize_funcptr_for_compare (fptr_t fptr)
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))
+ 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))
+ return (unsigned int) fptr;
+
got = (unsigned int *) (plabel[0] + GOT_FROM_PLT_STUB);
/* Return the address of the function if the plabel has been resolved. */