Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
libelf usage ?
I feel pretty comfortable posting this here --
working w/ libelf, and getting select failures on librump_* archives
(trying to list symbol tables) -- nm *does* work -- but for _all_ the
other .a files I process, the following works fine -- is there
something with our ar(1) or elf(3) that they're incompatible w/ ea.
other ?
#include <libelf.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
Elf *elf, *ae;
Elf_Arsym *symtbl;
int fd;
if (2!=argc) {
fprintf(stderr, "Usage: %s <ar_file>\n", argv[0]);
exit(1);
}
elf_version(EV_CURRENT);
fd = open(argv[1], O_RDONLY);
elf = elf_begin(fd, ELF_C_READ, (Elf *) NULL);
symtbl = elf_getarsym(elf, NULL);
if (NULL != symtbl) {
while (symtbl->as_name) {
fprintf(stdout, "name: %s\n", symtbl->as_name);
symtbl++;
}
close(fd);
elf_end(elf);
} else {
fprintf(stderr, "symbol table error.\n");
exit(1);
}
}
Home |
Main Index |
Thread Index |
Old Index