Scroll to navigation

ELF_GETARSYM(3) Libelf Programmer's Manual ELF_GETARSYM(3)

NAME

elf_getarsym - retrieve archive symbol table

SYNOPSIS

#include <libelf.h>
Elf_Arsym *elf_getarsym(Elf *elf, size_t *narsyms);"

DESCRIPTION

Retrieve the archive symbol table from the archive file associated with elf.

If the archive contains a symbol table, elf_getarsym() returns a pointer to an array of Elf_Arsym structures describing each symbol. Also store the number of symbols in this array in narsyms if not NULL.

Elf_Arsym has the following layout:

typedef struct {

char *as_name; /* Symbol name (null-terminated). */
int64_t as_off; /* File offset of defining archive member. */
uint64_t as_hash; /* Hash value of symbol name. */ } Elf_Arsym;

The last entry in the archive symbol table is the special entry { NULL, 0, ~0L}. This can be used to find the end of the table if narsyms is NULL.

PARAMETERS

An ELF descriptor referring to an archive file, obtained by calling elf_begin(3) on an archive.

A pointer to a size_t in which the number of entries in the symbol table will be stored if this pointer is not NULL.

RETURN VALUE

If the archive contains a symbol table, return a pointer to an array of Elf_Arsym structures, including the special NULL entry indicating the the end of the table. Sets *narsyms to the number of entries in the array (if narsyms is not NULL). These pointers are managed by libelf and should not be freed by the caller of elf_getarsym.

If the archive does not contain a symbol table or elf is not a valid archive descriptor, elf_getarsym returns NULL.

SEE ALSO

elf_begin(3), elf_getarhdr(3), elf_next(3), libelf(3), elf(5)

ATTRIBUTES

Interface Attribute Value
elf_getarsym () Thread safety MT-Safe

REPORTING BUGS

Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.

2025-06-06 Libelf