On hppa, the function pointers used in vtables point to function descriptors.  
In order for  CMP_VPTR
to work, we need to extract the actual function address from the function 
descriptor.  On linux, we further
need to canonicalize the function pointer due to the lazy binding of function 
descriptors.

Tested on hppa-unknown-linux-gnu, hhpa2.0w-hp-hpux11.11 and 
hppa64-hp-hpux11.11.  Committed
to trunk and gcc-6 branch.

Dave
--
John David Anglin       dave.ang...@bell.net


2017-01-28  John David Anglin  <dang...@gcc.gnu.org>

        PR testsuite/70583
        * g++.old-deja/g++.abi/vtable2.C: Adjust CMP_VPTR define on hppa.

Index: g++.old-deja/g++.abi/vtable2.C
===================================================================
--- g++.old-deja/g++.abi/vtable2.C      (revision 244960)
+++ g++.old-deja/g++.abi/vtable2.C      (working copy)
@@ -142,10 +142,24 @@
 #define INC_VDATA(A,N) ((A) += 2*(N))
 #endif
 #else
+// HPPA uses function pointers but they point to function descriptors.
+#if defined __hppa__
+#ifdef __hpux__
+#ifdef _LP64
+#define CMP_VPTR(A, B) (*(unsigned long *)(*(A)+16) == *(unsigned long 
*)((unsigned long)(B)+16))
+#else
 #define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
+#endif /* _LP64 */
+#else
+extern "C" { unsigned int __canonicalize_funcptr_for_compare (void*); }
+#define CMP_VPTR(A, B) (__canonicalize_funcptr_for_compare(*(void **)A) == 
__canonicalize_funcptr_for_compare((void *)B))
+#endif /* __hpux__ */
+#else
+#define CMP_VPTR(A, B) (*(A) == (ptrdiff_t)(B))
+#endif /* __hppa__ */
 #define INC_VPTR(A)    ((A) += 1)
 #define INC_VDATA(A,N) ((A) += (N))
-#endif
+#endif /* __ia64__ */
 
 int main ()
 {

Reply via email to