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

# [NAME](#NAME)

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

# [SYNOPSIS](#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](#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)](/man/os/elfutils/elf.5) for more information regarding ELF notes.

# [PARAMETERS](#PARAMETERS)

[*data*](#data)

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

[*offset*](#offset)

Offset of a note header within *data*.

[*result*](#result)

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

[*name\_offset*](#name_offset)

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

[*desc\_offset*](#desc_offset)

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

# [RETURN VALUE](#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](#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](#SEE_ALSO)

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

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

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

# [HISTORY](#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.

2025-12-31 Libelf

---

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