/*
* CDDL HEADER START
*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
* This file implements an audit library that can be used to force the loading
* of helper providers. The default disposition for a helper provider -- USDT
* and ustack helpers -- is to load itself from it's containing object's .init
* section. In cases where startup time is deemed critical, USDT authors can
* use the -xlazyload option to dtrace(1M) to disable automatic loading (it's
* difficult to make the case for the utility of this feature for anything
* other than libc which, indeed, was the sole motivation). If a binary has
* been compiled with automatic loading disabled, this audit library may be
* used to force automatic loading:
*
* LD_AUDIT_32=/usr/lib/dtrace/libdaudit.so
* LD_AUDIT_64=/usr/lib/dtrace/64/libdaudit.so
*/
#include <link.h>
#include <stdio.h>
#include <libproc.h>
#include <strings.h>
#include <dlink.h>
typedef struct obj_list {
char *ol_name;
} obj_list_t;
#pragma init(dtrace_daudit_init)
static void
dtrace_daudit_init(void)
{
}
/*ARGSUSED*/
{
return (LAV_CURRENT);
}
/*
* Record objects into our linked list as they're loaded.
*/
/*ARGSUSED*/
{
/*
* If we can't allocate the next node in our list, we'll try to emit a
* message, but it's possible that might fail as well.
*/
dprintf(0, "libdaudit: failed to allocate");
return (0);
}
return (0);
}
/*
* Once the link maps have reached a consistent state, process the list of
* objects that were loaded. We need to use libproc to search for the
* ___SUNW_dof symbol rather than dlsym(3C) since the symbol is not in the
* dynamic (run-time) symbol table (though it is, of course, in the symtab).
* Once we find it, we ioctl(2) it to the kernel just as we would have from
* the .init section if automatic loading were enabled.
*/
/*ARGSUSED*/
void
{
struct ps_prochandle *P;
if (flags != LA_ACT_CONSISTENT)
return;
Prelease(P, 0);
if (ret == 0) {
}
}
}