elf_rawdata(3)

elf_rawdata3

Retrieve unprocessed section data from an elf section.

Usage

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

Overview

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) 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) is called on the Elf descriptor associated with scn.

Parameters

scn

A section descriptor returned from elf_getscn(3) or elf_nextscn(3). 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.

Attributes

InterfaceAttributeValue
elf_rawdata()Thread safetyMT-Safe

Reporting bugs

Report bugs to <[email protected]> or https://sourceware.org/bugzilla/.

From libelf 0.197-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.