/*
* 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
*/
/*
*/
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <strings.h>
#include <dlfcn.h>
#include <debug.h>
#include <conv.h>
#include "msg.h"
#include "_libld.h"
/*
* dbg_setup() can be called a number of times. The typical use through
* LD_OPTIONS, results in dbg_setup() being called as the first argument to
* ld(1). It's also possible to pass debugging tokens through the compiler,
* for example -Wl,-Dlibs -Wl-Ddetail, in which case multiple dbg_setup()
* calls are made.
*
* A distinction is also made between diagnostics being requested before any
* other ld(1) options are read, or whether the debugging options occur
* between other options on the command line. In the latter case, the
* debugging options can be used to isolate diagnostics around one or more
* input files. The "phase" argument allows us to select which phase of
* dbg_setup() processing we should isolate ourselves to.
*
* dbg_print() can require the output filename for use in the diagnostics
* created. Save the address of the output filename pointer for this use.
*/
static int Phase = 0;
/* Debug file output state */
static struct {
} dbg_ofile = {
0
};
/*
* If there is an explicitly opened debug file, close it and reset the state.
*/
void
dbg_cleanup(void)
{
if (dbg_ofile.close_needed) {
dbg_ofile.close_needed = 0;
}
}
/*
* Process debug tokens. Returns True (1) on success, and False (0)
* on failure.
*/
int
{
const char *ofile;
if (Phase == 0)
return (1);
/*
* Call the debugging setup routine to initialize the mask and
* debug function array.
*/
return (0);
/*
* If output= token was used, close the old file if necessary
* and open a new one if the file name is not NULL.
*/
if (ofile) {
dbg_cleanup();
if (*ofile != '\0') {
return (0);
} else {
}
}
}
/*
* Now that the output file is established, identify the linker
* package, and generate help output if the user specified the
* debug help token.
*/
Dbg_version();
Dbg_help();
return (1);
}
/* PRINTFLIKE2 */
void
{
#if defined(lint)
/*
* The lml argument is only meaningful for diagnostics sent to ld.so.1.
* Supress the lint error by making a dummy assignment.
*/
#endif
/*
* Knock off any newline indicator to signify that a diagnostic has
* been processed.
*/
if (DBG_ISSNAME()) {
/*
* If the debugging options have requested each diagnostic line
* be prepended by a name create a prefix string.
*/
/*
* Select the fullname or basename of the output file
* being created.
*/
if (DBG_ISFNAME())
else {
if ((name =
else
name++;
}
/*
* Add the output file class if required.
*/
if (DBG_ISCLASS()) {
#if defined(_ELF64)
#else
#endif
}
/*
* Allocate a string to build the prefix.
*/
else {
if (DBG_ISCLASS())
}
}
} else
if (DBG_ISTIME()) {
if (DBG_ISTTIME())
if (DBG_ISDTIME())
DBG_DELTATIME = new;
}
}
}