Loading...
private/malloc_implementation.h libmalloc-317.121.1 libmalloc-474.0.13
--- libmalloc/libmalloc-317.121.1/private/malloc_implementation.h
+++ libmalloc/libmalloc-474.0.13/private/malloc_implementation.h
@@ -24,19 +24,58 @@
 /* Private interfaces between libsystem_malloc, libSystem, and MallocStackLogging */
 
 #include <malloc/malloc.h>
+#include <stack_logging.h>
 
 #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 ************/
+
+struct _malloc_msl_lite_hooks_s;
+
+struct _malloc_msl_symbols {
+	unsigned long version;
+
+	/* the following are included in version 1 of this structure */
+
+	void (*handle_memory_event) (unsigned long event);
+	boolean_t (*stack_logging_locked) (void);
+	void (*fork_prepare) (void);
+	void (*fork_parent) (void);
+	void (*fork_child) (void);
+
+	void (*set_flags_from_environment) (const char **env);
+	void (*initialize) ();
+	boolean_t (*turn_on_stack_logging) (stack_logging_mode_type mode);
+	void (*turn_off_stack_logging) ();
+	void (*copy_msl_lite_hooks) (struct _malloc_msl_lite_hooks_s *hooksp, size_t size);
+};
+
 
 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;
 };
 
 void __malloc_init(const char *apple[]);
@@ -49,7 +88,7 @@
  * This is SPI that is *not* intended for use elsewhere. It will change
  * and will eventually be removed, without prior warning.
  */
-#if MALLOC_ENABLE_MSL_LITE_SPI
+#if defined(MALLOC_ENABLE_MSL_LITE_SPI) && MALLOC_ENABLE_MSL_LITE_SPI
 
 typedef struct szone_s szone_t;
 
@@ -80,7 +119,7 @@
 	malloc_zone_t *(*basic_zone)(szone_t *zone);
 } _malloc_msl_lite_hooks_t;
 
-#endif // MALLOC_ENABLE_MSL_LITE_SPI
+#endif // defined(MALLOC_ENABLE_MSL_LITE_SPI) && MALLOC_ENABLE_MSL_LITE_SPI
 
 #endif