Loading...
private/malloc_implementation.h libmalloc-374.120.1 libmalloc-425.100.7
--- libmalloc/libmalloc-374.120.1/private/malloc_implementation.h
+++ libmalloc/libmalloc-425.100.7/private/malloc_implementation.h
@@ -29,6 +29,21 @@
 #ifndef _MALLOC_IMPLEMENTATION_H_
 #define _MALLOC_IMPLEMENTATION_H_
 
+#include <mach/boolean.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <ptrauth.h>
+
+#if defined(__PTRAUTH_INTRINSICS__) && __PTRAUTH_INTRINSICS__ && \
+		__has_builtin(__builtin_ptrauth_string_discriminator)
+#define LIBMALLOC_FUNCTION_PTRAUTH(f) \
+   __ptrauth(ptrauth_key_function_pointer, 1, \
+           __builtin_ptrauth_string_discriminator("libmalloc_functions_" # f) \
+   ) f
+#else
+#define LIBMALLOC_FUNCTION_PTRAUTH(f) f
+#endif
+
 
 /*********	Libsystem initializers ************/
 
@@ -56,8 +71,8 @@
 struct _malloc_late_init {
 	unsigned long version;
 	/* The following functions are included in version 1 of this structure */
-	void * (*dlopen) (const char *path, int mode);
-	void * (*dlsym) (void *handle, const char *symbol);
+	void * (*LIBMALLOC_FUNCTION_PTRAUTH(dlopen)) (const char *path, int mode);
+	void * (*LIBMALLOC_FUNCTION_PTRAUTH(dlsym)) (void *handle, const char *symbol);
 	bool internal_diagnostics;  /* os_variant_has_internal_diagnostics() */
 	/* The following are included in version 2 of this structure */
 	const struct _malloc_msl_symbols *msl;