Signed-off-by: Aaron Merey <[email protected]> --- v2 changes: Mention size limits for ELFCLASS32 binaries and setting ELF_F_DIRTY. Return value for success case is now non-zero, not 1.
On Fri, Oct 31, 2025 at 11:17 AM Mark Wielaard <[email protected]> wrote: > > +.SH SEE ALSO > > +.BR gelf_getrel (3), > > +.BR gelf_getrela (3), > > +.BR libelf (3), > > +.BR elf (5) > > Where are the GELF_R_SYM and GELF_R_TYPE decribed? I've added patch "doc: Update libelf.3 with gelf.h information" to this series. doc/Makefile.am | 2 + doc/gelf_update_rel.3 | 108 +++++++++++++++++++++++++++++++++++++++++ doc/gelf_update_rela.3 | 1 + 3 files changed, 111 insertions(+) create mode 100644 doc/gelf_update_rel.3 create mode 100644 doc/gelf_update_rela.3 diff --git a/doc/Makefile.am b/doc/Makefile.am index 3064e8ed..8c44e20e 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -101,6 +101,8 @@ notrans_dist_man3_MANS= elf32_checksum.3 \ gelf_offscn.3 \ gelf_update_ehdr.3 \ gelf_update_shdr.3 \ + gelf_update_rel.3 \ + gelf_update_rela.3 \ libelf.3 # libdebuginfod man pages (also notrans) diff --git a/doc/gelf_update_rel.3 b/doc/gelf_update_rel.3 new file mode 100644 index 00000000..e07ff09d --- /dev/null +++ b/doc/gelf_update_rel.3 @@ -0,0 +1,108 @@ +.TH GELF_UPDATE_REL 3 2025-09-27 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +gelf_update_rel, gelf_update_rela \- copy class\-independent relocation entries into a relocation section + +.SH SYNOPSIS +.nf +.B #include <gelf.h> + +.BI "int gelf_update_rel (Elf_Data *" data ", int " ndx ", GElf_Rel *" src ");" +.BI "int gelf_update_rela(Elf_Data *" data ", int " ndx ", GElf_Rela *" src ");" +.fi + +.SH DESCRIPTION +The +.BR gelf_update_rel () +and +.BR gelf_update_rela () +functions copy a class\-independent REL or RELA relocation entry from +.IR *src +into the SHT_REL or SHT_RELA section associated with +.I data +at entry index +.IR ndx . + +.SH PARAMETERS +.TP +.I data +.B Elf_Data +for a relocation section. The section must have sh_type +.B SHT_REL +for +.BR gelf_update_rel () +or +.B SHT_RELA +for +.BR gelf_update_rela (). + +.TP +.I ndx +Zero\-based index of the relocation entry within +.IR data . + +.TP +.I src +Pointer to the caller\-provided source entry of type +.B GElf_Rel +for +.BR gelf_update_rel () +and +.B GElf_Rela +for +.BR gelf_update_rela (). +.I src +must not be NULL. + +For +.B ELFCLASS32 +binaries, +.I r_offset +should fit in unsigned 32 bits. +.I r_addend +should fit in signed 32 bits. The +.B GELF_R_SYM +component of +.I r_info +should fit in 24 bits and the +.B GELF_R_TYPE +component should fit in 8 bits. + +.SH RETURN VALUE +On success, +.BR gelf_update_rel () +and +.BR gelf_update_rela () +copy +.I src +into +.IR data , +flag the corresponding section with +.B ELF_F_DIRTY +and return a non-zero value. On failure, these functions return 0 and set +elf_errno. If +.I src +is NULL, then 0 is returned without setting elf_errno. + +.SH SEE ALSO +.BR gelf_getrel (3), +.BR gelf_getrela (3), +.BR libelf (3), +.BR elf (5) + + +.SH ATTRIBUTES +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR gelf_update_rel (),\~gelf_update_rela () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to <[email protected]> or https://sourceware.org/bugzilla/. diff --git a/doc/gelf_update_rela.3 b/doc/gelf_update_rela.3 new file mode 100644 index 00000000..36db4a78 --- /dev/null +++ b/doc/gelf_update_rela.3 @@ -0,0 +1 @@ +.so man3/gelf_update_rel.3 -- 2.51.1
