{
memset(lte, 0, sizeof *lte);
lte->fd = open(filename, O_RDONLY);
- if (lte->fd == -1)
+ if (lte->fd == -1) {
+ fprintf(stderr, "Can't open %s: %s\n", filename,
+ strerror(errno));
return 1;
+ }
elf_version(EV_CURRENT);
return 0;
}
-static void
+void
delete_symbol_chain(struct library_symbol *libsym)
{
while (libsym != NULL) {
populate_this_symtab(struct process *proc, const char *filename,
struct ltelf *lte, struct library *lib,
Elf_Data *symtab, const char *strtab, size_t count,
- struct library_exported_name **names)
+ struct library_exported_names *names)
{
- /* If a valid NAMES is passed, we pass in *NAMES a list of
- * symbol names that this library exports. */
- if (names != NULL)
- *names = NULL;
-
/* Using sorted array would be arguably better, but this
* should be well enough for the number of symbols that we
* typically deal with. */
/* If we are interested in exports, store this name. */
if (names != NULL) {
- struct library_exported_name *export
- = malloc(sizeof *export);
char *name_copy = strdup(name);
-
- if (name_copy == NULL || export == NULL) {
- free(name_copy);
- free(export);
+ if (name_copy == NULL ||
+ library_exported_names_push(names,
+ sym.st_value,
+ name_copy, 1) != 0)
+ {
fprintf(stderr, "Couldn't store symbol %s. "
"Tracing may be incomplete.\n", name);
- } else {
- export->name = name_copy;
- export->own_name = 1;
- export->next = *names;
- *names = export;
}
}
/* Check whether we want to trace symbols implemented by this
* library (-l). */
- struct library_exported_name **names = NULL;
+ struct library_exported_names *names = NULL;
if (exports) {
debug(DEBUG_FUNCTION, "-l matches %s", lib->soname);
names = &lib->exported_names;