---
name: "gelf_getnote"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/gelf_getnote"
---

# gelf\_getnote(3)

Get class-independent note information at the supplied offset

## NAME

gelf\_getnote - Get class-independent note information at the supplied offset

## SYNOPSIS

```
#include <gelf.h>
size_t gelf_getnote (Elf_Data *data, size_t offset, GElf_Nhdr *result, size_t *name_offset, size_t *desc_offset);
```

## DESCRIPTION

Retrieve the ELF note header from *data* at offset *offset* and store it in a class-independent representation pointed to by *result*. The note name and note descriptor offsets relative to the start of *data* are stored in *\*name\_offset* and *\*desc\_offset*, respectively. **GElf\_Nhdr** fields *n\_namesz*, *n\_descsz*, and *n\_type* describe the note's name length, descriptor length and type, respectively. Alignment and padding of the note data entry are handled automatically by this function. See [**elf**(5)](/elf/5.md) for more information regarding ELF notes.

## PARAMETERS

- *data*

  Pointer to an **Elf\_Data** associated with a **SHT\_NOTE** section or a **PT\_NOTE** segment. *data-\>d\_type* should be **ELF\_T\_NHDR** or **ELF\_T\_NHDR8**.

- *offset*

  Offset of a note header within *data*.

- *result*

  Pointer to a caller-provided **GElf\_Nhdr** structure for storing the requested note header. *result* must not be NULL.

- *name\_offset*

  Pointer to a caller-provided **size\_t** for storing the name offset of the requested note.  This offset is relative to *data-\>d\_buf*. *name\_offset* must not be NULL.

- *desc\_offset*

  Pointer to a caller-provided **size\_t** for storing the descriptor offset of the requested note. This offset is relative to *data-\>d\_buf*. *desc\_offset* must not be NULL.

## RETURN VALUE

On success, this function updates *\*result*, *\*name\_offset*, and *\*desc\_offset* and returns the offset of the next note.  If there are no notes remaining then the return value will be greater than or equal to the **d\_size** of *data*. On failure, this function returns zero and sets elf\_errno.  If *data* is NULL then zero is returned without setting elf\_errno.

## EXAMPLE

```
  size_t offset = 0;
  GElf_Nhdr nhdr;
  size_t name_offset;
  size_t desc_offset;
  while (offset < data->d_size
         && (offset = gelf_getnote (data, offset,
                                    &nhdr, &name_offset, &desc_offset)) > 0)
    {
      const char *name = nhdr.n_namesz == 0 ? "" : data->d_buf + name_offset;
      const char *desc = nhdr.n_descsz == 0 ? "" : data->d_buf + desc_offset;
      /* Process note here.  name and desc are not guaranteed to be
         zero-terminated.  The presence of null characters should be
         verified using n_namesz and n_descsz.  */
      [...]
    }
```

## SEE ALSO

[**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **gelf\_getnote**() | Thread safety | MT-Safe |

## REPORTING BUGS

Report bugs to \<elfutils-devel@sourceware.org\> or https://sourceware.org/bugzilla/.

## HISTORY

**gelf\_getnote** first appeared in elfutils 0.130.  This function is an elfutils libelf extension and may not be available in other libelf implementations.
