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 */
21552ff457Srie
227c478bd9Sstevel@tonic-gate /*
235aefb655Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include "reloc.h"
297c478bd9Sstevel@tonic-gate
30552ff457Srie static const char *rels[R_AMD64_NUM] = {
31*a530dbfeSRichard Lowe [R_AMD64_NONE] = "R_AMD64_NONE",
32*a530dbfeSRichard Lowe [R_AMD64_64] = "R_AMD64_64",
33*a530dbfeSRichard Lowe [R_AMD64_PC32] = "R_AMD64_PC32",
34*a530dbfeSRichard Lowe [R_AMD64_GOT32] = "R_AMD64_GOT32",
35*a530dbfeSRichard Lowe [R_AMD64_PLT32] = "R_AMD64_PLT32",
36*a530dbfeSRichard Lowe [R_AMD64_COPY] = "R_AMD64_COPY",
37*a530dbfeSRichard Lowe [R_AMD64_GLOB_DAT] = "R_AMD64_GLOB_DAT",
38*a530dbfeSRichard Lowe [R_AMD64_JUMP_SLOT] = "R_AMD64_JUMP_SLOT",
39*a530dbfeSRichard Lowe [R_AMD64_RELATIVE] = "R_AMD64_RELATIVE",
40*a530dbfeSRichard Lowe [R_AMD64_GOTPCREL] = "R_AMD64_GOTPCREL",
41*a530dbfeSRichard Lowe [R_AMD64_32] = "R_AMD64_32",
42*a530dbfeSRichard Lowe [R_AMD64_32S] = "R_AMD64_32S",
43*a530dbfeSRichard Lowe [R_AMD64_16] = "R_AMD64_16",
44*a530dbfeSRichard Lowe [R_AMD64_PC16] = "R_AMD64_PC16",
45*a530dbfeSRichard Lowe [R_AMD64_8] = "R_AMD64_8",
46*a530dbfeSRichard Lowe [R_AMD64_PC8] = "R_AMD64_PC8",
47*a530dbfeSRichard Lowe [R_AMD64_DTPMOD64] = "R_AMD64_DTPMOD64",
48*a530dbfeSRichard Lowe [R_AMD64_DTPOFF64] = "R_AMD64_DTPOFF64",
49*a530dbfeSRichard Lowe [R_AMD64_TPOFF64] = "R_AMD64_TPOFF64",
50*a530dbfeSRichard Lowe [R_AMD64_TLSGD] = "R_AMD64_TLSGD",
51*a530dbfeSRichard Lowe [R_AMD64_TLSLD] = "R_AMD64_TLSLD",
52*a530dbfeSRichard Lowe [R_AMD64_DTPOFF32] = "R_AMD64_DTPOFF32",
53*a530dbfeSRichard Lowe [R_AMD64_GOTTPOFF] = "R_AMD64_GOTTPOFF",
54*a530dbfeSRichard Lowe [R_AMD64_TPOFF32] = "R_AMD64_TPOFF32",
55*a530dbfeSRichard Lowe [R_AMD64_PC64] = "R_AMD64_PC64",
56*a530dbfeSRichard Lowe [R_AMD64_GOTOFF64] = "R_AMD64_GOTOFF64",
57*a530dbfeSRichard Lowe [R_AMD64_GOTPC32] = "R_AMD64_GOTPC32",
58*a530dbfeSRichard Lowe [R_AMD64_GOT64] = "R_AMD64_GOT64",
59*a530dbfeSRichard Lowe [R_AMD64_GOTPCREL64] = "R_AMD64_GOTPCREL64",
60*a530dbfeSRichard Lowe [R_AMD64_GOTPC64] = "R_AMD64_GOTPC64",
61*a530dbfeSRichard Lowe [R_AMD64_GOTPLT64] = "R_AMD64_GOTPLT64",
62*a530dbfeSRichard Lowe [R_AMD64_PLTOFF64] = "R_AMD64_PLTOFF64",
63*a530dbfeSRichard Lowe [R_AMD64_SIZE32] = "R_AMD64_SIZE32",
64*a530dbfeSRichard Lowe [R_AMD64_SIZE64] = "R_AMD64_SIZE64",
65*a530dbfeSRichard Lowe [R_AMD64_GOTPC32_TLSDESC] = "R_AMD64_GOTPC32_TLSDESC",
66*a530dbfeSRichard Lowe [R_AMD64_TLSDESC_CALL] = "R_AMD64_TLSDESC_CALL",
67*a530dbfeSRichard Lowe [R_AMD64_TLSDESC] = "R_AMD64_TLSDESC",
68*a530dbfeSRichard Lowe [R_AMD64_IRELATIVE] = "R_AMD64_IRELATIVE",
69*a530dbfeSRichard Lowe [R_AMD64_RELATIVE64] = "R_AMD64_RELATIVE64",
70*a530dbfeSRichard Lowe [R_AMD64_UNKNOWN39] = "R_AMD64_UNKNOWN39",
71*a530dbfeSRichard Lowe [R_AMD64_UNKNOWN40] = "R_AMD64_UNKNOWN40",
72*a530dbfeSRichard Lowe [R_AMD64_GOTPCRELX] = "R_AMD64_GOTPCRELX",
73*a530dbfeSRichard Lowe [R_AMD64_REX_GOTPCRELX] = "R_AMD64_REX_GOTPCRELX",
747c478bd9Sstevel@tonic-gate };
757c478bd9Sstevel@tonic-gate
76*a530dbfeSRichard Lowe #if (R_AMD64_NUM != (R_AMD64_REX_GOTPCRELX + 1))
77552ff457Srie #error "R_AMD64_NUM has grown"
78552ff457Srie #endif
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate /*
81552ff457Srie * This is a 'stub' of the orignal version defined in liblddbg.so. This stub
82552ff457Srie * returns the 'int string' of the relocation in question instead of converting
83552ff457Srie * the relocation to it's full syntax.
847c478bd9Sstevel@tonic-gate */
857c478bd9Sstevel@tonic-gate const char *
conv_reloc_amd64_type(Word type)865aefb655Srie conv_reloc_amd64_type(Word type)
877c478bd9Sstevel@tonic-gate {
88*a530dbfeSRichard Lowe static char strbuf[32];
89552ff457Srie int ndx = 31;
90552ff457Srie
91552ff457Srie if (type < R_AMD64_NUM)
92552ff457Srie return (rels[type]);
93552ff457Srie
94552ff457Srie strbuf[ndx--] = '\0';
95552ff457Srie do {
96552ff457Srie strbuf[ndx--] = '0' + (type % 10);
97552ff457Srie type = type / 10;
98552ff457Srie } while ((ndx >= (int)0) && (type > (Word)0));
99552ff457Srie
100552ff457Srie return (&strbuf[ndx + 1]);
1017c478bd9Sstevel@tonic-gate }
102