ELF\_GETARSYM(3) Libelf Programmer's Manual ELF\_GETARSYM(3)

# [NAME](#NAME)

elf\_getarsym - retrieve archive symbol table

# [SYNOPSIS](#SYNOPSIS)

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

# [DESCRIPTION](#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](#PARAMETERS)

[*elf*](#elf)

An ELF descriptor referring to an archive file, obtained by calling [**elf\_begin**(3)](/man/os/elfutils/elf_begin.3) on an archive.

[*narsyms*](#narsyms)

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](#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](#SEE_ALSO)

[**elf\_begin**(3)](/man/os/elfutils/elf_begin.3), [**elf\_getarhdr**(3)](/man/os/elfutils/elf_getarhdr.3), [**elf\_next**(3)](/man/os/elfutils/elf_next.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

**Interface** **Attribute** **Value** elf\_getarsym () Thread safety MT-Safe

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;elfutils-devel@sourceware.org&gt; or https://sourceware.org/bugzilla/.

2025-06-06 Libelf

---

Document: elf_getarsym(3) from elfutils 0.197-r0 (Chainguard OS)
Source: https://sourceware.org/git/elfutils.git
