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

# elf\_getdata\_rawchunk(3)

create a raw data descriptor from a file offset

## NAME

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

## SYNOPSIS

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

## 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)](/elf_update/3.md). It is also owned by libelf and is valid until **elf\_end**() is called on *elf*.

## PARAMETERS

- *elf*

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

- *offset*

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

- *size*

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

- *type*

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

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

    Integer and pointer types.

  - **ELF\_T\_EHDR, ELF\_T\_SHDR, ELF\_T\_PHDR**

    ELF file, section, and program headers.

  - **ELF\_T\_SYM, ELF\_T\_DYN, ELF\_T\_REL, ELF\_T\_RELA, ELF\_T\_RELR**

    Symbols and relocations.

  - **ELF\_T\_NHDR, ELF\_T\_CHDR, ELF\_T\_NHDR8**

    ELF note headers and compressed data headers.

  - **ELF\_T\_VDEF, ELF\_T\_VDAUX, ELF\_T\_VNEED, ELF\_T\_VNAUX**

    Versioning structures.

  - **ELF\_T\_SYMINFO, ELF\_T\_MOVE, ELF\_T\_LIB**

    Other ELF metadata.

  - **ELF\_T\_GNUHASH**

    GNU-style hash table.

  - **ELF\_T\_AUXV**

    Auxiliary vectors.

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

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

## ATTRIBUTES

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

## REPORTING BUGS

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

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