/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* LINTLIBRARY */
#include <link.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <limits.h>
#include "rtld.h"
#include "_crle.h"
#include "msg.h"
/*
* This file provides the LD_AUDIT interfaces for libcrle.so.1, which are
* called for one of two reasons:
*
* CRLE_AUD_DEPENDS
* under this mode, the dependencies of the application are
* gathered (similar to ldd(1)) and written back to the calling
* process.
*
* CRLE_AUD_DLDUMP
* under this mode, the LD_CONFIG file is read to determine which
* objects are to be dldump()'ed. The memory range occupied by
* the dumped images is written back to the calling process.
*
* Both of these interfaces are invoked via the crle(1) calling process. The
* following environment variables are used to communicate between the two:
*
* CRLE_FD the file descriptor on which to communicate to the calling
* process (used for CRLE_AUD_DEPENDS and CRLE_AUD_DUMP).
*
* CRLE_FLAGS this signals CRLE_AUD_DLDUMP mode, and indicates the required
* flags for the dldump(3x) calls.
*/
static int auflag;
int pfd;
/*
* Initial audit handshake, establish audit mode.
*/
/* ARGSUSED */
{
char *str;
/*
* Establish the file desciptor to communicate with the calling process,
* If there are any errors terminate the process.
*/
exit(1);
/*
* Determine which audit mode is required based on the existance of
* CRLE_FLAGS.
*/
} else {
/*
* Fill any memory holes before anything gets mapped.
*/
if (filladdr() != 0)
exit(1);
}
/*
* We need the audit interface containing la_objfilter().
*/
return (LAV_VERSION3);
}
/*
* Audit interface called for each dependency. If in CRLE_AUD_DEPENDS mode,
* return each dependency of the primary link-map to the caller.
*/
/* ARGSUSED2 */
{
if (auflag == CRLE_AUD_DLDUMP)
return (0);
if ((lmid == LM_ID_BASE) &&
} else
return (0);
}
/*
*/
int
/* ARGSUSED2 */
{
if (auflag == CRLE_AUD_DLDUMP)
return (0);
}
return (1);
}
/*
* Audit interface called before transfer of control to application. If in
* CRLE_AUD_DLDUMP mode read the configuration file and dldump() all necessary
* objects.
*/
void
/* ARGSUSED */
{
if (auflag == CRLE_AUD_DLDUMP) {
if (dumpconfig() != 0)
exit(1);
}
exit(0);
}