table of contents
| ELF_MEMORY(3) | Libelf Programmer's Manual | ELF_MEMORY(3) |
NAME¶
elf_memory - create an ELF descriptor from a memory buffer
SYNOPSIS¶
#include <libelf.h> Elf * elf_memory(char *" image , size_t size );
DESCRIPTION¶
The elf_memory() function creates a new ELF descriptor from a memory region containing an ELF object. This function is used when the ELF data is already present in memory rather than being read from a file descriptor.
The memory pointed to by image must contain a complete ELF file or archive. The contents must remain valid and unmodified for the lifetime of the resulting ELF descriptor.
The ELF descriptor returned by elf_memory() is opened in read-only mode using ELF_C_READ_MMAP_PRIVATE (see elf_begin). The underlying memory image should not be directly modified by the application while its ELF descriptor is open. Some libelf functions, such as elf_compress() and gelf_update_*(), may internally modify the underlying image and therefore require that the underlying image be writable. The use of a read-only image (e.g., memory mapped with PROT_READ only) may result in failures or crashes.
PARAMETERS¶
RETURN VALUE¶
On success, elf_memory() returns a pointer to an Elf descriptor representing the archive or ELF file contained in image.
On failure, it returns NULL and sets an error code retrievable by elf_errmsg(3).
SEE ALSO¶
ATTRIBUTES¶
| Interface Attribute Value |
| elf_memory () Thread safety MT-Safe |
REPORTING BUGS¶
Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.
| 2025-06-23 | Libelf |