xref: /titanic_51/usr/src/cmd/sgs/libconv/common/relocate.c (revision d29b2c4438482eb00488be49a1f5d6835f455546)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
23de777a60Sab196087  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate  * String conversion routine for relocation types.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate #include	<stdio.h>
327c478bd9Sstevel@tonic-gate #include	"_conv.h"
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Generic front-end that determines machine specific relocations.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate const char *
38*d29b2c44Sab196087 conv_reloc_type(Half mach, Word type, Conv_fmt_flags_t fmt_flags,
39*d29b2c44Sab196087     Conv_inv_buf_t *inv_buf)
407c478bd9Sstevel@tonic-gate {
41c13de8f6Sab196087 	switch (mach) {
42c13de8f6Sab196087 	case EM_386:
43de777a60Sab196087 		return (conv_reloc_386_type(type, fmt_flags, inv_buf));
447c478bd9Sstevel@tonic-gate 
45c13de8f6Sab196087 	case EM_SPARC:
46c13de8f6Sab196087 	case EM_SPARC32PLUS:
47c13de8f6Sab196087 	case EM_SPARCV9:
48de777a60Sab196087 		return (conv_reloc_SPARC_type(type, fmt_flags, inv_buf));
497c478bd9Sstevel@tonic-gate 
50c13de8f6Sab196087 	case EM_AMD64:
51de777a60Sab196087 		return (conv_reloc_amd64_type(type, fmt_flags, inv_buf));
52c13de8f6Sab196087 	}
537c478bd9Sstevel@tonic-gate 
54c13de8f6Sab196087 	/* If didn't match a machine type, use integer value */
55de777a60Sab196087 	return (conv_invalid_val(inv_buf, type, fmt_flags));
56de777a60Sab196087 }
57de777a60Sab196087 
58de777a60Sab196087 /*
59de777a60Sab196087  * This version supplies a static buffer. It is for the benefit of
60de777a60Sab196087  * do_reloc().
61de777a60Sab196087  */
62de777a60Sab196087 const char *
63*d29b2c44Sab196087 conv_reloc_type_static(Half mach, Word type, Conv_fmt_flags_t fmt_flags)
64de777a60Sab196087 {
65de777a60Sab196087 	static Conv_inv_buf_t inv_buf;
66de777a60Sab196087 
67de777a60Sab196087 	return (conv_reloc_type(mach, type, fmt_flags, &inv_buf));
687c478bd9Sstevel@tonic-gate }
69