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 /* 235aefb655Srie * Copyright 2006 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 #include <sys/elf_SPARC.h> 295aefb655Srie #include <debug.h> 305aefb655Srie #include <libld.h> 315aefb655Srie #include <conv.h> 325aefb655Srie #include "_debug.h" 335aefb655Srie #include "msg.h" 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate void 365aefb655Srie Dbg_reloc_apply_reg(Lm_list *lml, int caller, Half mach, Xword off, Xword value) 377c478bd9Sstevel@tonic-gate { 385aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 397c478bd9Sstevel@tonic-gate return; 407c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 417c478bd9Sstevel@tonic-gate return; 425aefb655Srie 435aefb655Srie /* 445aefb655Srie * Print the actual relocation being applied to the specified output 455aefb655Srie * section, the offset represents the actual relocation address, and the 465aefb655Srie * value is the new data being written to that address. 475aefb655Srie */ 485aefb655Srie Elf_reloc_apply_reg(lml, caller, mach, off, value); 497c478bd9Sstevel@tonic-gate } 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate void 525aefb655Srie Dbg_reloc_apply_val(Lm_list *lml, int caller, Xword off, Xword value) 537c478bd9Sstevel@tonic-gate { 545aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 557c478bd9Sstevel@tonic-gate return; 567c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 577c478bd9Sstevel@tonic-gate return; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 605aefb655Srie * Print the actual relocation being applied to the specified output 615aefb655Srie * section, the offset represents the actual relocation address, and the 625aefb655Srie * value is the new data being written to that address. 637c478bd9Sstevel@tonic-gate */ 645aefb655Srie Elf_reloc_apply_val(lml, caller, off, value); 657c478bd9Sstevel@tonic-gate } 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate void 685aefb655Srie Dbg_reloc_error(Lm_list *lml, int caller, Half mach, Word type, void *reloc, 695aefb655Srie const char *sname) 707c478bd9Sstevel@tonic-gate { 715aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 727c478bd9Sstevel@tonic-gate return; 737c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 747c478bd9Sstevel@tonic-gate return; 757c478bd9Sstevel@tonic-gate 765aefb655Srie Elf_reloc_entry_1(lml, caller, MSG_INTL(MSG_STR_IN), mach, type, reloc, 775aefb655Srie NULL, sname, MSG_INTL(MSG_REL_BADROFFSET)); 785aefb655Srie } 795aefb655Srie 805aefb655Srie void 815aefb655Srie Dbg_reloc_run(Rt_map *lmp, uint_t rtype, int info, int dtype) 825aefb655Srie { 835aefb655Srie Lm_list *lml = LIST(lmp); 845aefb655Srie const char *str, *name = NAME(lmp); 855aefb655Srie 865aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 875aefb655Srie return; 885aefb655Srie 895aefb655Srie if (dtype == DBG_REL_FINISH) { 905aefb655Srie if (info) 915aefb655Srie str = MSG_ORIG(MSG_STR_EMPTY); 925aefb655Srie else 935aefb655Srie str = MSG_INTL(MSG_REL_FAIL); 945aefb655Srie } else { 955aefb655Srie if (info) 965aefb655Srie str = MSG_INTL(MSG_REL_PLT); 975aefb655Srie else 985aefb655Srie str = MSG_ORIG(MSG_STR_EMPTY); 995aefb655Srie } 1005aefb655Srie 1015aefb655Srie if (dtype == DBG_REL_START) { 1025aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 1035aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_START), name, str); 1045aefb655Srie 1055aefb655Srie if (DBG_NOTDETAIL()) 1065aefb655Srie return; 1075aefb655Srie 1085aefb655Srie Elf_reloc_title(lml, ELF_DBG_RTLD, rtype); 1095aefb655Srie 1105aefb655Srie } else { 1115aefb655Srie if (dtype == DBG_REL_NONE) { 1125aefb655Srie dbg_print(lml, MSG_ORIG(MSG_STR_EMPTY)); 1135aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_NONE), name, str); 1145aefb655Srie } else 1155aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_FINISH), name, 1165aefb655Srie str); 1175aefb655Srie 1185aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 1195aefb655Srie } 1207c478bd9Sstevel@tonic-gate } 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate void 1235aefb655Srie Dbg_reloc_copy(Rt_map *dlmp, Rt_map *nlmp, const char *name, int zero) 1247c478bd9Sstevel@tonic-gate { 1255aefb655Srie const char *str; 1267c478bd9Sstevel@tonic-gate 1275aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 1287c478bd9Sstevel@tonic-gate return; 1297c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1307c478bd9Sstevel@tonic-gate return; 1317c478bd9Sstevel@tonic-gate 1325aefb655Srie if (zero) 1335aefb655Srie str = MSG_INTL(MSG_STR_COPYZERO); 1345aefb655Srie else 1355aefb655Srie str = MSG_ORIG(MSG_STR_EMPTY); 1367c478bd9Sstevel@tonic-gate 1375aefb655Srie dbg_print(LIST(dlmp), MSG_INTL(MSG_REL_COPY), NAME(dlmp), NAME(nlmp), 1385aefb655Srie name, str); 1397c478bd9Sstevel@tonic-gate } 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate void 1425aefb655Srie Dbg_reloc_generate(Lm_list *lml, Os_desc *osp, Word type) 1437c478bd9Sstevel@tonic-gate { 1445aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 1457c478bd9Sstevel@tonic-gate return; 1465aefb655Srie 1475aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 1485aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_GENERATE), osp->os_name); 1495aefb655Srie 1507c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1517c478bd9Sstevel@tonic-gate return; 1527c478bd9Sstevel@tonic-gate 1535aefb655Srie Elf_reloc_title(lml, ELF_DBG_LD, type); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate void 1575aefb655Srie Dbg_reloc_proc(Lm_list *lml, Os_desc *osp, Is_desc *isp, Is_desc *risp) 1587c478bd9Sstevel@tonic-gate { 1595aefb655Srie const char *str1, *str2; 1605aefb655Srie 1615aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 1627c478bd9Sstevel@tonic-gate return; 1635aefb655Srie 1645aefb655Srie if (osp && osp->os_name) 1655aefb655Srie str1 = osp->os_name; 1665aefb655Srie else 1675aefb655Srie str1 = MSG_INTL(MSG_STR_NULL); 1685aefb655Srie 1695aefb655Srie if (isp && isp->is_file) 1705aefb655Srie str2 = isp->is_file->ifl_name; 1715aefb655Srie else if (risp && risp->is_file) 1725aefb655Srie str2 = risp->is_file->ifl_name; 1735aefb655Srie else 1745aefb655Srie str2 = MSG_INTL(MSG_STR_NULL); 1755aefb655Srie 1765aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 1775aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_COLLECT), str1, str2); 1785aefb655Srie 1797c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1807c478bd9Sstevel@tonic-gate return; 1817c478bd9Sstevel@tonic-gate 1825aefb655Srie Elf_reloc_title(lml, ELF_DBG_LD, risp->is_shdr->sh_type); 1837c478bd9Sstevel@tonic-gate } 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate void 1865aefb655Srie Dbg_reloc_doact_title(Lm_list *lml) 1877c478bd9Sstevel@tonic-gate { 1885aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 1897c478bd9Sstevel@tonic-gate return; 1905aefb655Srie if (DBG_NOTDETAIL()) 1915aefb655Srie return; 1925aefb655Srie 1935aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 1945aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_ACTIVE)); 1955aefb655Srie Elf_reloc_title(lml, ELF_DBG_LD, 0); 1967c478bd9Sstevel@tonic-gate } 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate void 1995aefb655Srie Dbg_reloc_doact(Lm_list *lml, int caller, Half mach, Word type, Word rtype, 2005aefb655Srie Xword off, Xword value, const char *symname, Os_desc *osp) 2017c478bd9Sstevel@tonic-gate { 2025aefb655Srie const char *secname; 2035aefb655Srie 2045aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 2057c478bd9Sstevel@tonic-gate return; 2067c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2077c478bd9Sstevel@tonic-gate return; 2085aefb655Srie 2095aefb655Srie if (osp) { 2105aefb655Srie secname = osp->os_name; 2115aefb655Srie off += osp->os_shdr->sh_offset; 2125aefb655Srie } else 2135aefb655Srie secname = MSG_ORIG(MSG_STR_EMPTY); 2145aefb655Srie 2155aefb655Srie Elf_reloc_entry_2(lml, caller, MSG_ORIG(MSG_STR_EMPTY), type, 216c13de8f6Sab conv_reloc_type(mach, rtype, 0), off, value, secname, symname, 2175aefb655Srie MSG_ORIG(MSG_STR_EMPTY)); 2187c478bd9Sstevel@tonic-gate } 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate void 2215aefb655Srie Dbg_reloc_dooutrel(Lm_list *lml, Word type) 2227c478bd9Sstevel@tonic-gate { 2235aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 2247c478bd9Sstevel@tonic-gate return; 2257c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2267c478bd9Sstevel@tonic-gate return; 2277c478bd9Sstevel@tonic-gate 2285aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 2295aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_CREATING)); 2305aefb655Srie Elf_reloc_title(lml, ELF_DBG_LD, type); 2317c478bd9Sstevel@tonic-gate } 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate void 2345aefb655Srie Dbg_reloc_discard(Lm_list *lml, Half mach, Rel_desc *rsp) 2357c478bd9Sstevel@tonic-gate { 2365aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 2377c478bd9Sstevel@tonic-gate return; 2387c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2397c478bd9Sstevel@tonic-gate return; 2407c478bd9Sstevel@tonic-gate 2415aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_DISCARDED), 2425aefb655Srie rsp->rel_isdesc->is_basename, rsp->rel_isdesc->is_file->ifl_name, 243c13de8f6Sab conv_reloc_type(mach, rsp->rel_rtype, 0), 244c13de8f6Sab EC_OFF(rsp->rel_roffset)); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate void 2485aefb655Srie Dbg_reloc_transition(Lm_list *lml, Half mach, Word oldrtype, Word newrtype, 2495aefb655Srie Xword off, const char *sym) 2507c478bd9Sstevel@tonic-gate { 2515aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 2525aefb655Srie return; 2535aefb655Srie 2545aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_TRANS), EC_OFF(off), 255c13de8f6Sab conv_reloc_type(mach, oldrtype, 0) + M_R_STR_LEN, 256c13de8f6Sab conv_reloc_type(mach, newrtype, 0) + M_R_STR_LEN, sym); 2575aefb655Srie } 2585aefb655Srie 2595aefb655Srie void 2605aefb655Srie Dbg_reloc_out(Ofl_desc *ofl, int caller, Word type, void *reloc, 2615aefb655Srie const char *secname, const char *symname) 2625aefb655Srie { 2635aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 2647c478bd9Sstevel@tonic-gate return; 2657c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2667c478bd9Sstevel@tonic-gate return; 2677c478bd9Sstevel@tonic-gate 2685aefb655Srie Elf_reloc_entry_1(ofl->ofl_lml, caller, MSG_ORIG(MSG_STR_EMPTY), 2695aefb655Srie ofl->ofl_dehdr->e_machine, type, reloc, secname, symname, 2707c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_EMPTY)); 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate void 2745aefb655Srie Dbg_reloc_in(Lm_list *lml, int caller, Half mach, Word type, void *reloc, 2755aefb655Srie const char *secname, const char *symname) 2767c478bd9Sstevel@tonic-gate { 2775aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 2787c478bd9Sstevel@tonic-gate return; 2797c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2807c478bd9Sstevel@tonic-gate return; 2817c478bd9Sstevel@tonic-gate 2825aefb655Srie Elf_reloc_entry_1(lml, caller, MSG_INTL(MSG_STR_IN), mach, type, reloc, 2835aefb655Srie secname, symname, MSG_ORIG(MSG_STR_EMPTY)); 2847c478bd9Sstevel@tonic-gate } 2857c478bd9Sstevel@tonic-gate 286*d2ef9fe9Sab /* 287*d2ef9fe9Sab * Used by ld when '-z relaxreloc' is in use and a relocation 288*d2ef9fe9Sab * is redirected to a kept section. 289*d2ef9fe9Sab * 290*d2ef9fe9Sab * entry: 291*d2ef9fe9Sab * lml - Link map control list 292*d2ef9fe9Sab * sdp - The replacement symbol to be used with the relocation, 293*d2ef9fe9Sab * which references the kept section. 294*d2ef9fe9Sab */ 295*d2ef9fe9Sab void 296*d2ef9fe9Sab Dbg_reloc_sloppycomdat(Lm_list *lml, const char *secname, Sym_desc *sdp) 297*d2ef9fe9Sab { 298*d2ef9fe9Sab const char *nfname; 299*d2ef9fe9Sab 300*d2ef9fe9Sab if (DBG_NOTCLASS(DBG_C_RELOC) || DBG_NOTDETAIL()) 301*d2ef9fe9Sab return; 302*d2ef9fe9Sab 303*d2ef9fe9Sab nfname = (sdp && sdp->sd_file && sdp->sd_file->ifl_name) 304*d2ef9fe9Sab ? sdp->sd_file->ifl_name : MSG_INTL(MSG_STR_NULL); 305*d2ef9fe9Sab 306*d2ef9fe9Sab dbg_print(lml, MSG_INTL(MSG_REL_SLOPPYCOMDAT), secname, nfname); 307*d2ef9fe9Sab } 308*d2ef9fe9Sab 3097c478bd9Sstevel@tonic-gate /* 3105aefb655Srie * Print a output relocation structure (Rel_desc). 3117c478bd9Sstevel@tonic-gate */ 3127c478bd9Sstevel@tonic-gate void 3135aefb655Srie Dbg_reloc_ors_entry(Lm_list *lml, int caller, Word type, Half mach, 3145aefb655Srie Rel_desc *orsp) 3157c478bd9Sstevel@tonic-gate { 3165aefb655Srie const char *secname, *symname; 3177c478bd9Sstevel@tonic-gate 3185aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 3197c478bd9Sstevel@tonic-gate return; 3207c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 3217c478bd9Sstevel@tonic-gate return; 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate if (orsp->rel_flags & (FLG_REL_GOT | FLG_REL_RFPTR1 | FLG_REL_RFPTR2)) 3245aefb655Srie secname = MSG_ORIG(MSG_SCN_GOT); 3257c478bd9Sstevel@tonic-gate else if (orsp->rel_flags & FLG_REL_PLT) 3265aefb655Srie secname = MSG_ORIG(MSG_SCN_PLT); 3277c478bd9Sstevel@tonic-gate else if (orsp->rel_flags & FLG_REL_BSS) 3285aefb655Srie secname = MSG_ORIG(MSG_SCN_BSS); 3297c478bd9Sstevel@tonic-gate else if (orsp->rel_osdesc) 3305aefb655Srie secname = orsp->rel_osdesc->os_name; 3317c478bd9Sstevel@tonic-gate else 3325aefb655Srie secname = MSG_INTL(MSG_STR_NULL); 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate /* 3355aefb655Srie * Register symbols can be relocated/initialized to a constant, which 3365aefb655Srie * is a special case where the symbol index is 0. 3377c478bd9Sstevel@tonic-gate */ 3387c478bd9Sstevel@tonic-gate if (orsp->rel_sym != NULL) 3395aefb655Srie symname = orsp->rel_sym->sd_name; 3407c478bd9Sstevel@tonic-gate else 3415aefb655Srie symname = MSG_ORIG(MSG_STR_EMPTY); 3427c478bd9Sstevel@tonic-gate 3435aefb655Srie Elf_reloc_entry_2(lml, caller, MSG_INTL(MSG_STR_OUT), type, 344c13de8f6Sab conv_reloc_type(mach, orsp->rel_rtype, 0), orsp->rel_roffset, 3455aefb655Srie orsp->rel_raddend, secname, symname, MSG_ORIG(MSG_STR_EMPTY)); 3467c478bd9Sstevel@tonic-gate } 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate /* 3497c478bd9Sstevel@tonic-gate * Print a Active relocation structure (Rel_desc). 3507c478bd9Sstevel@tonic-gate */ 3517c478bd9Sstevel@tonic-gate void 3525aefb655Srie Dbg_reloc_ars_entry(Lm_list *lml, int caller, Word type, Half mach, 3535aefb655Srie Rel_desc *arsp) 3547c478bd9Sstevel@tonic-gate { 3555aefb655Srie const char *secname; 3567c478bd9Sstevel@tonic-gate 3575aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 3587c478bd9Sstevel@tonic-gate return; 3597c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 3607c478bd9Sstevel@tonic-gate return; 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate if (arsp->rel_flags & (FLG_REL_GOT | FLG_REL_FPTR)) 3635aefb655Srie secname = MSG_ORIG(MSG_SCN_GOT); 3647c478bd9Sstevel@tonic-gate else 3655aefb655Srie secname = arsp->rel_osdesc->os_name; 3667c478bd9Sstevel@tonic-gate 3675aefb655Srie Elf_reloc_entry_2(lml, caller, MSG_INTL(MSG_STR_ACT), type, 368c13de8f6Sab conv_reloc_type(mach, arsp->rel_rtype, 0), arsp->rel_roffset, 3695aefb655Srie arsp->rel_raddend, secname, arsp->rel_sym->sd_name, 3705aefb655Srie MSG_ORIG(MSG_STR_EMPTY)); 3717c478bd9Sstevel@tonic-gate } 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate void 3745aefb655Srie Dbg_reloc_entry(Lm_list *lml, const char *prestr, Half mach, Word type, 3755aefb655Srie void *reloc, const char *secname, const char *symname, const char *poststr) 3767c478bd9Sstevel@tonic-gate { 3775aefb655Srie /* 3785aefb655Srie * Register relocations can use a constant initializer, in which case 3795aefb655Srie * the associated symbol is 0. 3805aefb655Srie */ 3815aefb655Srie if (symname == NULL) 3825aefb655Srie symname = MSG_ORIG(MSG_STR_EMPTY); 3837c478bd9Sstevel@tonic-gate 3845aefb655Srie Elf_reloc_entry_1(lml, ELF_DBG_LD, prestr, mach, type, reloc, secname, 3855aefb655Srie symname, poststr); 3865aefb655Srie } 3877c478bd9Sstevel@tonic-gate 3885aefb655Srie #if defined(_ELF64) 3897c478bd9Sstevel@tonic-gate 3905aefb655Srie void 3915aefb655Srie Dbg64_pltpad_to(Lm_list *lml, const char *file, Addr pltpad, 3925aefb655Srie const char *dfile, const char *symname) 3935aefb655Srie { 3945aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 3955aefb655Srie return; 3965aefb655Srie if (DBG_NOTDETAIL()) 3975aefb655Srie return; 3987c478bd9Sstevel@tonic-gate 3995aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PLTPAD_TO), EC_ADDR(pltpad), file, 4005aefb655Srie dfile, symname); 4017c478bd9Sstevel@tonic-gate } 4027c478bd9Sstevel@tonic-gate 4037c478bd9Sstevel@tonic-gate void 4045aefb655Srie Dbg64_pltpad_from(Lm_list *lml, const char *file, const char *sname, 4055aefb655Srie Addr pltpad) 4067c478bd9Sstevel@tonic-gate { 4075aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 4087c478bd9Sstevel@tonic-gate return; 4097c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4107c478bd9Sstevel@tonic-gate return; 4117c478bd9Sstevel@tonic-gate 4125aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PLTPAD_FROM), EC_ADDR(pltpad), file, 4135aefb655Srie Dbg_demangle_name(sname)); 4147c478bd9Sstevel@tonic-gate } 4157c478bd9Sstevel@tonic-gate 4165aefb655Srie #endif 4175aefb655Srie 4187c478bd9Sstevel@tonic-gate /* 4195aefb655Srie * Relocation output can differ depending on the caller and the type of 4205aefb655Srie * relocation record. However, the final diagnostic is maintained here so 4215aefb655Srie * that the various message strings remain consistent. 4225aefb655Srie * 4235aefb655Srie * elfdump: 4245aefb655Srie * type offset addend section symbol 4255aefb655Srie * X X X X X (Rela) 4265aefb655Srie * 4275aefb655Srie * type offset section symbol 4285aefb655Srie * X X X X (Rel) 4295aefb655Srie * 4305aefb655Srie * Note, it could be argued that the section name output with elfdump(1) is 4315aefb655Srie * unnecessary, as the table itself is identified with a title that reveals 4325aefb655Srie * the section name. However, the output does provide for grep(1)'ing for 4335aefb655Srie * individual entries and obtaining the section name with this type of input. 4345aefb655Srie * 4355aefb655Srie * ld.so.1: 4365aefb655Srie * (prestr) type offset addend symbol 4375aefb655Srie * value 4385aefb655Srie * in X X X X (Rela) 4395aefb655Srie * apply X X 4405aefb655Srie * 4415aefb655Srie * (prestr) type offset value symbol 4425aefb655Srie * in X X X (Rel) 4435aefb655Srie * apply X X 4445aefb655Srie * 4455aefb655Srie * ld: 4465aefb655Srie * (prestr) type offset addend section symbol 4475aefb655Srie * in X X X X X (Rela) 4485aefb655Srie * act X X X X 4495aefb655Srie * out X X X X 4505aefb655Srie * 4515aefb655Srie * (prestr) type offset section symbol 4525aefb655Srie * in X X X X (Rel) 4535aefb655Srie * act X X X X 4545aefb655Srie * out X X X X 4555aefb655Srie * 4565aefb655Srie * Both Rela and Rel active relocations are printed as: 4575aefb655Srie * 4585aefb655Srie * type offset value section symbol 4595aefb655Srie * X X X X X 4607c478bd9Sstevel@tonic-gate */ 4617c478bd9Sstevel@tonic-gate void 4625aefb655Srie Elf_reloc_title(Lm_list *lml, int caller, Word type) 4637c478bd9Sstevel@tonic-gate { 4645aefb655Srie if (caller == ELF_DBG_ELFDUMP) { 4655aefb655Srie if (type == SHT_RELA) { 4665aefb655Srie if (DBG_NOTLONG()) 4675aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFSA_TITLE)); 4685aefb655Srie else 4695aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFLA_TITLE)); 4705aefb655Srie } else { 4715aefb655Srie if (DBG_NOTLONG()) 4725aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFSN_TITLE)); 4735aefb655Srie else 4745aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFLN_TITLE)); 4755aefb655Srie } 4765aefb655Srie return; 4775aefb655Srie } 4785aefb655Srie if (caller == ELF_DBG_RTLD) { 4795aefb655Srie if (type == SHT_RELA) { 4805aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RTA_TITLE)); 4815aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RTV_TITLE)); 4825aefb655Srie } else 4835aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RTN_TITLE)); 4845aefb655Srie return; 4855aefb655Srie } 4865aefb655Srie if (caller == ELF_DBG_LD) { 4875aefb655Srie if (type == 0) { 4885aefb655Srie if (DBG_NOTLONG()) 4895aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDSV_TITLE)); 4905aefb655Srie else 4915aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDLV_TITLE)); 4925aefb655Srie return; 4935aefb655Srie } 4945aefb655Srie if (type == SHT_RELA) { 4955aefb655Srie if (DBG_NOTLONG()) 4965aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDSA_TITLE)); 4975aefb655Srie else 4985aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDLA_TITLE)); 4995aefb655Srie } else { 5005aefb655Srie if (DBG_NOTLONG()) 5015aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDSN_TITLE)); 5025aefb655Srie else 5035aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDLN_TITLE)); 5045aefb655Srie } 5057c478bd9Sstevel@tonic-gate } 5067c478bd9Sstevel@tonic-gate } 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate void 5095aefb655Srie Elf_reloc_entry_2(Lm_list *lml, int caller, const char *prestr, Word type, 5105aefb655Srie const char *typestr, Addr off, Sxword add, const char *secname, 5115aefb655Srie const char *symname, const char *poststr) 5127c478bd9Sstevel@tonic-gate { 5135aefb655Srie if (symname) 5145aefb655Srie symname = Elf_demangle_name(symname); 5155aefb655Srie else 5165aefb655Srie symname = MSG_ORIG(MSG_STR_EMPTY); 5177c478bd9Sstevel@tonic-gate 5185aefb655Srie if (caller == ELF_DBG_ELFDUMP) { 5197c478bd9Sstevel@tonic-gate if (type == SHT_RELA) { 5205aefb655Srie if (DBG_NOTLONG()) 5215aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFSA_ENTRY), 5225aefb655Srie typestr, EC_OFF(off), EC_SXWORD(add), 5235aefb655Srie secname, symname); 5245aefb655Srie else 5255aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFLA_ENTRY), 5265aefb655Srie typestr, EC_OFF(off), EC_SXWORD(add), 5275aefb655Srie secname, symname); 5287c478bd9Sstevel@tonic-gate } else { 5295aefb655Srie if (DBG_NOTLONG()) 5305aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFSN_ENTRY), 5315aefb655Srie typestr, EC_OFF(off), secname, symname); 5325aefb655Srie else 5335aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_EFLN_ENTRY), 5345aefb655Srie typestr, EC_OFF(off), secname, symname); 5357c478bd9Sstevel@tonic-gate } 5365aefb655Srie return; 5375aefb655Srie } 5385aefb655Srie if (caller == ELF_DBG_RTLD) { 5395aefb655Srie if (type == SHT_RELA) 5405aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RTA_ENTRY), prestr, 541c1c6f601Srie typestr, EC_OFF(off), EC_SXWORD(add), symname, 542c1c6f601Srie poststr); 5435aefb655Srie else 5445aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RTN_ENTRY), prestr, 545c1c6f601Srie typestr, EC_OFF(off), symname, poststr); 5465aefb655Srie return; 5475aefb655Srie } 5485aefb655Srie if (caller == ELF_DBG_LD) { 5497c478bd9Sstevel@tonic-gate if (type == SHT_RELA) { 5505aefb655Srie if (DBG_NOTLONG()) 5515aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDSA_ENTRY), 5525aefb655Srie prestr, typestr, EC_OFF(off), 5535aefb655Srie EC_SXWORD(add), secname, symname, poststr); 5545aefb655Srie else 5555aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDLA_ENTRY), 5565aefb655Srie prestr, typestr, EC_OFF(off), 5575aefb655Srie EC_SXWORD(add), secname, symname, poststr); 5587c478bd9Sstevel@tonic-gate } else { 5595aefb655Srie if (DBG_NOTLONG()) 5605aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDSN_ENTRY), 5615aefb655Srie prestr, typestr, EC_OFF(off), secname, 5625aefb655Srie symname, poststr); 5635aefb655Srie else 5645aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_LDLN_ENTRY), 5655aefb655Srie prestr, typestr, EC_OFF(off), secname, 5665aefb655Srie symname, poststr); 5677c478bd9Sstevel@tonic-gate } 5687c478bd9Sstevel@tonic-gate } 5697c478bd9Sstevel@tonic-gate } 5707c478bd9Sstevel@tonic-gate 5717c478bd9Sstevel@tonic-gate void 5725aefb655Srie Elf_reloc_entry_1(Lm_list *lml, int caller, const char *prestr, Half mach, 5735aefb655Srie Word type, void *reloc, const char *secname, const char *symname, 5745aefb655Srie const char *poststr) 5757c478bd9Sstevel@tonic-gate { 5765aefb655Srie Addr off; 5775aefb655Srie Sxword add; 5785aefb655Srie const char *str; 5795aefb655Srie 5805aefb655Srie if (type == SHT_RELA) { 5815aefb655Srie Rela *rela = (Rela *)reloc; 5825aefb655Srie 583c13de8f6Sab str = conv_reloc_type(mach, ELF_R_TYPE(rela->r_info), 0); 5845aefb655Srie off = rela->r_offset; 5855aefb655Srie add = rela->r_addend; 5865aefb655Srie } else { 5875aefb655Srie Rel *rel = (Rel *)reloc; 5885aefb655Srie 589c13de8f6Sab str = conv_reloc_type(mach, ELF_R_TYPE(rel->r_info), 0); 5905aefb655Srie off = rel->r_offset; 5915aefb655Srie add = 0; 5925aefb655Srie } 5935aefb655Srie Elf_reloc_entry_2(lml, caller, prestr, type, str, off, add, secname, 5945aefb655Srie symname, poststr); 5957c478bd9Sstevel@tonic-gate } 5967c478bd9Sstevel@tonic-gate 5975aefb655Srie /* 5985aefb655Srie * Display any applied relocations. Presently, these are only called from 5995aefb655Srie * ld.so.1, but the interfaces are maintained here to insure consistency with 6005aefb655Srie * other relocation diagnostics. 6015aefb655Srie */ 6027c478bd9Sstevel@tonic-gate void 6035aefb655Srie Elf_reloc_apply_val(Lm_list *lml, int caller, Xword offset, Xword value) 6047c478bd9Sstevel@tonic-gate { 6055aefb655Srie if (caller == ELF_DBG_RTLD) 6065aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RT_APLVAL), EC_XWORD(offset), 6075aefb655Srie EC_XWORD(value)); 6085aefb655Srie } 6095aefb655Srie void 6105aefb655Srie Elf_reloc_apply_reg(Lm_list *lml, int caller, Half mach, Xword offset, 6115aefb655Srie Xword value) 6125aefb655Srie { 6135aefb655Srie if (caller == ELF_DBG_RTLD) 6145aefb655Srie dbg_print(lml, MSG_INTL(MSG_REL_RT_APLREG), 6155aefb655Srie conv_sym_value(mach, STT_SPARC_REGISTER, offset), 6165aefb655Srie EC_XWORD(value)); 6177c478bd9Sstevel@tonic-gate } 618