symdef.c revision ae115bc77f6fcde83175c75b4206dc2e50747966
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <libelf.h>
#include <gelf.h>
#include <errno.h>
/*
* symdef is a very simplified version of nm. It is used by upgrade and
* create_ramdisk in situations where we can't guarantee that nm will be around.
*
* Two arguments are expected: a binary and a symbol name. If the symbol is
* found in the name table of the binary, 0 is returned. If it is not found,
* 1 is returned. If an error occurs, a message is printed to stderr and -1
* is returned.
*/
static void
usage(void)
{
}
int
{
int fd = 0;
int rv = 1;
if (argc != 3) {
usage();
return (-1);
}
if (fd == -1) {
rv = -1;
goto done;
}
rv = -1;
goto done;
}
goto done;
continue;
rv = 0;
goto done;
}
}
}
done:
if (elfp)
if (fd != -1)
return (rv);
}