'\"!  tbl | mmdoc
'\"macro stdmacro
.if n .pH g3e.elf_xlate @(#)elf_xlate	40.11 of 10/27/89
.\" Copyright 1989 AT&T
.\"#ident	"@(#)ci5-doc:req/libelf/xlate.man	1.3"
.nr X
.if \nX=0 .ds x} elf_xlate 3E "ELF Library" "\&"
.if \nX=1 .ds x} elf_xlate 3E "ELF Library"
.if \nX=2 .ds x} elf_xlate 3E "" "\&"
.if \nX=3 .ds x} elf_xlate "" "" "\&"
.TH \*(x}
.SH NAME
\f4elf_xlate\f1: \f4elf32_xlatetof\f1, \f4elf32_xlatetom\f1 \- class-dependent data translation
.SH SYNOPSIS
\f4cc\f1
[\f2flag\fP \|.\|.\|.] \f2file\fP \|.\|.\|.
\f4\-lelf\f1
[\f2library\fP \|.\|.\|.]
.PP
.nf
.na
.ft 4
#include <libelf.h>
.sp 0.5
Elf_Data \(**elf32_xlatetof(Elf_Data \(**dst, const Elf_Data \(**src,
	unsigned encode);
.sp 0.5
Elf_Data \(**elf32_xlatetom(Elf_Data \(**dst, const Elf_Data \(**src,
	unsigned encode);
.ft 1
.ad
.fi
.SH DESCRIPTION
\f4elf32_xlatetom\fP
translates various data structures from their 32-bit class
file representations to their memory representations;
\f4elf32_xlatetof\fP
provides the inverse.
This conversion is particularly important for cross
development environments.
.I src
is a pointer to the source buffer that holds the original data;
.I dst
is a pointer to a destination buffer that will hold the translated copy.
.I encode
gives the byte encoding in which the file objects are (to be)
represented and must have one of the encoding values defined
for the
.SM ELF
header's \f4e_ident[EI_DATA]\fP entry [see
\f4elf_getident\fP(3E)].
If the data can be translated,
the functions return
.IR dst .
Otherwise, they return null because an error occurred,
such as incompatible types, destination buffer overflow, etc.
.P
\f4elf_getdata\fP(3E)
describes the
\f4Elf_Data\f1
descriptor, which the translation routines use as follows.
.IP "\f4d_buf\fP" 14
Both the source and destination must have valid buffer pointers.
.IP "\f4d_type\fP"
This member's value specifies the type of
the data to which \f4d_buf\fP points and the type of
data to be created in the destination.
The program supplies a \f4d_type\fP value in the source;
the library sets the destination's \f4d_type\fP to the same value.
These values are summarized below.
.IP "\f4d_size\fP"
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 \f4d_size\fP
member to the actual size required, after the translation occurs.
The source and destination sizes may differ.
.IP "\f4d_version\fP"
This member holds version number of the objects (desired) in the buffer.
The source and destination versions are independent.
.P
Translation routines allow the source and destination buffers
to coincide.
That is, \f4dst->d_buf\fP may equal \fPsrc->d_buf\fP.
Other cases where the source and destination buffers overlap
give undefined behavior.
.P
.ne 20
.TS
center;
cf4 c
lf4 | lf4.
Elf_Type	32-Bit Memory Type
.sp .3v
_
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
.sp .3v
_
.TE
.P
``Translating'' buffers of type
\f4ELF_T_BYTE\f1
does not change the byte order.
.SH "SEE ALSO"
.na
\f4elf\fP(3E),
\f4elf_fsize\fP(3E),
\f4elf_getdata\fP(3E),
\f4elf_getident\fP(3E).
