mirror of
				https://github.com/jart/cosmopolitan.git
				synced 2025-10-26 11:10:58 +00:00 
			
		
		
		
	add support for __cxa_demangle
This adds support for __cxa_demangle through the cxxabi.h file. At the moment it is the only symbol included. The source was taken from FreeBSD contrib/libcxxrt/libelftc_dem_gnu3.c 2176c9ab71c85efd90a6c7af4a9e04fe8e3d49ca FreeBSD does say this is also almost verbatim from ELFToolkit
This commit is contained in:
		
							parent
							
								
									0d3c1c8b1a
								
							
						
					
					
						commit
						a1dd777f22
					
				
					 3 changed files with 4442 additions and 0 deletions
				
			
		
							
								
								
									
										55
									
								
								third_party/libcxx/cxxabi.h
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								third_party/libcxx/cxxabi.h
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,55 @@ | |||
| #ifndef _CXXABI_H | ||||
| #define _CXXABI_H 1 | ||||
| 
 | ||||
| #include "third_party/libcxx/cstddef" | ||||
| 
 | ||||
| namespace abi { | ||||
| 
 | ||||
|    /**
 | ||||
|    *  @brief Demangling routine. | ||||
|    *  ABI-mandated entry point in the C++ runtime library for demangling. | ||||
|    * | ||||
|    *  @param __mangled_name A NUL-terminated character string | ||||
|    *  containing the name to be demangled. | ||||
|    * | ||||
|    *  @param __output_buffer A region of memory, allocated with | ||||
|    *  malloc, of @a *__length bytes, into which the demangled name is | ||||
|    *  stored.  If @a __output_buffer is not long enough, it is | ||||
|    *  expanded using realloc.  @a __output_buffer may instead be null; | ||||
|    *  in that case, the demangled name is placed in a region of memory | ||||
|    *  allocated with malloc. | ||||
|    * | ||||
|    *  @param __length If @a __length is non-null, the length of the | ||||
|    *  buffer containing the demangled name is placed in @a *__length. | ||||
|    * | ||||
|    *  @param __status If @a __status is non-null, @a *__status is set to | ||||
|    *  one of the following values: | ||||
|    *   0: The demangling operation succeeded. | ||||
|    *  -1: A memory allocation failure occurred. | ||||
|    *  -2: @a mangled_name is not a valid name under the C++ ABI mangling rules. | ||||
|    *  -3: One of the arguments is invalid. | ||||
|    * | ||||
|    *  @return A pointer to the start of the NUL-terminated demangled | ||||
|    *  name, or a null pointer if the demangling fails.  The caller is | ||||
|    *  responsible for deallocating this memory using @c free. | ||||
|    * | ||||
|    *  The demangling is performed using the C++ ABI mangling rules, | ||||
|    *  with GNU extensions. For example, this function is used in | ||||
|    *  __gnu_cxx::__verbose_terminate_handler. | ||||
|    * | ||||
|    *  See https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html
 | ||||
|    *  for other examples of use. | ||||
|    * | ||||
|    *  @note The same demangling functionality is available via | ||||
|    *  libiberty (@c <libiberty/demangle.h> and @c libiberty.a) in GCC | ||||
|    *  3.1 and later, but that requires explicit installation (@c | ||||
|    *  --enable-install-libiberty) and uses a different API, although | ||||
|    *  the ABI is unchanged. | ||||
|    */ | ||||
|   extern "C" char* | ||||
|   __cxa_demangle(const char* __mangled_name, char* __output_buffer, | ||||
| 		 size_t* __length, int* __status); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										4375
									
								
								third_party/libcxx/demangle.cc
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4375
									
								
								third_party/libcxx/demangle.cc
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										12
									
								
								third_party/libcxx/libcxx.mk
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								third_party/libcxx/libcxx.mk
									
										
									
									
										vendored
									
									
								
							|  | @ -67,6 +67,7 @@ THIRD_PARTY_LIBCXX_A_HDRS =					\ | |||
| 	third_party/libcxx/ctype.h				\
 | ||||
| 	third_party/libcxx/cwchar				\
 | ||||
| 	third_party/libcxx/cwctype				\
 | ||||
| 	third_party/libcxx/cxxabi.h				\
 | ||||
| 	third_party/libcxx/deque				\
 | ||||
| 	third_party/libcxx/errno.h				\
 | ||||
| 	third_party/libcxx/exception				\
 | ||||
|  | @ -143,6 +144,7 @@ THIRD_PARTY_LIBCXX_A_SRCS_CC =					\ | |||
| 	third_party/libcxx/chrono.cc				\
 | ||||
| 	third_party/libcxx/condition_variable.cc		\
 | ||||
| 	third_party/libcxx/condition_variable_destructor.cc	\
 | ||||
| 	third_party/libcxx/demangle.cc	\
 | ||||
| 	third_party/libcxx/exception.cc				\
 | ||||
| 	third_party/libcxx/functional.cc			\
 | ||||
| 	third_party/libcxx/future.cc				\
 | ||||
|  | @ -212,6 +214,16 @@ $(THIRD_PARTY_LIBCXX_A_OBJS): private				\ | |||
| 			-ffunction-sections			\
 | ||||
| 			-fdata-sections | ||||
| 
 | ||||
| # Super gross! But I found no way to do -fno-error=permissive
 | ||||
| # this steps from the fact that demangle is a C++ file extension
 | ||||
| # but the source I copied was written in C.
 | ||||
| # The fix would be to go through all the casts and make them correct.
 | ||||
| o/$(MODE)/third_party/libcxx/demangle.o: private				\ | ||||
| 		CXXFLAGS +=							\
 | ||||
| 			-fpermissive					\
 | ||||
| 			-Wno-error | ||||
| 
 | ||||
| 
 | ||||
| THIRD_PARTY_LIBCXX_LIBS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x))) | ||||
| THIRD_PARTY_LIBCXX_SRCS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x)_SRCS)) | ||||
| THIRD_PARTY_LIBCXX_HDRS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x)_HDRS)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue