---
name: "elf_rawfile"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_rawfile"
---

# elf\_rawfile(3)

return uninterpreted contents of an ELF file

## NAME

**elf\_rawfile** – return uninterpreted contents of an ELF file

## LIBRARY

library “libelf”

## SYNOPSIS

**#include \<libelf.h\>**

*char* *\**\

**elf\_rawfile**(*Elf \*elf*, *size\_t \*sz*);

## DESCRIPTION

Function **elf\_rawfile**() returns the uninterpreted contents of the file referenced by ELF descriptor *elf*.

If argument *sz* is non-null, the function stores the file's size in bytes in the location to which it points. A value of zero is written to this location if an error is encountered.

## RETURN VALUES

Function **elf\_rawfile**() returns a valid pointer if successful or NULL if an error occurs.

## ERRORS

Function **elf\_rawfile**() may fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* was NULL.

- \[ELF\_E\_SEQUENCE\]

  Argument *elf* was opened for writing and function **elf\_rawfile**() was invoked before [elf\_update(3)](/elf_update/3.md).

## SEE ALSO

[elf(3)](/elf/3.md), [elf\_getdata(3)](/elf_getdata/3.md), [elf\_getident(3)](/elf_getident/3.md), [elf\_kind(3)](/elf_kind/3.md), [elf\_update(3)](/elf_update/3.md)
