* PATCH: Fix implementation of __aeabi_vec*
@ 2008-06-27 23:15 Mark Mitchell
0 siblings, 0 replies; only message in thread
From: Mark Mitchell @ 2008-06-27 23:15 UTC (permalink / raw)
To: gcc-patches
The ARM ABI C++ vector helper functions are required to accept NULL
pointers as inputs -- but the implementation in libsupc++ did not do
that. We don't use these functions from code generated by G++, but
other compilers do call them. This simple patch fixes the problem.
Committed to mainline.
As an FYI, I'm also working on a patch to use the generic helper
functions (though not the special ARM versions) when optimizing for
size.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2008-06-27 Mark Mitchell <mark@codesourcery.com>
* libsupc++/vec.cc (__aeabi_vec_dtor_cookie): Handle NULL array
address.
(__aeabi_vec_delete): Likewise.
(__aeabi_vec_delete3): Likewise.
(__aeabi_vec_delete3_nodtor): Likewise.
2008-06-27 Mark Mitchell <mark@codesourcery.com>
* g++.dg/abi/arm_cxa_vec2.C: New test.
Index: libstdc++-v3/libsupc++/vec.cc
===================================================================
--- libstdc++-v3/libsupc++/vec.cc (revision 137206)
+++ libstdc++-v3/libsupc++/vec.cc (working copy)
@@ -461,6 +461,9 @@ namespace __aeabiv1
__aeabi_vec_dtor_cookie (void *array_address,
abi::__cxa_cdtor_type destructor)
{
+ if (!array_address)
+ return NULL;
+
abi::__cxa_vec_dtor (array_address,
reinterpret_cast<std::size_t *>(array_address)[-1],
reinterpret_cast<std::size_t *>(array_address)[-2],
@@ -473,6 +476,9 @@ namespace __aeabiv1
__aeabi_vec_delete (void *array_address,
abi::__cxa_cdtor_type destructor)
{
+ if (!array_address)
+ return;
+
abi::__cxa_vec_delete (array_address,
reinterpret_cast<std::size_t *>(array_address)[-2],
2 * sizeof (std::size_t),
@@ -484,6 +490,9 @@ namespace __aeabiv1
abi::__cxa_cdtor_type destructor,
void (*dealloc) (void *, std::size_t))
{
+ if (!array_address)
+ return;
+
abi::__cxa_vec_delete3 (array_address,
reinterpret_cast<std::size_t *>(array_address)[-2],
2 * sizeof (std::size_t),
@@ -494,6 +503,9 @@ namespace __aeabiv1
__aeabi_vec_delete3_nodtor (void *array_address,
void (*dealloc) (void *, std::size_t))
{
+ if (!array_address)
+ return;
+
abi::__cxa_vec_delete3 (array_address,
reinterpret_cast<std::size_t *>(array_address)[-2],
2 * sizeof (std::size_t),
Index: gcc/testsuite/g++.dg/abi/arm_cxa_vec2.C
===================================================================
--- gcc/testsuite/g++.dg/abi/arm_cxa_vec2.C (revision 0)
+++ gcc/testsuite/g++.dg/abi/arm_cxa_vec2.C (revision 0)
@@ -0,0 +1,41 @@
+// Check that ARM vector delete functions accept NULL pointers as
+// inputs.
+// { dg-do run { target arm*-*-* } }
+
+#ifdef __ARM_EABI__
+#include <cxxabi.h>
+
+typedef void *(dtor_type)(void *);
+
+extern "C" {
+ void abort();
+ void *__aeabi_vec_dtor_cookie(void *, dtor_type);
+ void __aeabi_vec_delete(void *, dtor_type);
+ void __aeabi_vec_delete3(void *,
+ dtor_type,
+ void (*)(void *, __SIZE_TYPE__));
+ void __aeabi_vec_delete3_nodtor(void *,
+ void (*)(void *, __SIZE_TYPE__));
+}
+
+// These functions should never be called.
+void* dtor(void *)
+{
+ abort ();
+}
+
+void dealloc(void *, size_t) {
+ abort ();
+}
+
+int main () {
+ if (__aeabi_vec_dtor_cookie (NULL, &dtor) != NULL)
+ return 1;
+ // These do not return values, but should not crash.
+ __aeabi_vec_delete (NULL, &dtor);
+ __aeabi_vec_delete3 (NULL, &dtor, &dealloc);
+ __aeabi_vec_delete3_nodtor (NULL, &dealloc);
+}
+#else
+int main () {}
+#endif
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-27 23:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-27 23:15 PATCH: Fix implementation of __aeabi_vec* Mark Mitchell
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).