xref: /onnv-gate/usr/src/cmd/sgs/libconv/common/relocate.c (revision 5088:26c540f30cd3)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211618Srie 
220Sstevel@tonic-gate /*
234734Sab196087  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * String conversion routine for relocation types.
300Sstevel@tonic-gate  */
310Sstevel@tonic-gate #include	<stdio.h>
320Sstevel@tonic-gate #include	"_conv.h"
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * Generic front-end that determines machine specific relocations.
360Sstevel@tonic-gate  */
370Sstevel@tonic-gate const char *
conv_reloc_type(Half mach,Word type,Conv_fmt_flags_t fmt_flags,Conv_inv_buf_t * inv_buf)38*5088Sab196087 conv_reloc_type(Half mach, Word type, Conv_fmt_flags_t fmt_flags,
39*5088Sab196087     Conv_inv_buf_t *inv_buf)
400Sstevel@tonic-gate {
411976Sab196087 	switch (mach) {
421976Sab196087 	case EM_386:
434734Sab196087 		return (conv_reloc_386_type(type, fmt_flags, inv_buf));
440Sstevel@tonic-gate 
451976Sab196087 	case EM_SPARC:
461976Sab196087 	case EM_SPARC32PLUS:
471976Sab196087 	case EM_SPARCV9:
484734Sab196087 		return (conv_reloc_SPARC_type(type, fmt_flags, inv_buf));
490Sstevel@tonic-gate 
501976Sab196087 	case EM_AMD64:
514734Sab196087 		return (conv_reloc_amd64_type(type, fmt_flags, inv_buf));
521976Sab196087 	}
530Sstevel@tonic-gate 
541976Sab196087 	/* If didn't match a machine type, use integer value */
554734Sab196087 	return (conv_invalid_val(inv_buf, type, fmt_flags));
560Sstevel@tonic-gate }
574734Sab196087 
584734Sab196087 /*
594734Sab196087  * This version supplies a static buffer. It is for the benefit of
604734Sab196087  * do_reloc().
614734Sab196087  */
624734Sab196087 const char *
conv_reloc_type_static(Half mach,Word type,Conv_fmt_flags_t fmt_flags)63*5088Sab196087 conv_reloc_type_static(Half mach, Word type, Conv_fmt_flags_t fmt_flags)
644734Sab196087 {
654734Sab196087 	static Conv_inv_buf_t inv_buf;
664734Sab196087 
674734Sab196087 	return (conv_reloc_type(mach, type, fmt_flags, &inv_buf));
684734Sab196087 }
69