---
name: "elf_end"
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_end"
---

# elf\_end(3)

release an ELF descriptor

## NAME

**elf\_end** – release an ELF descriptor

## LIBRARY

library “libelf”

## SYNOPSIS

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

*int*\

**elf\_end**(*Elf \*elf*);

## DESCRIPTION

Function **elf\_end**() is used to release the resources associated with an ELF descriptor pointed to by argument *elf*. This descriptor must have been allocated by a previous call to [elf\_begin(3)](/elf_begin/3.md) or [elf\_memory(3)](/elf_memory/3.md). For programming convenience, a NULL value is permitted for argument *elf*.

A call to **elf\_end**() decrements the activation count for descriptor *elf* by one. The resources associated with the descriptor are only released with its activation count goes to zero.

Once function **elf\_end**() returns zero, the ELF descriptor *elf* will no longer be valid and should not be used further.

## RETURN VALUES

Function **elf\_end**() returns the current value of the ELF descriptor *elf*'s activation count, or zero if argument *elf* was NULL.

## SEE ALSO

[elf(3)](/elf/3.md), [elf\_begin(3)](/elf_begin/3.md), [elf\_memory(3)](/elf_memory/3.md), [gelf(3)](/gelf/3.md)
