ELF\_RAWDATA(3) Libelf Programmer's Manual ELF\_RAWDATA(3)

# [NAME](#NAME)

elf\_rawdata - Retrieve unprocessed section data from an ELF section.

# [SYNOPSIS](#SYNOPSIS)

```
#include <libelf.h>
Elf_Data *elf_rawdata(Elf_Scn *scn, Elf_Data *data);
```

# [DESCRIPTION](#DESCRIPTION)

The **elf\_rawdata**() function returns a pointer to an **Elf\_Data** structure containing the unprocessed (raw) contents of the section identified by *scn*. This raw view reflects the exact on-disk binary layout of the ELF file with no modifications made for endianness or memory alignment. Use [**elf\_getdata**(3)](/man/os/elfutils/elf_getdata.3) to acquire a view of the data that has been translated to the in-memory format.

If *data* is NULL, the raw data of the section is returned. If *data* is not NULL and raw data has not been initialized, the call fails.

For compressed sections (i.e., with the **SHF\_COMPRESSED** flag), the returned **Elf\_Data** contains the compressed form, and its **d\_type** is **ELF\_T\_CHDR**.

For sections of type **SHT\_NOBITS ,** the **d\_buf** pointer is NULL.

The *Elf\_Data \** returned by this function and it's *d\_buf* are owned by libelf and should not be freed. They are only valid until [**elf\_end**(3)](/man/os/elfutils/elf_end.3) is called on the *Elf* descriptor associated with *scn*.

# [PARAMETERS](#PARAMETERS)

[*scn*](#scn)

A section descriptor returned from [**elf\_getscn**(3)](/man/os/elfutils/elf_getscn.3) or [**elf\_nextscn**(3)](/man/os/elfutils/elf_nextscn.3)**.** If NULL, then this function returns NULL.

[*data*](#data)

Must be NULL on initial invocation. Any other use is not supported.

# [RETURN VALUE](#RETURN_VALUE)

Returns a pointer to an **Elf\_Data** descriptor describing the raw contents of the section. On failure, NULL is returned and elf\_errno is set.

# [SEE ALSO](#SEE_ALSO)

[**elf\_getdata**(3)](/man/os/elfutils/elf_getdata.3), [**elf\_getscn**(3)](/man/os/elfutils/elf_getscn.3), [**elf\_compress**(3)](/man/os/elfutils/elf_compress.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

**Interface** **Attribute** **Value** elf\_rawdata () Thread safety MT-Safe

# [REPORTING BUGS](#REPORTING_BUGS)

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

2025-06-30 Libelf

---

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