---
name: "elf_getarsym"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_getarsym"
---

# elf\_getarsym(3)

retrieve archive symbol table

## 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

- *elf*

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

- *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

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_begin/3.md), [**elf\_getarhdr**(3)](/elf_getarhdr/3.md), [**elf\_next**(3)](/elf_next/3.md), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

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

## REPORTING BUGS

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