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

# [NAME](#NAME)

elf\_getbase - Retrieve the base offset for an ELF object file.

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;libelf.h&gt;**

**int64\_t elf\_getbase(Elf \*elf);**

# [DESCRIPTION](#DESCRIPTION)

**elf\_getbase** returns the file offset of the first byte of the ELF descriptor *elf*. If *elf* is a member of an archive and has ELF kind **ELF\_K\_AR**, the base offset is the offset of the ELF object within the archive. For other ELF object types the base offset is 0.

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

The ELF descriptor.

# [RETURN VALUE](#RETURN_VALUE)

Return the base offset of *elf* if its ELF kind is **ELF\_K\_AR**, otherwise return 0. If *elf* is NULL, return -1.

# [SEE ALSO](#SEE_ALSO)

[**elf\_getaroff**(3)](/man/os/elfutils/elf_getaroff.3), [**elf\_rawelf**(3)](/man/os/elfutils/elf_rawelf.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

For an explanation of the terms used in this section, see [**attributes**(7)](/man/os/elfutils/attributes.7).

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

# [REPORTING BUGS](#REPORTING_BUGS)

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

2025-03-31 Libelf

---

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