1*5ac3bc71Schristos.\" $NetBSD: gelf_update_ehdr.3,v 1.6 2024/03/03 17:37:34 christos Exp $ 2e81373b4Schristos.\" 39dd9d0cfSchristos.\" Copyright (c) 2006,2008 Joseph Koshy. All rights reserved. 49dd9d0cfSchristos.\" 59dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without 69dd9d0cfSchristos.\" modification, are permitted provided that the following conditions 79dd9d0cfSchristos.\" are met: 89dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright 99dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer. 109dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright 119dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer in the 129dd9d0cfSchristos.\" documentation and/or other materials provided with the distribution. 139dd9d0cfSchristos.\" 149dd9d0cfSchristos.\" This software is provided by Joseph Koshy ``as is'' and 159dd9d0cfSchristos.\" any express or implied warranties, including, but not limited to, the 169dd9d0cfSchristos.\" implied warranties of merchantability and fitness for a particular purpose 179dd9d0cfSchristos.\" are disclaimed. in no event shall Joseph Koshy be liable 189dd9d0cfSchristos.\" for any direct, indirect, incidental, special, exemplary, or consequential 199dd9d0cfSchristos.\" damages (including, but not limited to, procurement of substitute goods 209dd9d0cfSchristos.\" or services; loss of use, data, or profits; or business interruption) 219dd9d0cfSchristos.\" however caused and on any theory of liability, whether in contract, strict 229dd9d0cfSchristos.\" liability, or tort (including negligence or otherwise) arising in any way 239dd9d0cfSchristos.\" out of the use of this software, even if advised of the possibility of 249dd9d0cfSchristos.\" such damage. 259dd9d0cfSchristos.\" 263f622274Sjkoshy.\" Id: gelf_update_ehdr.3 3958 2022-03-12 14:31:32Z jkoshy 279dd9d0cfSchristos.\" 289dd9d0cfSchristos.Dd August 27, 2006 299dd9d0cfSchristos.Dt GELF_UPDATE_EHDR 3 30c5261b83Sjkoshy.Os 319dd9d0cfSchristos.Sh NAME 329dd9d0cfSchristos.Nm gelf_update_ehdr , 339dd9d0cfSchristos.Nm gelf_update_phdr , 349dd9d0cfSchristos.Nm gelf_update_shdr 359dd9d0cfSchristos.Nd update underlying ELF data structures 369dd9d0cfSchristos.Sh LIBRARY 379dd9d0cfSchristos.Lb libelf 389dd9d0cfSchristos.Sh SYNOPSIS 399dd9d0cfSchristos.In gelf.h 409dd9d0cfSchristos.Ft int 419dd9d0cfSchristos.Fn gelf_update_ehdr "Elf *elf" "GElf_Ehdr *ehdr" 429dd9d0cfSchristos.Ft int 439dd9d0cfSchristos.Fn gelf_update_phdr "Elf *elf" "int ndx" "GElf_Phdr *phdr" 449dd9d0cfSchristos.Ft int 459dd9d0cfSchristos.Fn gelf_update_shdr "Elf_Scn *scn" "GElf_Shdr *shdr" 469dd9d0cfSchristos.Sh DESCRIPTION 479dd9d0cfSchristosThese functions are used to update ELF data structures on the underlying 489dd9d0cfSchristosELF descriptor. 499dd9d0cfSchristosClass-dependent data structures in the underlying ELF descriptor 509dd9d0cfSchristosare updated using the data in the class-independent GElf descriptors 519dd9d0cfSchristosand the underlying ELF data structures are marked 529dd9d0cfSchristos.Dq dirty . 539dd9d0cfSchristosThe conversion process signals an error if the values being copied 549dd9d0cfSchristosto the target ELF data structure would exceed representation 559dd9d0cfSchristoslimits. 569dd9d0cfSchristosGElf descriptors are described in 579dd9d0cfSchristos.Xr gelf 3 . 589dd9d0cfSchristos.Pp 599dd9d0cfSchristosFunction 609dd9d0cfSchristos.Fn gelf_update_ehdr 619dd9d0cfSchristosupdates the ELF Executable Header with the values in the 629dd9d0cfSchristosclass-independent executable header 633f622274Sjkoshy.Fa ehdr . 649dd9d0cfSchristos.Pp 659dd9d0cfSchristosFunction 669dd9d0cfSchristos.Fn gelf_update_phdr 679dd9d0cfSchristosupdates the ELF Program Header structure at index 683f622274Sjkoshy.Fa ndx 699dd9d0cfSchristoswith the values in the class-independent program header 703f622274Sjkoshy.Fa phdr . 719dd9d0cfSchristos.Pp 729dd9d0cfSchristosFunction 739dd9d0cfSchristos.Fn gelf_update_shdr 749dd9d0cfSchristosupdates the ELF Section Header structure associated with section 759dd9d0cfSchristosdescriptor 763f622274Sjkoshy.Fa scn 779dd9d0cfSchristoswith the values in argument 783f622274Sjkoshy.Fa shdr . 799dd9d0cfSchristos.Sh RETURN VALUES 809dd9d0cfSchristosThese functions return a non-zero integer on success, or zero in case 819dd9d0cfSchristosof an error. 829dd9d0cfSchristos.Sh ERRORS 839dd9d0cfSchristosThese functions may fail with the following errors: 849dd9d0cfSchristos.Bl -tag -width "[ELF_E_RESOURCE]" 859dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 869dd9d0cfSchristosArguments 873f622274Sjkoshy.Fa elf , 883f622274Sjkoshy.Fa ehdr , 893f622274Sjkoshy.Fa phdr , 903f622274Sjkoshy.Fa scn , 919dd9d0cfSchristosor 923f622274Sjkoshy.Fa shdr 93c5261b83Sjkoshywere 94c5261b83Sjkoshy.Dv NULL . 959dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 969dd9d0cfSchristosArgument 973f622274Sjkoshy.Fa elf 989dd9d0cfSchristoswas not a descriptor for an ELF object. 999dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 1009dd9d0cfSchristosArgument 1013f622274Sjkoshy.Fa elf 1029dd9d0cfSchristoshad an unsupported ELF class. 1039dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 1049dd9d0cfSchristosArgument 1053f622274Sjkoshy.Fa ndx 1069dd9d0cfSchristosexceeded the number of entries in the program header table. 1079dd9d0cfSchristos.It Bq Er ELF_E_ARGUMENT 1089dd9d0cfSchristosSection descriptor 1093f622274Sjkoshy.Fa scn 1109dd9d0cfSchristoswas not associated with an ELF descriptor. 1119dd9d0cfSchristos.It Bq Er ELF_E_MODE 1129dd9d0cfSchristosELF descriptor 1133f622274Sjkoshy.Fa elf 1149dd9d0cfSchristoswas not opened for writing or updating. 1159dd9d0cfSchristos.It Bq Er ELF_E_RESOURCE 1169dd9d0cfSchristosAn out of memory condition was detected. 1179dd9d0cfSchristos.El 1189dd9d0cfSchristos.Sh SEE ALSO 1199dd9d0cfSchristos.Xr elf 3 , 1209dd9d0cfSchristos.Xr elf_flagelf 3 , 1219dd9d0cfSchristos.Xr elf_flagphdr 3 , 1229dd9d0cfSchristos.Xr elf_flagshdr 3 , 1239dd9d0cfSchristos.Xr gelf 3 , 1249dd9d0cfSchristos.Xr gelf_getehdr 3 , 1259dd9d0cfSchristos.Xr gelf_getphdr 3 , 1269dd9d0cfSchristos.Xr gelf_getshdr 3 127