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.
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.
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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
35 Dbg_got_compare(Gottable
*gtp1
, Gottable
*gtp2
)
37 Gotndx
*gnp1
= >p1
->gt_gndx
;
38 Gotndx
*gnp2
= >p2
->gt_gndx
;
40 if (gnp1
->gn_gotndx
> gnp2
->gn_gotndx
)
42 if (gnp1
->gn_gotndx
< gnp2
->gn_gotndx
)
49 Dbg_got_display(Ofl_desc
*ofl
, Off goff
, int stage
,
50 Word m_got_xnumber
, size_t m_got_entsize
)
52 Lm_list
*lml
= ofl
->ofl_lml
;
53 Gottable
*gtp
= ofl
->ofl_gottable
;
57 if (DBG_NOTCLASS(DBG_C_GOT
))
60 if (ofl
->ofl_gotcnt
== m_got_xnumber
)
63 Dbg_util_nl(lml
, DBG_NL_STD
);
64 dbg_print(lml
, MSG_INTL(MSG_GOT_INFO
), EC_WORD(ofl
->ofl_gotcnt
));
69 qsort((char *)gtp
, ofl
->ofl_gotcnt
, sizeof (Gottable
),
70 (int(*)(const void *, const void *))Dbg_got_compare
);
73 dbg_print(lml
, MSG_INTL(MSG_GOT_COLUMNS1
));
75 dbg_print(lml
, MSG_INTL(MSG_GOT_COLUMNS2
));
77 gptr
= (Xword
*)ofl
->ofl_osgot
->os_outdata
->d_buf
;
79 for (gotndx
= 0; gotndx
< ofl
->ofl_gotcnt
; gotndx
++, gtp
++, gptr
++) {
80 Sym_desc
*sdp
= gtp
->gt_sym
;
81 const char *refstr
, *name
;
82 Gotndx
*gnp
= >p
->gt_gndx
;
84 Off off
= goff
+ (gotndx
* m_got_entsize
);
85 char index
[INDEX_STR_SIZE
];
87 (void) snprintf(index
, INDEX_STR_SIZE
, MSG_ORIG(MSG_GOT_INDEX
),
88 EC_SWORD(gnp
->gn_gotndx
));
91 refstr
= MSG_ORIG(MSG_STR_EMPTY
);
92 else if (sdp
->sd_flags
& FLG_SY_SMGOT
)
93 refstr
= MSG_ORIG(MSG_GOT_SMALL_PIC
);
95 refstr
= MSG_ORIG(MSG_GOT_BIG_PIC
);
98 name
= MSG_ORIG(MSG_STR_EMPTY
);
99 else if (sdp
->sd_name
)
100 name
= Dbg_demangle_name(sdp
->sd_name
);
102 name
= MSG_INTL(MSG_STR_UNKNOWN
);
105 gotaddval
= gnp
->gn_addend
;
109 if ((sdp
== 0) || (sdp
->sd_sym
->st_shndx
== SHN_UNDEF
) ||
110 (sdp
->sd_file
== 0)) {
111 dbg_print(lml
, MSG_INTL(MSG_GOT_FORMAT1
), index
,
112 refstr
, EC_OFF(off
), EC_XWORD(gotaddval
), name
);
114 dbg_print(lml
, MSG_INTL(MSG_GOT_FORMAT2
), index
,
115 refstr
, EC_OFF(off
), EC_XWORD(gotaddval
),
116 sdp
->sd_file
->ifl_name
, name
);
122 Elf_got_title(Lm_list
*lml
)
124 dbg_print(lml
, MSG_INTL(MSG_GOT_TITLE
));
128 Elf_got_entry(Lm_list
*lml
, Sword ndx
, Addr addr
, Xword value
, Half mach
,
129 uchar_t ei_target_data
, uchar_t ei_host_data
, Word type
, void *reloc
,
135 Conv_inv_buf_t inv_buf
;
136 char index
[INDEX_STR_SIZE
];
138 (void) snprintf(index
, INDEX_STR_SIZE
, MSG_ORIG(MSG_GOT_INDEX
),
142 * Got sections are SHT_PROGBITS, and are therefore not xlated by
143 * libelf. If the target system has a different byte order than
144 * the system displaying the data, swap the bytes so they are
145 * presented properly.
147 if (ei_target_data
!= ei_host_data
)
148 value
= BSWAP_XWORD(value
);
151 if (type
== SHT_RELA
) {
152 rela
= (Rela
*)reloc
;
153 str
= conv_reloc_type(mach
,
154 ELF_R_TYPE(rela
->r_info
, mach
), 0, &inv_buf
);
157 str
= conv_reloc_type(mach
,
158 ELF_R_TYPE(rel
->r_info
, mach
), 0, &inv_buf
);
162 name
= Elf_demangle_name(name
);
164 name
= MSG_ORIG(MSG_STR_EMPTY
);
166 dbg_print(lml
, MSG_INTL(MSG_GOT_ENTRY_RE
), index
, EC_ADDR(addr
),
167 EC_XWORD(value
), str
, name
);
169 dbg_print(lml
, MSG_INTL(MSG_GOT_ENTRY_NR
), index
, EC_ADDR(addr
),