[4/9] doc: Add elf32_getphdr.3 and elf64_getphdr.3

Message ID 20240814213321.244089-4-amerey@redhat.com
State Superseded
Delegated to: Mark Wielaard
Headers
Series [1/9] doc: Add elf32_checksum.3 and elf64_checksum.3 |

Commit Message

Aaron Merey Aug. 14, 2024, 9:33 p.m. UTC
  Signed-off-by: Aaron Merey <amerey@redhat.com>
---
 doc/elf32_getphdr.3 | 45 +++++++++++++++++++++++++++++++++++++++++++++
 doc/elf64_getphdr.3 | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 doc/elf32_getphdr.3
 create mode 100644 doc/elf64_getphdr.3
  

Comments

Mark Wielaard Aug. 27, 2024, 9:53 p.m. UTC | #1
Hi Aaron,

On Wed, Aug 14, 2024 at 05:33:16PM -0400, Aaron Merey wrote:
> diff --git a/doc/elf32_getphdr.3 b/doc/elf32_getphdr.3
> new file mode 100644
> index 00000000..7245f81b
> --- /dev/null
> +++ b/doc/elf32_getphdr.3
> @@ -0,0 +1,45 @@
> +.TH ELF32_GETPHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +elf32_getphdr \- retrieve the program header table for an ELF32 object file
> +
> +.SH SYNOPSIS
> +.B #include <libelf.h>
> +
> +.BI "Elf32_Phdr *elf32_getphdr(Elf *" elf ");"
> +
> +.SH DESCRIPTION
> +Retrieve the program header table for the given ELF descriptor
> +.I elf.

This should expain what the elements of the table are and how to know
how many elements it has. Calling elf_getphdrnum will give you the
number of elements. When changing an element you have to call
elf_flagphdr with ELF_C_SET ELF_F_DIRTY to write the (new) data out to
disk. To change the size of the table (or to delete it) one has to
call elf32_newphdr.

> +.SH PARAMETERS
> +.TP
> +.I elf
> +ELF descriptor from which to retrieve the program header table.
> +
> +.SH RETURN VALUE
> +On success, return a pointer to the program header table. On failure, return NULL and set a libelf error code.

Note that NULL is also returned if there is no program header (or
would be zero size).

> +
> +.SH SEE ALSO
> +.BR elf_errno (3),
> +.BR elf64_getphdr (3),
> +.BR libelf (3),
> +.BR elf (5)

Add elf_getphdrnum and elf32_newphdr.

> +.SH ATTRIBUTES
> +For an explanation of the terms used in this section, see
> +.BR attributes (7).
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface	Attribute	Value
> +T{
> +.na
> +.nh
> +.BR elf32_getphdr ()
> +T}	Thread safety	MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.

Cheers,

Mark
  

Patch

diff --git a/doc/elf32_getphdr.3 b/doc/elf32_getphdr.3
new file mode 100644
index 00000000..7245f81b
--- /dev/null
+++ b/doc/elf32_getphdr.3
@@ -0,0 +1,45 @@ 
+.TH ELF32_GETPHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual"
+
+.SH NAME
+elf32_getphdr \- retrieve the program header table for an ELF32 object file
+
+.SH SYNOPSIS
+.B #include <libelf.h>
+
+.BI "Elf32_Phdr *elf32_getphdr(Elf *" elf ");"
+
+.SH DESCRIPTION
+Retrieve the program header table for the given ELF descriptor
+.I elf.
+
+.SH PARAMETERS
+.TP
+.I elf
+ELF descriptor from which to retrieve the program header table.
+
+.SH RETURN VALUE
+On success, return a pointer to the program header table. On failure, return NULL and set a libelf error code.
+
+.SH SEE ALSO
+.BR elf_errno (3),
+.BR elf64_getphdr (3),
+.BR libelf (3),
+.BR elf (5)
+
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lbx lb lb
+l l l.
+Interface	Attribute	Value
+T{
+.na
+.nh
+.BR elf32_getphdr ()
+T}	Thread safety	MT-Safe
+.TE
+
+.SH REPORTING BUGS
+Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.
diff --git a/doc/elf64_getphdr.3 b/doc/elf64_getphdr.3
new file mode 100644
index 00000000..b27c8de3
--- /dev/null
+++ b/doc/elf64_getphdr.3
@@ -0,0 +1,45 @@ 
+.TH ELF64_GETPHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual"
+
+.SH NAME
+elf64_getphdr \- retrieve the program header table for an ELF64 object file
+
+.SH SYNOPSIS
+.B #include <libelf.h>
+
+.BI "Elf64_Phdr *elf64_getphdr(Elf *" elf ");"
+
+.SH DESCRIPTION
+Retrieve the program header table for the given ELF descriptor
+.I elf.
+
+.SH PARAMETERS
+.TP
+.I elf
+ELF descriptor from which to retrieve the program header table.
+
+.SH RETURN VALUE
+On success, return a pointer to the program header table. On failure, return NULL and set a libelf error code.
+
+.SH SEE ALSO
+.BR elf_errno (3),
+.BR elf32_getphdr (3),
+.BR libelf (3),
+.BR elf (5)
+
+.SH ATTRIBUTES
+For an explanation of the terms used in this section, see
+.BR attributes (7).
+.TS
+allbox;
+lbx lb lb
+l l l.
+Interface	Attribute	Value
+T{
+.na
+.nh
+.BR elf64_getphdr ()
+T}	Thread safety	MT-Safe
+.TE
+
+.SH REPORTING BUGS
+Report bugs to <elfutils-devel@sourceware.org> or https://sourceware.org/bugzilla/.