/*
* 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) 1994, by Sun Microsytems, Inc.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Generic functions that know how to traverse elf sections in an object.
* Also functions that know how to traverse records in a section.
*
*/
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include "tnfctl_int.h"
#include "dbg.h"
/*
* _tnfctl_traverse_object() - traverses all of the elf sections in an object,
* calling the supplied function on each.
*/
{
char *strs;
"sunw%verbosity 3",
return (TNFCTL_ERR_INTERNAL);
/* open elf descriptor on the fd */
"sunw%verbosity 3; sunw%debug 'not elf object'");
return (TNFCTL_ERR_INTERNAL);
}
/* get the elf header */
"_tnfctl_traverse_object: gelf_getehdr failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
"_tnfctl_traverse_object: not an "
"executable or a shared object\n"));
return (TNFCTL_ERR_INTERNAL);
}
/* if an executable file, the base address is 0 */
addr = 0;
/* get a pointer to the elf header string table */
"sunw%verbosity 3",
"_tnfctl_traverse_object: elf_getscn failed\n"));
break;
}
"_tnfctl_traverse_obj:gelf_getshdr failed\n"));
break;
}
"_tnfctl_traverse_obj:gelf_getdata failed\n"));
break;
}
/* call the supplied function */
if (prexstat)
break;
}
return (prexstat);
} /* end _tnfctl_traverse_object */
/*
* _tnfctl_traverse_rela() - this function traverses a .rela section calling the
* supplied function on each relocation record.
*/
/*ARGSUSED*/
{
char *str_table;
uint_t i;
char *ptr;
"sunw%verbosity 4");
/* bail if this isn't a rela (or rel) section */
} else
return (TNFCTL_ERR_NONE);
/* find the symbol table section associated with this rela section */
"_tnfctl_traverse_rela:elf_getscn (sym) failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
"_tnfctl_traverse_rela:gelf_getshdr (sym) failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
"_tnfctl_traverse_rela:elf_getdata (sym) failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
/* find the string table associated with the symbol table */
"_tnfctl_traverse_rela:elf_getscn (str) failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
"_tnfctl_traverse_rela:gelf_getshdr (str) failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
"_tnfctl_traverse_rela: elf_getdata (str) failed\n"));
return (TNFCTL_ERR_INTERNAL);
}
/* loop over each relocation record */
"sunw%verbosity 3",
char *name;
/* decode the r_info field of the relocation record */
if (isrela) {
/*LINTED pointer cast may result in improper alignment*/
} else {
/*LINTED pointer cast may result in improper alignment*/
}
/* find the associated symbol table entry */
if (!syminfo)
continue;
/* find the associated string table entry */
continue;
if (prexstat)
break;
}
return (TNFCTL_ERR_NONE);
} /* end _tnfctl_traverse_rela */
/*
* _tnfctl_traverse_dynsym() - this function traverses a dynsym section calling
* the supplied function on each symbol.
*/
/*ARGSUSED*/
char *elfstrs,
{
int i;
char *strs;
/* bail if this isn't a dynsym section */
return (TNFCTL_ERR_NONE);
#if 0
printf("### entering _tnfctl_traverse_dynsym...\n");
#endif
"sunw%verbosity 3",
for (i = 0; i < nsyms; i++) {
char *name;
#if 0
if (name != 0)
else
printf("_tnfctl_traverse_dynsym: name is 0\n");
#endif
if (prexstat)
break;
}
#if 0
printf("### leaving _tnfctl_traverse_dynsym...\n");
#endif
return (prexstat);
} /* end _tnfctl_traverse_dynsym */