elf_rand(3)

elf_rand3

Set the offset for the next archive member in an elf file.

Usage

#include <libelf.h>
size_t elf_rand(Elf *elf, size_t offset);

Overview

The elf_rand() function sets the current archive member offset for the ELF archive descriptor elf to offset.

This function is only valid when elf refers to an archive descriptor (i.e., its kind is ELF_K_AR).

Archive member offsets can be acquired from the Elf_Arsym array returned by elf_getarsym(3).

If the archive header at the given offset cannot be parsed or validated, then 0 is returned.

Parameters

elf

A pointer to an ELF archive descriptor.

offset

A byte offset to the archive header, indicating the desired member position.

Return value

Returns the input offset if successful. Returns 0 if elf is NULL, is not an archive descriptor, or if an error occurs while reading the member at offset.

Attributes

InterfaceAttributeValue
elf_rand()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.