GELF\_GETCLASS(3) Libelf Programmer's Manual GELF\_GETCLASS(3)

# [NAME](#NAME)

gelf\_getclass - return the ELF class (32-bit or 64-bit) for an object

# [SYNOPSIS](#SYNOPSIS)

```
#include <gelf.h>
int gelf_getclass(Elf *elf);
```

# [DESCRIPTION](#DESCRIPTION)

**gelf\_getclass**() returns the class of the ELF object referenced by *elf*. The class of a valid ELF file will be one of:

[**ELFCLASS32**](#ELFCLASS32)

The object is a 32-bit ELF class.

[**ELFCLASS64**](#ELFCLASS64)

The object is a 64-bit ELF class.

If *elf* does not denote a valid ELF object, or the class cannot be determined, **ELFCLASSNONE** is returned.

# [RETURN VALUE](#RETURN_VALUE)

Returns **ELFCLASS32** or **ELFCLASS64** on success. If *elf* is NULL or does not refer to a valid ELF binary with kind **ELF\_K\_ELF**, then **ELFCLASSNONE** is returned.

# [SEE ALSO](#SEE_ALSO)

[**elf\_kind**(3)](/man/os/elfutils/elf_kind.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

**Interface** **Attribute** **Value** gelf\_getclass () Thread safety MT-unsafe race

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;elfutils-devel@sourceware.org&gt; or https://sourceware.org/bugzilla/.

2025-09-14 Libelf

---

Document: gelf_getclass(3) from elfutils 0.197-r0 (Chainguard OS)
Source: https://sourceware.org/git/elfutils.git
