xref: /minix3/external/bsd/elftoolchain/dist/libelf/gelf_update_ehdr.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: gelf_update_ehdr.3,v 1.2 2014/03/09 16:58:04 christos Exp $
2*0a6a1f1dSLionel Sambuc.\"
3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2006,2008 Joseph Koshy.  All rights reserved.
4*0a6a1f1dSLionel Sambuc.\"
5*0a6a1f1dSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
6*0a6a1f1dSLionel Sambuc.\" modification, are permitted provided that the following conditions
7*0a6a1f1dSLionel Sambuc.\" are met:
8*0a6a1f1dSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
9*0a6a1f1dSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
10*0a6a1f1dSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
11*0a6a1f1dSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
12*0a6a1f1dSLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
13*0a6a1f1dSLionel Sambuc.\"
14*0a6a1f1dSLionel Sambuc.\" This software is provided by Joseph Koshy ``as is'' and
15*0a6a1f1dSLionel Sambuc.\" any express or implied warranties, including, but not limited to, the
16*0a6a1f1dSLionel Sambuc.\" implied warranties of merchantability and fitness for a particular purpose
17*0a6a1f1dSLionel Sambuc.\" are disclaimed.  in no event shall Joseph Koshy be liable
18*0a6a1f1dSLionel Sambuc.\" for any direct, indirect, incidental, special, exemplary, or consequential
19*0a6a1f1dSLionel Sambuc.\" damages (including, but not limited to, procurement of substitute goods
20*0a6a1f1dSLionel Sambuc.\" or services; loss of use, data, or profits; or business interruption)
21*0a6a1f1dSLionel Sambuc.\" however caused and on any theory of liability, whether in contract, strict
22*0a6a1f1dSLionel Sambuc.\" liability, or tort (including negligence or otherwise) arising in any way
23*0a6a1f1dSLionel Sambuc.\" out of the use of this software, even if advised of the possibility of
24*0a6a1f1dSLionel Sambuc.\" such damage.
25*0a6a1f1dSLionel Sambuc.\"
26*0a6a1f1dSLionel Sambuc.\" Id: gelf_update_ehdr.3 189 2008-07-20 10:38:08Z jkoshy
27*0a6a1f1dSLionel Sambuc.\"
28*0a6a1f1dSLionel Sambuc.Dd August 27, 2006
29*0a6a1f1dSLionel Sambuc.Os
30*0a6a1f1dSLionel Sambuc.Dt GELF_UPDATE_EHDR 3
31*0a6a1f1dSLionel Sambuc.Sh NAME
32*0a6a1f1dSLionel Sambuc.Nm gelf_update_ehdr ,
33*0a6a1f1dSLionel Sambuc.Nm gelf_update_phdr ,
34*0a6a1f1dSLionel Sambuc.Nm gelf_update_shdr
35*0a6a1f1dSLionel Sambuc.Nd update underlying ELF data structures
36*0a6a1f1dSLionel Sambuc.Sh LIBRARY
37*0a6a1f1dSLionel Sambuc.Lb libelf
38*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS
39*0a6a1f1dSLionel Sambuc.In gelf.h
40*0a6a1f1dSLionel Sambuc.Ft int
41*0a6a1f1dSLionel Sambuc.Fn gelf_update_ehdr "Elf *elf" "GElf_Ehdr *ehdr"
42*0a6a1f1dSLionel Sambuc.Ft int
43*0a6a1f1dSLionel Sambuc.Fn gelf_update_phdr "Elf *elf" "int ndx" "GElf_Phdr *phdr"
44*0a6a1f1dSLionel Sambuc.Ft int
45*0a6a1f1dSLionel Sambuc.Fn gelf_update_shdr "Elf_Scn *scn" "GElf_Shdr *shdr"
46*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION
47*0a6a1f1dSLionel SambucThese functions are used to update ELF data structures on the underlying
48*0a6a1f1dSLionel SambucELF descriptor.
49*0a6a1f1dSLionel SambucClass-dependent data structures in the underlying ELF descriptor
50*0a6a1f1dSLionel Sambucare updated using the data in the class-independent GElf descriptors
51*0a6a1f1dSLionel Sambucand the underlying ELF data structures are marked
52*0a6a1f1dSLionel Sambuc.Dq dirty .
53*0a6a1f1dSLionel SambucThe conversion process signals an error if the values being copied
54*0a6a1f1dSLionel Sambucto the target ELF data structure would exceed representation
55*0a6a1f1dSLionel Sambuclimits.
56*0a6a1f1dSLionel SambucGElf descriptors are described in
57*0a6a1f1dSLionel Sambuc.Xr gelf 3 .
58*0a6a1f1dSLionel Sambuc.Pp
59*0a6a1f1dSLionel SambucFunction
60*0a6a1f1dSLionel Sambuc.Fn gelf_update_ehdr
61*0a6a1f1dSLionel Sambucupdates the ELF Executable Header with the values in the
62*0a6a1f1dSLionel Sambucclass-independent executable header
63*0a6a1f1dSLionel Sambuc.Ar ehdr .
64*0a6a1f1dSLionel Sambuc.Pp
65*0a6a1f1dSLionel SambucFunction
66*0a6a1f1dSLionel Sambuc.Fn gelf_update_phdr
67*0a6a1f1dSLionel Sambucupdates the ELF Program Header structure at index
68*0a6a1f1dSLionel Sambuc.Ar ndx
69*0a6a1f1dSLionel Sambucwith the values in the class-independent program header
70*0a6a1f1dSLionel Sambuc.Ar phdr .
71*0a6a1f1dSLionel Sambuc.Pp
72*0a6a1f1dSLionel SambucFunction
73*0a6a1f1dSLionel Sambuc.Fn gelf_update_shdr
74*0a6a1f1dSLionel Sambucupdates the ELF Section Header structure associated with section
75*0a6a1f1dSLionel Sambucdescriptor
76*0a6a1f1dSLionel Sambuc.Ar scn
77*0a6a1f1dSLionel Sambucwith the values in argument
78*0a6a1f1dSLionel Sambuc.Ar shdr .
79*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES
80*0a6a1f1dSLionel SambucThese functions return a non-zero integer on success, or zero in case
81*0a6a1f1dSLionel Sambucof an error.
82*0a6a1f1dSLionel Sambuc.Sh ERRORS
83*0a6a1f1dSLionel SambucThese functions may fail with the following errors:
84*0a6a1f1dSLionel Sambuc.Bl -tag -width "[ELF_E_RESOURCE]"
85*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
86*0a6a1f1dSLionel SambucArguments
87*0a6a1f1dSLionel Sambuc.Ar elf ,
88*0a6a1f1dSLionel Sambuc.Ar ehdr ,
89*0a6a1f1dSLionel Sambuc.Ar phdr ,
90*0a6a1f1dSLionel Sambuc.Ar scn ,
91*0a6a1f1dSLionel Sambucor
92*0a6a1f1dSLionel Sambuc.Ar shdr
93*0a6a1f1dSLionel Sambucwere NULL.
94*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
95*0a6a1f1dSLionel SambucArgument
96*0a6a1f1dSLionel Sambuc.Ar elf
97*0a6a1f1dSLionel Sambucwas not a descriptor for an ELF object.
98*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
99*0a6a1f1dSLionel SambucArgument
100*0a6a1f1dSLionel Sambuc.Ar elf
101*0a6a1f1dSLionel Sambuchad an unsupported ELF class.
102*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
103*0a6a1f1dSLionel SambucArgument
104*0a6a1f1dSLionel Sambuc.Ar ndx
105*0a6a1f1dSLionel Sambucexceeded the number of entries in the program header table.
106*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_ARGUMENT
107*0a6a1f1dSLionel SambucSection descriptor
108*0a6a1f1dSLionel Sambuc.Ar scn
109*0a6a1f1dSLionel Sambucwas not associated with an ELF descriptor.
110*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_MODE
111*0a6a1f1dSLionel SambucELF descriptor
112*0a6a1f1dSLionel Sambuc.Ar elf
113*0a6a1f1dSLionel Sambucwas not opened for writing or updating.
114*0a6a1f1dSLionel Sambuc.It Bq Er ELF_E_RESOURCE
115*0a6a1f1dSLionel SambucAn out of memory condition was detected.
116*0a6a1f1dSLionel Sambuc.El
117*0a6a1f1dSLionel Sambuc.Sh SEE ALSO
118*0a6a1f1dSLionel Sambuc.Xr elf 3 ,
119*0a6a1f1dSLionel Sambuc.Xr elf_flagelf 3 ,
120*0a6a1f1dSLionel Sambuc.Xr elf_flagphdr 3 ,
121*0a6a1f1dSLionel Sambuc.Xr elf_flagshdr 3 ,
122*0a6a1f1dSLionel Sambuc.Xr gelf 3 ,
123*0a6a1f1dSLionel Sambuc.Xr gelf_getehdr 3 ,
124*0a6a1f1dSLionel Sambuc.Xr gelf_getphdr 3 ,
125*0a6a1f1dSLionel Sambuc.Xr gelf_getshdr 3
126