Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: libelf usage ?



Usage example:


kamloops$ ./a.out  /usr/lib/librumpnet_netinet6.a
symbol table error.
kamloops$ ./a.out  /usr/lib/librump_p.a | head
name: rumpns_cdbr_open_mem
name: rumpns_cdbr_entries
name: rumpns_cdbr_get
name: rumpns_cdbr_find
name: rumpns_cdbr_close
name: rumpns_consttime_memequal
name: rumpns_ptree_init
name: rumpns_ptree_insert_node
name: rumpns_ptree_insert_mask_node
name: rumpns_ptree_find_filtered_node
kamloops$ ./a.out  /usr/lib/libossaudio.a
name: _oss_ioctl

On 1/29/15, bch <brad.harder%gmail.com@localhost> wrote:
> 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