---
name: "elf_getbase"
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_getbase"
---

# elf\_getbase(3)

Retrieve the base offset for an ELF object file.

## NAME

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

## SYNOPSIS

**#include \<libelf.h\>**

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

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

- *elf*

  The ELF descriptor.

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

[**elf\_getaroff**(3)](/elf_getaroff/3.md), **elf\_rawelf**(3), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

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

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

## REPORTING BUGS

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