1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
'\" te
.\" Copyright 1989 AT&T Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH ELF32_XLATETOF 3ELF "Jul 11, 2001"
.SH NAME
elf32_xlatetof, elf32_xlatetom, elf64_xlatetof, elf64_xlatetom \-
class-dependent data translation
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR ... ] \fIfile\fR... \fB-lelf\fR [ \fIlibrary\fR ... ]
#include <libelf.h>
\fBElf_Data *\fR\fBelf32_xlatetof\fR(\fBElf_Data *\fR\fIdst\fR, \fBconst Elf_Data *\fR\fIsrc\fR,
\fBunsigned\fR \fIencode\fR);
.fi
.LP
.nf
\fBElf_Data *\fR\fBelf32_xlatetom\fR(\fBElf_Data *\fR\fIdst\fR, \fBconst Elf_Data *\fR\fIsrc\fR,
\fBunsigned\fR \fIencode\fR);
.fi
.LP
.nf
\fBElf_Data *\fR\fBelf64_xlatetof\fR(\fBElf_Data *\fR\fIdst\fR, \fBconst Elf_Data *\fR\fIsrc\fR,
\fBunsigned\fR \fIencode\fR);
.fi
.LP
.nf
\fBElf_Data *\fR\fBelf64_xlatetom\fR(\fBElf_Data *\fR\fIdst\fR, \fBconst Elf_Data *\fR\fIsrc\fR,
\fBunsigned\fR \fIencode\fR);
.fi
.SH DESCRIPTION
.sp
.LP
\fBelf32_xlatetom()\fR translates various data structures from their 32-bit
class file representations to their memory representations;
\fBelf32_xlatetof()\fR provides the inverse. This conversion is particularly
important for cross development environments. \fIsrc\fR is a pointer to the
source buffer that holds the original data; \fIdst\fR is a pointer to a
destination buffer that will hold the translated copy. \fIencode\fR gives the
byte encoding in which the file objects are to be represented and must have one
of the encoding values defined for the \fBELF\fR header's
\fBe_ident[EI_DATA]\fR entry (see \fBelf_getident\fR(3ELF)). If the data can be
translated, the functions return \fIdst\fR. Otherwise, they return \fINULL\fR
because an error occurred, such as incompatible types, destination buffer
overflow, etc.
.sp
.LP
\fBelf_getdata\fR(3ELF) describes the \fBElf_Data\fR descriptor, which the
translation routines use as follows:
.sp
.ne 2
.na
\fB\fBd_buf\fR\fR
.ad
.RS 13n
Both the source and destination must have valid buffer pointers.
.RE
.sp
.ne 2
.na
\fB\fBd_type\fR\fR
.ad
.RS 13n
This member's value specifies the type of the data to which \fBd_buf\fR points
and the type of data to be created in the destination. The program supplies a
\fBd_type\fR value in the source; the library sets the destination's
\fBd_type\fR to the same value. These values are summarized below.
.RE
.sp
.ne 2
.na
\fB\fBd_size\fR\fR
.ad
.RS 13n
This member holds the total size, in bytes, of the memory occupied by the
source data and the size allocated for the destination data. If the destination
buffer is not large enough, the routines do not change its original contents.
The translation routines reset the destination's \fBd_size\fR member to the
actual size required, after the translation occurs. The source and destination
sizes may differ.
.RE
.sp
.ne 2
.na
\fB\fBd_version\fR\fR
.ad
.RS 13n
This member holds the version number of the objects (desired) in the buffer.
The source and destination versions are independent.
.RE
.sp
.LP
Translation routines allow the source and destination buffers to coincide. That
is, \fBdst\(->d_buf\fR may equal \fBsrc\(->d_buf\fR. Other cases where the
source and destination buffers overlap give undefined behavior.
.sp
.in +2
.nf
\fBElf_Type 32-Bit Memory Type
ELF_T_ADDR Elf32_Addr
ELF_T_BYTE unsigned char
ELF_T_DYN Elf32_Dyn
ELF_T_EHDR Elf32_Ehdr
ELF_T_HALF Elf32_Half
ELT_T_OFF Elf32_Off
ELF_T_PHDR Elf32_Phdr
ELF_T_REL Elf32_Rel
ELF_T_RELA Elf32_Rela
ELF_T_SHDR Elf32_Shdr
ELF_T_SWORD Elf32_Sword
ELF_T_SYM Elf32_Sym
ELF_T_WORD Elf32_Word\fR
.fi
.in -2
.sp
.LP
Translating buffers of type \fBELF_T_BYTE\fR does not change the byte order.
.sp
.LP
For the 64\(mibit class, replace 32 with 64 as appropriate.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Stable
_
MT-Level MT-Safe
.TE
.SH SEE ALSO
.sp
.LP
.BR elf (3ELF),
.BR elf32_fsize (3ELF),
.BR elf_getdata (3ELF),
.BR elf_getident (3ELF),
.BR libelf (3LIB),
.BR attributes (7)
|