public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix g++.old-deja/g++.abi/vtable2.C on hppa
@ 2017-01-28 18:47 John David Anglin
  0 siblings, 0 replies; only message in thread
From: John David Anglin @ 2017-01-28 18:47 UTC (permalink / raw)
  To: gcc-patches@gcc.gnu.org Patches

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

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.anglin@bell.net



[-- Attachment #2: vtable2.C.d.2.txt --]
[-- Type: text/plain, Size: 1185 bytes --]

2017-01-28  John David Anglin  <danglin@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 ()
 {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-01-28 18:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-28 18:47 [committed] Fix g++.old-deja/g++.abi/vtable2.C on hppa John David Anglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).