--- old/usr/src/tools/smatch/src/check_free.c	2019-03-18 19:38:48.328120091 +0000
+++ new/usr/src/tools/smatch/src/check_free.c	2019-03-18 19:38:48.345088362 +0000
@@ -290,6 +290,9 @@
 
 	add_function_hook("free", &match_free, INT_PTR(0));
 
+	if (option_project == PROJ_ILLUMOS_USER)
+		add_function_hook("libld_free", &match_free, INT_PTR(0));
+
 	if (option_spammy)
 		add_hook(&match_symbol, SYM_HOOK);
 	add_hook(&match_dereferences, DEREF_HOOK);
--- old/usr/src/tools/smatch/src/check_freeing_null.c	2019-03-18 19:38:48.849663609 +0000
+++ new/usr/src/tools/smatch/src/check_freeing_null.c	2019-03-18 19:38:48.869096686 +0000
@@ -40,8 +40,12 @@
 	my_id = id;
 	if (!option_spammy)
 		return;
-	if (option_project == PROJ_KERNEL)
+	if (option_project == PROJ_KERNEL) {
 		add_function_hook("kfree", &match_free, NULL);
-	else
+	} else {
 		add_function_hook("free", &match_free, NULL);
+	}
+
+	if (option_project == PROJ_ILLUMOS_USER)
+		add_function_hook("libld_free", &match_free, NULL);
 }
--- old/usr/src/tools/smatch/src/check_frees_argument.c	2019-03-18 19:38:49.378293682 +0000
+++ new/usr/src/tools/smatch/src/check_frees_argument.c	2019-03-18 19:38:49.396126254 +0000
@@ -138,6 +138,10 @@
 		add_function_hook("kfree", &match_kfree, NULL);
 	else
 		add_function_hook("free", &match_kfree, NULL);
+
+	if (option_project == PROJ_ILLUMOS_USER)
+		add_function_hook("libld_free", &match_kfree, NULL);
+
 	add_hook(&match_return, RETURN_HOOK);
 	add_hook(&match_end_func, END_FUNC_HOOK);
 	add_hook(&match_after_func, AFTER_FUNC_HOOK);
--- old/usr/src/tools/smatch/src/check_frees_param.c	2019-03-18 19:38:49.904369988 +0000
+++ new/usr/src/tools/smatch/src/check_frees_param.c	2019-03-18 19:38:49.922883390 +0000
@@ -114,6 +114,8 @@
 	add_hook(&match_function_def, FUNC_DEF_HOOK);
 
 	add_function_hook("free", &match_free, INT_PTR(0));
+	if (option_project == PROJ_ILLUMOS_USER)
+		add_function_hook("libld_free", &match_free, INT_PTR(0));
 
 	select_return_implies_hook(PARAM_FREED, &set_param_freed);
 	add_modification_hook(my_id, &set_ignore);
--- old/usr/src/tools/smatch/src/check_kmalloc_wrong_size.c	2019-03-18 19:38:50.400283520 +0000
+++ new/usr/src/tools/smatch/src/check_kmalloc_wrong_size.c	2019-03-18 19:38:50.417690158 +0000
@@ -84,12 +84,14 @@
 {
 	my_id = id;
 
-	if (option_project != PROJ_KERNEL) {
-		add_function_assign_hook("malloc", &match_alloc, NULL);
-		add_function_assign_hook("calloc", &match_calloc, INT_PTR(1));
-		return;
+	if (option_project == PROJ_KERNEL) {
+		add_function_assign_hook("kmalloc", &match_alloc, NULL);
+		add_function_assign_hook("kcalloc", &match_calloc, INT_PTR(1));
 	}
+	
+	add_function_assign_hook("malloc", &match_alloc, NULL);
+	add_function_assign_hook("calloc", &match_calloc, INT_PTR(1));
 
-	add_function_assign_hook("kmalloc", &match_alloc, NULL);
-	add_function_assign_hook("kcalloc", &match_calloc, INT_PTR(1));
+	if (option_project == PROJ_ILLUMOS_USER)
+		add_function_assign_hook("libld_calloc", &match_calloc, INT_PTR(1));
 }
--- old/usr/src/tools/smatch/src/check_leaks.c	2019-03-18 19:38:50.922353502 +0000
+++ new/usr/src/tools/smatch/src/check_leaks.c	2019-03-18 19:38:50.940155720 +0000
@@ -46,13 +46,6 @@
 
 static void set_parent(struct expression *expr, struct smatch_state *state);
 
-static const char *allocation_funcs[] = {
-	"malloc",
-	"kmalloc",
-	"kzalloc",
-	"kmemdup",
-};
-
 static char *alloc_parent_str(struct symbol *sym)
 {
 	static char buf[256];
@@ -253,13 +246,23 @@
 
 void check_leaks(int id)
 {
-	int i;
-
 	my_id = id;
 
-	for (i = 0; i < ARRAY_SIZE(allocation_funcs); i++)
-		add_function_assign_hook(allocation_funcs[i], &match_alloc, NULL);
-
+	switch (option_project) {
+	case PROJ_KERNEL:
+		add_function_assign_hook("kmalloc", &match_alloc, NULL);
+		add_function_assign_hook("kzalloc", &match_alloc, NULL);
+		add_function_assign_hook("kmemdup", &match_alloc, NULL);
+		break;
+	case PROJ_ILLUMOS_USER:
+		add_function_assign_hook("libld_malloc", &match_alloc, NULL);
+		add_function_assign_hook("libld_calloc", &match_alloc, NULL);
+		/* FALLTHROUGH */
+	default:
+		add_function_assign_hook("malloc", &match_alloc, NULL);
+		add_function_assign_hook("calloc", &match_alloc, NULL);
+	}
+	
 	add_hook(&match_condition, CONDITION_HOOK);
 
 	add_hook(&match_function_call, FUNCTION_CALL_HOOK);
--- old/usr/src/tools/smatch/src/check_memory.c	2019-03-18 19:38:51.410469229 +0000
+++ new/usr/src/tools/smatch/src/check_memory.c	2019-03-18 19:38:51.427575587 +0000
@@ -462,5 +462,8 @@
 		register_funcs_from_file();
 	} else {
 		add_function_hook("free", &match_free_func, (void *)0);
+		if (option_project == PROJ_ILLUMOS_USER)
+			add_function_hook("libld_free", &match_free_func,
+			    (void *)0);
 	}
 }
--- old/usr/src/tools/smatch/src/smatch_buf_comparison.c	2019-03-18 19:38:51.926450320 +0000
+++ new/usr/src/tools/smatch/src/smatch_buf_comparison.c	2019-03-18 19:38:51.945319480 +0000
@@ -586,6 +586,10 @@
 		add_allocation_function("devm_kcalloc", &match_calloc, 1);
 		add_allocation_function("kmalloc_array", &match_calloc, 0);
 		add_allocation_function("krealloc", &match_alloc, 1);
+	} else if (option_project == PROJ_ILLUMOS_USER) {
+		add_allocation_function("libld_malloc", &match_alloc, 0);
+		add_allocation_function("libld_calloc", &match_calloc, 0);
+		add_allocation_function("libld_realloc", &match_calloc, 1);
 	}
 
 	add_hook(&array_check, OP_HOOK);
--- old/usr/src/tools/smatch/src/smatch_buf_size.c	2019-03-18 19:38:52.393948595 +0000
+++ new/usr/src/tools/smatch/src/smatch_buf_size.c	2019-03-18 19:38:52.410970965 +0000
@@ -911,6 +911,10 @@
 		add_allocation_function("alloc_pages", &match_alloc_pages, 1);
 		add_allocation_function("alloc_pages_current", &match_alloc_pages, 1);
 		add_allocation_function("__get_free_pages", &match_alloc_pages, 1);
+	} else if (option_project == PROJ_ILLUMOS_USER) {
+		add_allocation_function("libld_malloc", &match_alloc, 0);
+		add_allocation_function("libld_realloc", &match_alloc, 1);
+		add_allocation_function("libld_calloc", &match_calloc, 0);
 	}
 
 	add_allocation_function("strndup", match_strndup, 0);
--- old/usr/src/tools/smatch/src/smatch_constraints_required.c	2019-03-18 19:38:52.904357967 +0000
+++ new/usr/src/tools/smatch/src/smatch_constraints_required.c	2019-03-18 19:38:52.920858302 +0000
@@ -26,6 +26,11 @@
 	int param2;
 };
 
+static struct allocator illumos_user_allocator_table[] = {
+	{"libld_malloc", 0},
+	{"libld_realloc", 1},
+};
+
 static struct allocator generic_allocator_table[] = {
 	{"malloc", 0},
 	{"memdup", 1},
@@ -49,13 +54,24 @@
 	{"krealloc", 1},
 };
 
-static struct allocator calloc_table[] = {
+static struct allocator illumos_user_calloc_table[] = {
+	{"libld_calloc", 0, 1},
 	{"calloc", 0, 1},
 	{"kcalloc", 0, 1},
 	{"kmalloc_array", 0, 1},
 	{"devm_kcalloc", 1, 2},
 };
 
+static struct allocator generic_calloc_table[] = {
+	{"calloc", 0, 1},
+};
+
+static struct allocator kernel_calloc_table[] = {
+	{"kcalloc", 0, 1},
+	{"kmalloc_array", 0, 1},
+	{"devm_kcalloc", 1, 2},
+};
+
 static int bytes_per_element(struct expression *expr)
 {
 	struct symbol *type;
@@ -324,6 +340,32 @@
 		}
 	}
 
+	for (i = 0; i < ARRAY_SIZE(generic_calloc_table); i++) {
+		if (strcmp(right->fn->symbol->ident->name,
+			   generic_calloc_table[i].func) == 0) {
+			size_arg = generic_calloc_table[i].param;
+			size_arg2 = generic_calloc_table[i].param2;
+			goto found;
+		}
+	}	
+
+	if (option_project == PROJ_ILLUMOS_USER) {
+		if (strcmp(right->fn->symbol->ident->name,
+			   illumos_user_allocator_table[i].func) == 0) {
+			size_arg = illumos_user_allocator_table[i].param;
+			goto found;
+		}
+
+		for (i = 0; i < ARRAY_SIZE(illumos_user_calloc_table); i++) {
+			if (strcmp(right->fn->symbol->ident->name,
+			    illumos_user_calloc_table[i].func) == 0) {
+				size_arg = illumos_user_calloc_table[i].param;
+				size_arg2 = illumos_user_calloc_table[i].param2;
+				goto found;
+			}
+		}
+	}
+
 	if (option_project != PROJ_KERNEL)
 		return;
 
@@ -335,11 +377,11 @@
 		}
 	}
 
-	for (i = 0; i < ARRAY_SIZE(calloc_table); i++) {
+	for (i = 0; i < ARRAY_SIZE(kernel_calloc_table); i++) {
 		if (strcmp(right->fn->symbol->ident->name,
-			   calloc_table[i].func) == 0) {
-			size_arg = calloc_table[i].param;
-			size_arg2 = calloc_table[i].param2;
+			   kernel_calloc_table[i].func) == 0) {
+			size_arg = kernel_calloc_table[i].param;
+			size_arg2 = kernel_calloc_table[i].param2;
 			goto found;
 		}
 	}
@@ -467,7 +509,12 @@
 	add_allocation_function("malloc", &match_alloc, 0);
 	add_allocation_function("memdup", &match_alloc, 1);
 	add_allocation_function("realloc", &match_alloc, 1);
-	add_allocation_function("realloc", &match_calloc, 0);
+	add_allocation_function("calloc", &match_calloc, 0);
+	if (option_project == PROJ_ILLUMOS_USER) {
+		add_allocation_function("libld_malloc", &match_alloc, 0);
+		add_allocation_function("libld_realloc", &match_alloc, 1);
+		add_allocation_function("libld_calloc", &match_calloc, 0);
+	}
 	if (option_project == PROJ_KERNEL) {
 		add_allocation_function("kmalloc", &match_alloc, 0);
 		add_allocation_function("kzalloc", &match_alloc, 0);
