---
name: "elf_getident"
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_getident"
---

# elf\_getident(3)

return the initial bytes of a file

## NAME

**elf\_getident** – return the initial bytes of a file

## LIBRARY

library “libelf”

## SYNOPSIS

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

*char* *\**\

**elf\_getident**(*Elf \*elf*, *size\_t \*sz*);

## DESCRIPTION

Function **elf\_getident**() returns a pointer to the initial bytes of the file for descriptor *elf*.

If argument *sz* is non-null, the size of the identification area returned is written to the location pointed to by *sz*. This location is set to zero on errors.

## RETURN VALUES

Function **elf\_getident**() will return a non-NULL pointer to the initial bytes of the file if successful, or NULL if an error condition is detected.

## ERRORS

Function **elf\_getident**() can fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  A NULL value was passed in for argument *elf*.

- \[ELF\_E\_SEQUENCE\]

  ELF descriptor *elf* was opened for writing and function **elf\_getident**() was called before a call to [elf\_update(3)](/elf_update/3.md).

## SEE ALSO

[elf(3)](/elf/3.md), [elf32\_getehdr(3)](/elf32_getehdr/3.md), [elf64\_getehdr(3)](/elf64_getehdr/3.md), [elf\_getarhdr(3)](/elf_getarhdr/3.md), [elf\_getbase(3)](/elf_getbase/3.md), elf\_getflags(3), [elf\_kind(3)](/elf_kind/3.md), [elf\_rawfile(3)](/elf_rawfile/3.md), [elf\_update(3)](/elf_update/3.md), [gelf(3)](/gelf/3.md), [gelf\_getclass(3)](/gelf_getclass/3.md), [gelf\_getehdr(3)](/gelf_getehdr/3.md)
