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

# elf\_rawdata(3)

Retrieve unprocessed section data from an ELF section.

## NAME

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

## SYNOPSIS

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

## 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)](/elf_getdata/3.md) 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)](/elf_end/3.md) is called on the *Elf* descriptor associated with *scn*.

## PARAMETERS

- *scn*

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

- *data*

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

## 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

[**elf\_getdata**(3)](/elf_getdata/3.md), [**elf\_getscn**(3)](/elf_getscn/3.md), **elf\_compress**(3), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

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

## REPORTING BUGS

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