xref: /titanic_51/usr/src/cmd/sgs/elfwrap/common/machine.c (revision dcda19f50b2b80bfc622fff718ac04fb0e1cb670)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include	<_elfwrap.h>
29 
30 #if	defined(lint)
31 #include	<machdep.h>
32 #else
33 #if	defined(ELFWRAP_X86)
34 #include	<i386/machdep_x86.h>
35 #if	defined(_ELF64)
36 #define	target_init	target_init_amd64
37 #else
38 #define	target_init	target_init_i386
39 #endif
40 #endif
41 #if	defined(ELFWRAP_SPARC)
42 #include	<sparc/machdep_sparc.h>
43 #if	defined(_ELF64)
44 #define	target_init	target_init_sparcv9
45 #else
46 #define	target_init	target_init_sparc
47 #endif
48 #endif
49 #endif
50 
51 /*
52  * Establish any target specific data.  This module is compiled using the
53  * defines shown above, to provide data for each target machine elfwrap(1)
54  * supports - each target module being assigned a unique interface name.
55  */
56 void
57 target_init(TargDesc_t *tdp)
58 {
59 	/*
60 	 * ELF header information.
61 	 */
62 	tdp->td_class = M_CLASS;		/* e_ident[EI_CLASS] */
63 	tdp->td_data = M_DATA;			/* e_ident[EI_DATA] */
64 	tdp->td_mach = M_MACH;			/* e_machine */
65 
66 	/*
67 	 * Default data buffer alignment.
68 	 */
69 	tdp->td_align = M_WORD_ALIGN;		/* d_align */
70 
71 	/*
72 	 * Symbol table entry size.
73 	 */
74 	tdp->td_symsz = sizeof (Sym);		/* d_size */
75 }
76