Enable '___cxa_demangle()' in libsupc++

From: Christian Prochaska <christian.prochaska@genode-labs.com>


---
 include/libiberty.h                |    4 ++++
 libiberty/cp-demangle.c            |    4 +++-
 libstdc++-v3/libsupc++/Makefile.in |   19 ++++++++++++++++++-
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/include/libiberty.h b/include/libiberty.h
index 141cb886a..0a8b54db5 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -46,7 +46,11 @@ extern "C" {
 /* Get a definition for va_list.  */
 #include <stdarg.h>
 
+#ifdef GENODE
+#define FILE void
+#else
 #include <stdio.h>
+#endif
 
 /* If the OS supports it, ensure that the supplied stream is setup to
    avoid any multi-threaded locking.  Otherwise leave the FILE pointer
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index cbfb2f937..a58820ae5 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -106,7 +106,9 @@
 #include "config.h"
 #endif
 
+#ifndef GENODE
 #include <stdio.h>
+#endif
 
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
@@ -6390,7 +6392,7 @@ d_demangle (const char *mangled, int options, size_t *palc)
   return dgs.buf;
 }
 
-#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3) || defined(GENODE)
 
 extern char *__cxa_demangle (const char *, char *, size_t *, int *);
 
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index a0a500eab..8c37ec251 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -168,7 +168,11 @@ am__objects_1 = array_type_info.lo atexit_arm.lo atexit_thread.lo \
 	del_opvsa.lo pbase_type_info.lo pmem_type_info.lo \
 	pointer_type_info.lo pure.lo si_class_type_info.lo tinfo.lo \
 	tinfo2.lo vec.lo vmi_class_type_info.lo vterminate.lo
+ifeq ($(GENODE),yes)
+am__objects_2 = cp-demangle.lo
+else
 @GLIBCXX_HOSTED_TRUE@am__objects_2 = cp-demangle.lo
+endif
 @ENABLE_VTABLE_VERIFY_TRUE@@VTV_CYGMIN_FALSE@am__objects_3 =  \
 @ENABLE_VTABLE_VERIFY_TRUE@@VTV_CYGMIN_FALSE@	vtv_stubs.lo
 am_libsupc___la_OBJECTS = $(am__objects_1) $(am__objects_2) \
@@ -491,8 +495,14 @@ bits_HEADERS = \
 	exception_defines.h exception_ptr.h hash_bytes.h nested_exception.h exception.h cxxabi_init_exception.h
 
 headers = $(std_HEADERS) $(bits_HEADERS)
+
+ifeq ($(GENODE),yes)
+c_sources = \
+  cp-demangle.c
+else
 @GLIBCXX_HOSTED_TRUE@c_sources = \
-@GLIBCXX_HOSTED_TRUE@	cp-demangle.c
+@GLIBCXX_HOSTED_TRUE@  cp-demangle.c
+endif
 
 sources = \
 	array_type_info.cc \
@@ -951,10 +961,17 @@ uninstall-am: uninstall-bitsHEADERS uninstall-stdHEADERS \
 cp-demangle.c:
 	rm -f $@
 	$(LN_S) $(toplevel_srcdir)/libiberty/cp-demangle.c $@
+ifeq ($(GENODE),yes)
+cp-demangle.lo: cp-demangle.c
+	$(LTCOMPILE) -DGENODE -Wno-error -c $<
+cp-demangle.o: cp-demangle.c
+	$(C_COMPILE) -DGENODE -Wno-error -c $<
+else
 cp-demangle.lo: cp-demangle.c
 	$(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
 cp-demangle.o: cp-demangle.c
 	$(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $<
+endif
 
 # Use special rules for the C++17 sources so that the proper flags are passed.
 new_opa.lo: new_opa.cc
