/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "dis_target.h"
#include "dis_list.h"
#include "dis_util.h"
/*
* List support functions.
*
* Support routines for managing lists of sections and functions. We first
* process the command line arguments into lists of strings. For each target,
* functions to arrive at the set of objects to disassemble.
*
* We export two types of lists, namelists and resolvelists. The first is used
* to record names given as command line options. The latter is used to
* maintain the data objects specific to a given target.
*/
typedef struct unresolved_name {
typedef struct resolved_name {
static int current_mark = 0;
static void
initialize_pools(void)
{
"unresolved_pool", sizeof (unresolved_name_t),
"resolved_pool", sizeof (resolved_name_t),
if (unresolved_pool == NULL ||
resolved_pool == NULL)
die("out of memory");
}
/*
* Returns an empty list of unresolved names.
*/
dis_namelist_create(void)
{
/*
* If this is the first request to create a list, initialize the list
* pools.
*/
if (unresolved_pool == NULL)
die("out of memory");
return (listp);
}
/*
* Adds the given name to the unresolved list. 'value' is an arbitrary value
* which is preserved for this entry, even when resolved against a target. This
* allows the caller to associate similar behavior (such as the difference
* between -d, -D, and -s) without having to create multiple lists.
*/
void
{
}
/*
* Internal callback structure used
*/
typedef struct cb_data {
int cb_mark;
} cb_data_t;
/*
* For each section, walk the list of unresolved names and resolve those that
* correspond to real functions. We mark functions as we see them, and re-walk
* the list a second time to warn about functions we didn't find.
*
* This is an O(n * m) algorithm, but we typically search for only a single
* function.
*/
/* ARGSUSED */
static void
{
die("out of memory");
/*
* Mark the current node as seen
*/
/*
* Add the data to the resolved list
*/
resolved);
}
}
}
/*
* Take a list of unresolved names and create a resolved list of sections. We
* rely on walk_sections() to do the dirty work. After resolving the sections,
* we check for any unmarked names and warn the user about missing sections.
*/
{
/*
* Walk all sections in the target, calling walk_sections() for each
* one.
*/
die("out of memory");
/*
* Walk all elements of the unresolved list, and report any that we
* didn't mark in the process.
*/
die("out of memory");
warn("failed to find section '%s' in '%s'",
}
return (listp);
}
/*
* Similar to walk_sections(), but for functions.
*/
/* ARGSUSED */
static void
{
die("out of memory");
resolved);
}
}
}
/*
* Take a list of unresolved names and create a resolved list of functions. We
* rely on walk_functions() to do the dirty work. After resolving the
* functions, * we check for any unmarked names and warn the user about missing
* functions.
*/
{
die("out of memory");
/*
* Walk unresolved list and report any missing functions.
*/
die("out of memory");
warn("failed to find function '%s' in '%s'",
}
return (listp);
}
/*
* Returns true if the given list is empty.
*/
int
{
return (uu_list_numnodes(list) == 0);
}
static void
{
void *data;
die("out of memory");
}
}
/*
* Destroy a list of sections. First, walk the list and free the associated
* section data. Pass the list onto to free_list() to clean up the rest of the
* list.
*/
void
{
die("out of memory");
}
/*
* Destroy a list of functions. First, walk the list and free the associated
* function data. Pass the list onto to free_list() to clean up the rest of the
* list.
*/
void
{
die("out of memory");
}
/*
* Destroy a lis tof unresolved names.
*/
void
{
}
/*
* Iterate over a resolved list of sections.
*/
void
void *arg)
{
die("out of memory");
}
/*
* Iterate over a resolved list of functions.
*/
void
void *arg)
{
die("out of memory");
}