---
name: "elf_getbase"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_getbase"
---

# elf\_getbase(3)

get the base offset for an object file

## NAME

**elf\_getbase** – get the base offset for an object file

## LIBRARY

library “libelf”

## SYNOPSIS

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

*off\_t*\

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

## DESCRIPTION

Function **elf\_getbase**() returns the file offset to the first byte of the object referenced by ELF descriptor *elf*.

For descriptors referencing members of archives, the returned offset is the file offset of the member in its containing archive. For descriptors to regular objects, the returned offset is (vacuously) zero.

## RETURN VALUES

Function **elf\_getbase**() returns a valid file offset if successful, or (*off\_t*) -1 in case of an error.

## ERRORS

Function **elf\_getbase**() may fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* was NULL.

## SEE ALSO

[elf(3)](/elf/3.md), [elf\_getarhdr(3)](/elf_getarhdr/3.md), [elf\_getident(3)](/elf_getident/3.md), [elf\_rawfile(3)](/elf_rawfile/3.md), [gelf(3)](/gelf/3.md)
