---
name: "gelf_checksum"
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/elf32_checksum"
---

# gelf\_checksum(3)

return the checksum of an ELF object

Part of [elf32\_checksum(3)](/elf32_checksum/3.md).

## NAME

**elf32\_checksum**, **elf64\_checksum**, **gelf\_checksum** – return the checksum of an ELF object

## LIBRARY

library “libelf”

## SYNOPSIS

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

*long*\

**elf32\_checksum**(*Elf \*elf*);

*long*\

**elf64\_checksum**(*Elf \*elf*);

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

*long*\

**gelf\_checksum**(*Elf \*elf*);

## DESCRIPTION

These functions return a simple checksum of the ELF object described by their argument *elf*. The checksum is computed in way that allows its value to remain unchanged in presence of modifications to the ELF object by utilities like [strip(1)](/strip/1.md).

Function **elf32\_checksum**() returns a checksum for an ELF descriptor *elf* of class ELFCLASS32.

Function **elf64\_checksum**() returns a checksum for an ELF descriptor *elf* of class ELFCLASS64.

Function **gelf\_checksum**() provides a class-independent way retrieving the checksum for ELF object *elf*.

## RETURN VALUES

These functions return the checksum of the ELF object, or zero in case an error was encountered.

## ERRORS

These functions may fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* was NULL.

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* was not a descriptor for an ELF file.

- \[ELF\_E\_ARGUMENT\]

  The ELF descriptor *elf* was not opened for reading or updating.

- \[ELF\_E\_CLASS\]

  For functions **elf32\_checksum**() and **elf64\_checksum**(), ELF descriptor *elf* did not match the class of the called function.

- \[ELF\_E\_HEADER\]

  The ELF object specified by argument *elf* had a malformed executable header.

- \[ELF\_E\_RESOURCE\]

  An out of memory condition was detected during processing.

- \[ELF\_E\_SECTION\]

  The ELF object specified by argument *elf* contained a section with a malformed section header.

- \[ELF\_E\_VERSION\]

  The ELF object was of an unsupported version.

## SEE ALSO

[strip(1)](/strip/1.md), [elf(3)](/elf/3.md), [gelf(3)](/gelf/3.md)
