Hi Aaron,

Funny, I had no idea this existed. But it is actually used by readelf
(for showing the program interpreter) and there is one test case (that
does the same).

On Mon, 2025-06-30 at 23:12 -0400, Aaron Merey wrote:
> Signed-off-by: Aaron Merey <ame...@redhat.com>
> ---
>  doc/Makefile.am   |  1 +
>  doc/elf_rawfile.3 | 71 +++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+)
>  create mode 100644 doc/elf_rawfile.3
> 
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index 7d5a3eef..50ab63ec 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -84,6 +84,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \
>                       elf_nextscn.3 \
>                       elf_rand.3 \
>                       elf_rawdata.3 \
> +                     elf_rawfile.3 \
>                       elf_update.3 \
>                       elf_version.3 \
>                       libelf.3

OK.

> diff --git a/doc/elf_rawfile.3 b/doc/elf_rawfile.3
> new file mode 100644
> index 00000000..d7a3e3fb
> --- /dev/null
> +++ b/doc/elf_rawfile.3
> @@ -0,0 +1,71 @@
> +.TH ELF_RAWFILE 3 2025-06-30 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +elf_rawfile \- Retrieve a pointer to the entire raw ELF file image
> +
> +.SH SYNOPSIS
> +.nf
> +#include <libelf.h>
> +
> +.BI "char *elf_rawfile(Elf *" elf ", size_t *" ptr ");"
> +.fi

OK.

> +.SH DESCRIPTION
> +The
> +.BR elf_rawfile ()
> +function returns a pointer to the entire contents of the ELF file 
> represented by
> +.IR elf .
> +This data is unprocessed and includes everything from the ELF header to the
> +final byte.
> +
> +If the ELF descriptor was opened from memory or the file has already been
> +memory-mapped or fully read, this function returns a pointer to the internal 
> buffer.
> +
> +If the ELF data has not yet been read or mapped, it is loaded on demand.

OK.

> +If
> +.I ptr
> +is non-NULL, the total size in bytes of the raw file is stored in
> +.IR *ptr .
> +
> +The returned buffer is read-only and managed internally by libelf.
> +The application must not modify or free it.

OK.

> +.SH PARAMETERS
> +.TP
> +.I elf
> +A handle previously returned by
> +.BR elf_begin (3) .

Or elf_memory?

> +.TP
> +.I ptr
> +If not
> +.BR NULL ,
> +receives the size in bytes of the ELF file.

receives? maybe "is set to"?

> +.SH RETURN VALUE
> +Returns a pointer to the start of the ELF file data. On failure,
> +.B NULL
> +is returned and
> +.I *ptr
> +(if non-NULL) is set to 0.

OK.

> +.SH SEE ALSO
> +.BR libelf (3),
> +.BR elf (5)
> +
> +.SH ATTRIBUTES
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface    Attribute       Value
> +T{
> +.na
> +.nh
> +.BR elf_rawfile ()
> +T}   Thread safety   MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to <elfutils-devel@sourceware.org> or 
> https://sourceware.org/bugzilla/.

OK.

Thanks,

Mark

Reply via email to