rdelf.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 (c) 1998 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ELF support routines for processing versioned mon.out files.
*/
#include "profv.h"
bool
is_shared_obj(char *name)
{
int fd;
}
}
}
}
return (TRUE);
else
return (FALSE);
}
static void
{
for (i = 1; i < *nfuncs; i++) {
/*
* If current value is different from prev, proceed.
*/
prev = i;
continue;
}
/*
* If current and prev have the syminfo, rm the latter.
*/
continue;
}
/*
* Remove the one with STT_NOTYPE and keep the other.
*/
if (prev_type != STT_NOTYPE)
else {
prev = i;
}
continue;
}
/*
* If they have the same type, take the stronger bound
* function
*/
else {
prev = i;
}
}
/*
* Actually remove the cleared symbols from namelist. We're not
* truncating namelist by realloc, though.
*/
;
ndx = i;
ndx++;
}
}
}
int
{
return (-1);
return (1);
else
return (0);
}
static int
{
/*
* With dynamic linking, it is possible that certain undefined
* symbols exist in the objects. The actual definition will be
* found elsewhere, so we'll just skip it for this object.
*/
return (0);
return (1);
return (1);
return (1);
}
/*
* It's not a function; determine if it's in an executable section.
*/
return (0);
/*
* If it isn't global, and it isn't weak, and it isn't
* a 'local with the gflag set', then get out.
*/
return (0);
return (0);
return (0);
return (1);
}
static void
{
continue;
"more than 2^32 symbols", cmdname);
}
}
/*
* If we've found a real symbol table, we're done.
*/
break;
}
}
}
}
/*
* Now we need to cruise through the symbol table eliminating
* all non-functions from consideration, and making strings
* real.
*/
nfuncs = 0;
for (i = 1; i < nsyms; i++) {
char *name;
/*
* We're interested in this symbol if it's a function
*/
npe++;
nfuncs++;
}
}
}
/*
* And finally, sort the symbols by increasing address
* and remove the duplicates.
*/
(int(*)(const void *, const void *)) cmp_by_address);
}
static GElf_Addr
{
GElf_Addr txt_origin = 0;
bool first_load_seg = TRUE;
}
continue;
if (first_load_seg)
}
}
return (txt_origin);
}
void
{
int fd;
}
}
}
"this class of object\n", cmdname);
}
}