ELF\_GETDATA\_RAWCHUNK(3) Libelf Programmer's Manual ELF\_GETDATA\_RAWCHUNK(3)

# [NAME](#NAME)

elf\_getdata\_rawchunk - create a raw data descriptor from a file offset

# [SYNOPSIS](#SYNOPSIS)

```
#include <libelf.h>
Elf_Data * elf_getdata_rawchunk("Elf *elf", int64_t offset , size_t size , Elf_Type type );
```

# [DESCRIPTION](#DESCRIPTION)

The **elf\_getdata\_rawchunk**() function returns an **Elf\_Data** descriptor that refers to a raw region of the ELF file, starting at the given file *offset* and spanning *size* bytes. This is used to access arbitrary byte ranges in the ELF file that may not correspond to any section or segment.

The returned **Elf\_Data** *d\_buf* will be properly aligned for the requested *type*.

If the file’s byte order matches the host, and alignment permits, the raw data is returned as-is. If the file’s byte order differs, the buffer is converted into native byte order and aligned for direct access. This behaves like **elf\_getdata**(), and not **elf\_rawdata**(). The contents of the return value's *d\_buf* are a decoded representation.

The returned data is not associated with any section or update mechanism. It will not be included in any output written by [**elf\_update**(3)](/man/os/elfutils/elf_update.3). It is also owned by libelf and is valid until **elf\_end**() is called on *elf*.

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

A pointer to an **Elf** descriptor representing the ELF file.

[*offset*](#offset)

The starting file offset in bytes. This must lie within the bounds of the file.

[*size*](#size)

The number of bytes to include in the data chunk, starting at *offset*.

[*type*](#type)

An **Elf\_Type** enumeration value indicating the intended interpretation of the data. Values include:

[**ELF\_T\_BYTE**](#ELF_T_BYTE)

Raw bytes.

[**ELF\_T\_ADDR, ELF\_T\_OFF, ELF\_T\_HALF, ELF\_T\_WORD, ELF\_T\_XWORD, ELF\_T\_SWORD, ELF\_T\_SXWORD**](#ELF_T_ADDR,)

Integer and pointer types.

[**ELF\_T\_EHDR, ELF\_T\_SHDR, ELF\_T\_PHDR**](#ELF_T_EHDR,)

ELF file, section, and program headers.

[**ELF\_T\_SYM, ELF\_T\_DYN, ELF\_T\_REL, ELF\_T\_RELA, ELF\_T\_RELR**](#ELF_T_SYM,)

Symbols and relocations.

[**ELF\_T\_NHDR, ELF\_T\_CHDR, ELF\_T\_NHDR8**](#ELF_T_NHDR,)

ELF note headers and compressed data headers.

[**ELF\_T\_VDEF, ELF\_T\_VDAUX, ELF\_T\_VNEED, ELF\_T\_VNAUX**](#ELF_T_VDEF,)

Versioning structures.

[**ELF\_T\_SYMINFO, ELF\_T\_MOVE, ELF\_T\_LIB**](#ELF_T_SYMINFO,)

Other ELF metadata.

[**ELF\_T\_GNUHASH**](#ELF_T_GNUHASH)

GNU-style hash table.

[**ELF\_T\_AUXV**](#ELF_T_AUXV)

Auxiliary vectors.

# [RETURN VALUE](#RETURN_VALUE)

Returns a pointer to an **Elf\_Data** descriptor on success.

Returns NULL if any arguments are invalid, or if memory allocation or file reading fails. An error code is set which can be retrieved with **elf\_errmsg**(). The result is cached and shared between repeated calls using the same arguments.

# [SEE ALSO](#SEE_ALSO)

[**elf**(3)](/man/os/elfutils/elf.3), [**elf\_errmsg**(3)](/man/os/elfutils/elf_errmsg.3), [**elf\_getdata**(3)](/man/os/elfutils/elf_getdata.3), [**elf\_getscn**(3)](/man/os/elfutils/elf_getscn.3), [**elf\_rawdata**(3)](/man/os/elfutils/elf_rawdata.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

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

# [HISTORY](#HISTORY)

**elf\_getdata\_rawchunk** first appeared in elfutils 0.130. This function is a elfutils libelf extension and may not be available in other libelf implementations.

2025-06-30 Libelf

---

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