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 5*1618Srie * Common Development and Distribution License (the "License"). 6*1618Srie * 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 */ 21*1618Srie 220Sstevel@tonic-gate /* 23*1618Srie * Copyright (c) 1988 AT&T 24*1618Srie * All Rights Reserved 25*1618Srie * 26*1618Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 27*1618Srie * Use is subject to license terms. 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate /* 330Sstevel@tonic-gate * SPARC machine dependent and a.out format file class dependent functions. 340Sstevel@tonic-gate * Contains routines for performing function binding and symbol relocations. 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate #include "_synonyms.h" 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <stdio.h> 390Sstevel@tonic-gate #include <sys/types.h> 400Sstevel@tonic-gate #include <sys/mman.h> 410Sstevel@tonic-gate #include <synch.h> 420Sstevel@tonic-gate #include <dlfcn.h> 43*1618Srie #include <debug.h> 440Sstevel@tonic-gate #include "_a.out.h" 450Sstevel@tonic-gate #include "_rtld.h" 460Sstevel@tonic-gate #include "_audit.h" 470Sstevel@tonic-gate #include "msg.h" 480Sstevel@tonic-gate 490Sstevel@tonic-gate extern void iflush_range(caddr_t, size_t); 500Sstevel@tonic-gate 510Sstevel@tonic-gate /* 520Sstevel@tonic-gate * Function binding routine - invoked on the first call to a function through 530Sstevel@tonic-gate * the procedure linkage table; 540Sstevel@tonic-gate * passes first through an assembly language interface. 550Sstevel@tonic-gate * 560Sstevel@tonic-gate * Takes the address of the PLT entry where the call originated, 570Sstevel@tonic-gate * the offset into the relocation table of the associated 580Sstevel@tonic-gate * relocation entry and the address of the link map (rt_private_map struct) 590Sstevel@tonic-gate * for the entry. 600Sstevel@tonic-gate * 610Sstevel@tonic-gate * Returns the address of the function referenced after re-writing the PLT 620Sstevel@tonic-gate * entry to invoke the function directly. 630Sstevel@tonic-gate * 640Sstevel@tonic-gate * On error, causes process to terminate with a signal. 650Sstevel@tonic-gate */ 660Sstevel@tonic-gate ulong_t 670Sstevel@tonic-gate aout_bndr(caddr_t pc) 680Sstevel@tonic-gate { 69*1618Srie Rt_map *lmp, *nlmp, *llmp; 700Sstevel@tonic-gate struct relocation_info *rp; 710Sstevel@tonic-gate struct nlist *sp; 72*1618Srie Sym *sym; 730Sstevel@tonic-gate char *name; 740Sstevel@tonic-gate int rndx, entry; 750Sstevel@tonic-gate ulong_t symval; 760Sstevel@tonic-gate Slookup sl; 770Sstevel@tonic-gate uint_t binfo; 78*1618Srie Lm_list *lml; 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* 810Sstevel@tonic-gate * For compatibility with libthread (TI_VERSION 1) we track the entry 820Sstevel@tonic-gate * value. A zero value indicates we have recursed into ld.so.1 to 830Sstevel@tonic-gate * further process a locking request (see comments in completion()). 840Sstevel@tonic-gate * Under this recursion we disable tsort and cleanup activities. 850Sstevel@tonic-gate */ 860Sstevel@tonic-gate entry = enter(); 870Sstevel@tonic-gate 880Sstevel@tonic-gate for (lmp = lml_main.lm_head; lmp; lmp = (Rt_map *)NEXT(lmp)) { 890Sstevel@tonic-gate if (FCT(lmp) == &aout_fct) { 900Sstevel@tonic-gate if (pc > (caddr_t)(LM2LP(lmp)->lp_plt) && 910Sstevel@tonic-gate pc < (caddr_t)((int)LM2LP(lmp)->lp_plt + 920Sstevel@tonic-gate AOUTDYN(lmp)->v2->ld_plt_sz)) { 930Sstevel@tonic-gate break; 940Sstevel@tonic-gate } 950Sstevel@tonic-gate } 960Sstevel@tonic-gate } 970Sstevel@tonic-gate 980Sstevel@tonic-gate #define LAST22BITS 0x3fffff 990Sstevel@tonic-gate 1000Sstevel@tonic-gate /* LINTED */ 1010Sstevel@tonic-gate rndx = *(int *)(pc + (sizeof (ulong_t *) * 2)) & LAST22BITS; 1020Sstevel@tonic-gate rp = &LM2LP(lmp)->lp_rp[rndx]; 1030Sstevel@tonic-gate sp = &LM2LP(lmp)->lp_symtab[rp->r_symbolnum]; 1040Sstevel@tonic-gate name = &LM2LP(lmp)->lp_symstr[sp->n_un.n_strx]; 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate /* 1070Sstevel@tonic-gate * Determine the last link-map of this list, this'll be the starting 1080Sstevel@tonic-gate * point for any tsort() processing. 1090Sstevel@tonic-gate */ 110*1618Srie lml = LIST(lmp); 111*1618Srie llmp = lml->lm_tail; 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* 1140Sstevel@tonic-gate * Find definition for symbol. 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate sl.sl_name = name; 1170Sstevel@tonic-gate sl.sl_cmap = lmp; 118*1618Srie sl.sl_imap = lml->lm_head; 1190Sstevel@tonic-gate sl.sl_hash = 0; 1200Sstevel@tonic-gate sl.sl_rsymndx = 0; 1210Sstevel@tonic-gate sl.sl_flags = LKUP_DEFT; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate if ((sym = aout_lookup_sym(&sl, &nlmp, &binfo)) == 0) { 124*1618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 1250Sstevel@tonic-gate demangle(name)); 126*1618Srie rtldexit(lml, 1); 1270Sstevel@tonic-gate } 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate symval = sym->st_value; 1300Sstevel@tonic-gate if (!(FLAGS(nlmp) & FLG_RT_FIXED) && 1310Sstevel@tonic-gate (sym->st_shndx != SHN_ABS)) 1320Sstevel@tonic-gate symval += (int)(ADDR(nlmp)); 1330Sstevel@tonic-gate if ((lmp != nlmp) && ((FLAGS1(nlmp) & FL1_RT_NOINIFIN) == 0)) { 1340Sstevel@tonic-gate /* 1350Sstevel@tonic-gate * Record that this new link map is now bound to the caller. 1360Sstevel@tonic-gate */ 1370Sstevel@tonic-gate if (bind_one(lmp, nlmp, BND_REFER) == 0) 138*1618Srie rtldexit(lml, 1); 1390Sstevel@tonic-gate } 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate * Print binding information and rebuild PLT entry. 1430Sstevel@tonic-gate */ 144*1618Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)(ADDR(lmp) + rp->r_address), 145*1618Srie (Off)rp->r_address, (Xword)(-1), PLT_T_NONE, nlmp, 146*1618Srie (Addr)symval, sym->st_value, name, binfo)); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate if (!(rtld_flags & RT_FL_NOBIND)) 1490Sstevel@tonic-gate aout_plt_write((caddr_t)(ADDR(lmp) + rp->r_address), symval); 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * Complete any processing for newly loaded objects. Note we don't 1530Sstevel@tonic-gate * know exactly where any new objects are loaded (we know the object 1540Sstevel@tonic-gate * that supplied the symbol, but others may have been loaded lazily as 1550Sstevel@tonic-gate * we searched for the symbol), so sorting starts from the last 1560Sstevel@tonic-gate * link-map know on entry to this routine. 1570Sstevel@tonic-gate */ 1580Sstevel@tonic-gate if (entry) 1590Sstevel@tonic-gate load_completion(llmp, lmp); 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate /* 1620Sstevel@tonic-gate * If the object we've bound to is in the process of being initialized 1630Sstevel@tonic-gate * by another thread, determine whether we should block. 1640Sstevel@tonic-gate */ 1650Sstevel@tonic-gate is_dep_ready(nlmp, lmp, DBG_WAIT_SYMBOL); 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate /* 1680Sstevel@tonic-gate * Make sure the object to which we've bound has had it's .init fired. 1690Sstevel@tonic-gate * Cleanup before return to user code. 1700Sstevel@tonic-gate */ 1710Sstevel@tonic-gate if (entry) { 1720Sstevel@tonic-gate is_dep_init(nlmp, lmp); 173*1618Srie leave(lml); 1740Sstevel@tonic-gate } 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate return (symval); 1770Sstevel@tonic-gate } 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate #define IS_PC_RELATIVE(X) (pc_rel_type[(X)] == 1) 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate static const uchar_t pc_rel_type[] = { 1830Sstevel@tonic-gate 0, /* RELOC_8 */ 1840Sstevel@tonic-gate 0, /* RELOC_16 */ 1850Sstevel@tonic-gate 0, /* RELOC_32 */ 1860Sstevel@tonic-gate 1, /* RELOC_DISP8 */ 1870Sstevel@tonic-gate 1, /* RELOC_DISP16 */ 1880Sstevel@tonic-gate 1, /* RELOC_DISP32 */ 1890Sstevel@tonic-gate 1, /* RELOC_WDISP30 */ 1900Sstevel@tonic-gate 1, /* RELOC_WDISP22 */ 1910Sstevel@tonic-gate 0, /* RELOC_HI22 */ 1920Sstevel@tonic-gate 0, /* RELOC_22 */ 1930Sstevel@tonic-gate 0, /* RELOC_13 */ 1940Sstevel@tonic-gate 0, /* RELOC_LO10 */ 1950Sstevel@tonic-gate 0, /* RELOC_SFA_BASE */ 1960Sstevel@tonic-gate 0, /* RELOC_SFA_OFF13 */ 1970Sstevel@tonic-gate 0, /* RELOC_BASE10 */ 1980Sstevel@tonic-gate 0, /* RELOC_BASE13 */ 1990Sstevel@tonic-gate 0, /* RELOC_BASE22 */ 2000Sstevel@tonic-gate 0, /* RELOC_PC10 */ 2010Sstevel@tonic-gate 0, /* RELOC_PC22 */ 2020Sstevel@tonic-gate 0, /* RELOC_JMP_TBL */ 2030Sstevel@tonic-gate 0, /* RELOC_SEGOFF16 */ 2040Sstevel@tonic-gate 0, /* RELOC_GLOB_DAT */ 2050Sstevel@tonic-gate 0, /* RELOC_JMP_SLOT */ 2060Sstevel@tonic-gate 0 /* RELOC_RELATIVE */ 2070Sstevel@tonic-gate }; 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate int 2100Sstevel@tonic-gate aout_reloc(Rt_map * lmp, uint_t plt) 2110Sstevel@tonic-gate { 2120Sstevel@tonic-gate int k; /* loop temporary */ 2130Sstevel@tonic-gate int nr; /* number of relocations */ 2140Sstevel@tonic-gate char *name; /* symbol being searched for */ 2150Sstevel@tonic-gate long *et; /* cached _etext of object */ 2160Sstevel@tonic-gate long value; /* relocation temporary */ 2170Sstevel@tonic-gate long *ra; /* cached relocation address */ 2180Sstevel@tonic-gate struct relocation_info *rp; /* current relocation */ 2190Sstevel@tonic-gate struct nlist *sp; /* symbol table of "symbol" */ 2200Sstevel@tonic-gate Rt_map * _lmp; /* lm which holds symbol definition */ 2210Sstevel@tonic-gate Sym * sym; /* symbol definition */ 2220Sstevel@tonic-gate int textrel = 0, ret = 1; 2230Sstevel@tonic-gate Alist *bound = 0; 224*1618Srie Lm_list *lml = LIST(lmp); 2250Sstevel@tonic-gate 226*1618Srie DBG_CALL(Dbg_reloc_run(lmp, SHT_RELA, plt, DBG_REL_START)); 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * If we've been called upon to promote an RTLD_LAZY object to an 2300Sstevel@tonic-gate * RTLD_NOW don't bother to do anything - a.out's are bound as if 2310Sstevel@tonic-gate * RTLD_NOW regardless. 2320Sstevel@tonic-gate */ 2330Sstevel@tonic-gate if (plt) 2340Sstevel@tonic-gate return (1); 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate rp = LM2LP(lmp)->lp_rp; 2370Sstevel@tonic-gate et = (long *)ETEXT(lmp); 2380Sstevel@tonic-gate nr = GETRELSZ(AOUTDYN(lmp)) / sizeof (struct relocation_info); 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate /* 2410Sstevel@tonic-gate * Initialize _PLT_, if any. 2420Sstevel@tonic-gate */ 2430Sstevel@tonic-gate if (AOUTDYN(lmp)->v2->ld_plt_sz) 2440Sstevel@tonic-gate aout_plt_write((caddr_t)LM2LP(lmp)->lp_plt->jb_inst, 2450Sstevel@tonic-gate (ulong_t)aout_rtbndr); 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate /* 2480Sstevel@tonic-gate * Loop through relocations. 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate for (k = 0; k < nr; k++, rp++) { 2510Sstevel@tonic-gate /* LINTED */ 2520Sstevel@tonic-gate ra = (long *)&((char *)ADDR(lmp))[rp->r_address]; 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate /* 2550Sstevel@tonic-gate * Check to see if we're relocating in the text segment 2560Sstevel@tonic-gate * and turn off the write protect if necessary. 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate if ((ra < et) && (textrel == 0)) { 2590Sstevel@tonic-gate if (aout_set_prot(lmp, PROT_WRITE) == 0) { 2600Sstevel@tonic-gate ret = 0; 2610Sstevel@tonic-gate break; 2620Sstevel@tonic-gate } 2630Sstevel@tonic-gate textrel = 1; 2640Sstevel@tonic-gate } 2650Sstevel@tonic-gate 2660Sstevel@tonic-gate /* 2670Sstevel@tonic-gate * Perform the relocation. 2680Sstevel@tonic-gate */ 2690Sstevel@tonic-gate if (rp->r_extern == 0) { 2700Sstevel@tonic-gate name = (char *)0; 2710Sstevel@tonic-gate value = ADDR(lmp); 2720Sstevel@tonic-gate } else { 2730Sstevel@tonic-gate Slookup sl; 2740Sstevel@tonic-gate uint_t binfo; 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate if (rp->r_type == RELOC_JMP_SLOT) 2770Sstevel@tonic-gate continue; 2780Sstevel@tonic-gate sp = &LM2LP(lmp)->lp_symtab[rp->r_symbolnum]; 2790Sstevel@tonic-gate name = &LM2LP(lmp)->lp_symstr[sp->n_un.n_strx]; 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate /* 2820Sstevel@tonic-gate * Locate symbol. 2830Sstevel@tonic-gate */ 2840Sstevel@tonic-gate sl.sl_name = name; 2850Sstevel@tonic-gate sl.sl_cmap = lmp; 2860Sstevel@tonic-gate sl.sl_imap = 0; 2870Sstevel@tonic-gate sl.sl_hash = 0; 2880Sstevel@tonic-gate sl.sl_rsymndx = 0; 2890Sstevel@tonic-gate sl.sl_flags = (LKUP_DEFT | LKUP_ALLCNTLIST); 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate if ((sym = aout_lookup_sym(&sl, &_lmp, &binfo)) == 0) { 292*1618Srie if (lml->lm_flags & LML_FLG_TRC_WARN) { 2930Sstevel@tonic-gate (void) 2940Sstevel@tonic-gate printf(MSG_INTL(MSG_LDD_SYM_NFOUND), 2950Sstevel@tonic-gate demangle(name), NAME(lmp)); 2960Sstevel@tonic-gate continue; 2970Sstevel@tonic-gate } else { 298*1618Srie eprintf(lml, ERR_FATAL, 2990Sstevel@tonic-gate MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 3000Sstevel@tonic-gate demangle(name)); 3010Sstevel@tonic-gate ret = 0; 3020Sstevel@tonic-gate break; 3030Sstevel@tonic-gate } 3040Sstevel@tonic-gate } 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate /* 3070Sstevel@tonic-gate * If symbol was found in an object other than the 3080Sstevel@tonic-gate * referencing object then record the binding. 3090Sstevel@tonic-gate */ 3100Sstevel@tonic-gate if ((lmp != _lmp) && 3110Sstevel@tonic-gate ((FLAGS1(_lmp) & FL1_RT_NOINIFIN) == 0)) { 3120Sstevel@tonic-gate if (alist_test(&bound, _lmp, sizeof (Rt_map *), 3130Sstevel@tonic-gate AL_CNT_RELBIND) == 0) { 3140Sstevel@tonic-gate ret = 0; 3150Sstevel@tonic-gate break; 3160Sstevel@tonic-gate } 3170Sstevel@tonic-gate } 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate value = sym->st_value + rp->r_addend; 3200Sstevel@tonic-gate if (!(FLAGS(_lmp) & FLG_RT_FIXED) && 3210Sstevel@tonic-gate (sym->st_shndx != SHN_COMMON) && 3220Sstevel@tonic-gate (sym->st_shndx != SHN_ABS)) 3230Sstevel@tonic-gate value += ADDR(_lmp); 3240Sstevel@tonic-gate 3250Sstevel@tonic-gate if (IS_PC_RELATIVE(rp->r_type)) 3260Sstevel@tonic-gate value -= (long)ADDR(lmp); 3270Sstevel@tonic-gate 328*1618Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)ra, 329*1618Srie (Off)(ra - ADDR(lmp)), (Xword)(-1), PLT_T_NONE, 330*1618Srie _lmp, (Addr)value, sym->st_value, name, binfo)); 3310Sstevel@tonic-gate } 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate /* 3340Sstevel@tonic-gate * Perform a specific relocation operation. 3350Sstevel@tonic-gate */ 3360Sstevel@tonic-gate switch (rp->r_type) { 3370Sstevel@tonic-gate case RELOC_RELATIVE: 3380Sstevel@tonic-gate value += *ra << (32-22); 3390Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3400Sstevel@tonic-gate ((value >> (32 - 22)) & S_MASK(22)); 3410Sstevel@tonic-gate ra++; 3420Sstevel@tonic-gate value += (*ra & S_MASK(10)); 3430Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(10)) | 3440Sstevel@tonic-gate (value & S_MASK(10)); 3450Sstevel@tonic-gate break; 3460Sstevel@tonic-gate case RELOC_8: 3470Sstevel@tonic-gate case RELOC_DISP8: 3480Sstevel@tonic-gate value += *ra & S_MASK(8); 3490Sstevel@tonic-gate if (!S_INRANGE(value, 8)) 350*1618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_OVERFLOW), 3510Sstevel@tonic-gate NAME(lmp), (name ? demangle(name) : 3520Sstevel@tonic-gate MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 8, 3530Sstevel@tonic-gate (uint_t)ra); 3540Sstevel@tonic-gate *ra = value; 3550Sstevel@tonic-gate break; 3560Sstevel@tonic-gate case RELOC_LO10: 3570Sstevel@tonic-gate case RELOC_BASE10: 3580Sstevel@tonic-gate value += *ra & S_MASK(10); 3590Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(10)) | 3600Sstevel@tonic-gate (value & S_MASK(10)); 3610Sstevel@tonic-gate break; 3620Sstevel@tonic-gate case RELOC_BASE13: 3630Sstevel@tonic-gate case RELOC_13: 3640Sstevel@tonic-gate value += *ra & S_MASK(13); 3650Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(13)) | 3660Sstevel@tonic-gate (value & S_MASK(13)); 3670Sstevel@tonic-gate break; 3680Sstevel@tonic-gate case RELOC_16: 3690Sstevel@tonic-gate case RELOC_DISP16: 3700Sstevel@tonic-gate value += *ra & S_MASK(16); 3710Sstevel@tonic-gate if (!S_INRANGE(value, 16)) 372*1618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_OVERFLOW), 3730Sstevel@tonic-gate NAME(lmp), (name ? demangle(name) : 3740Sstevel@tonic-gate MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 16, 3750Sstevel@tonic-gate (uint_t)ra); 3760Sstevel@tonic-gate *(short *)ra = value; 3770Sstevel@tonic-gate break; 3780Sstevel@tonic-gate case RELOC_22: 3790Sstevel@tonic-gate case RELOC_BASE22: 3800Sstevel@tonic-gate value += *ra & S_MASK(22); 3810Sstevel@tonic-gate if (!S_INRANGE(value, 22)) 382*1618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_OVERFLOW), 3830Sstevel@tonic-gate NAME(lmp), (name ? demangle(name) : 3840Sstevel@tonic-gate MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 22, 3850Sstevel@tonic-gate (uint_t)ra); 3860Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3870Sstevel@tonic-gate (value & S_MASK(22)); 3880Sstevel@tonic-gate break; 3890Sstevel@tonic-gate case RELOC_HI22: 3900Sstevel@tonic-gate value += (*ra & S_MASK(22)) << (32 - 22); 3910Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3920Sstevel@tonic-gate ((value >> (32 - 22)) & S_MASK(22)); 3930Sstevel@tonic-gate break; 3940Sstevel@tonic-gate case RELOC_WDISP22: 3950Sstevel@tonic-gate value += *ra & S_MASK(22); 3960Sstevel@tonic-gate value >>= 2; 3970Sstevel@tonic-gate if (!S_INRANGE(value, 22)) 398*1618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_OVERFLOW), 3990Sstevel@tonic-gate NAME(lmp), (name ? demangle(name) : 4000Sstevel@tonic-gate MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 22, 4010Sstevel@tonic-gate (uint_t)ra); 4020Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 4030Sstevel@tonic-gate (value & S_MASK(22)); 4040Sstevel@tonic-gate break; 4050Sstevel@tonic-gate case RELOC_WDISP30: 4060Sstevel@tonic-gate value += *ra & S_MASK(30); 4070Sstevel@tonic-gate value >>= 2; 4080Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(30)) | 4090Sstevel@tonic-gate (value & S_MASK(30)); 4100Sstevel@tonic-gate break; 4110Sstevel@tonic-gate case RELOC_32: 4120Sstevel@tonic-gate case RELOC_GLOB_DAT: 4130Sstevel@tonic-gate case RELOC_DISP32: 4140Sstevel@tonic-gate value += *ra; 4150Sstevel@tonic-gate *(long *)ra = value; 4160Sstevel@tonic-gate break; 4170Sstevel@tonic-gate default: 418*1618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_UNIMPL), 419*1618Srie NAME(lmp), (name ? demangle(name) : 420*1618Srie MSG_INTL(MSG_STR_UNKNOWN)), rp->r_type); 4210Sstevel@tonic-gate ret = 0; 4220Sstevel@tonic-gate break; 4230Sstevel@tonic-gate } 4240Sstevel@tonic-gate 4250Sstevel@tonic-gate /* 4260Sstevel@tonic-gate * If this relocation is against a text segment we must make 4270Sstevel@tonic-gate * sure that the instruction cache is flushed. 4280Sstevel@tonic-gate */ 4290Sstevel@tonic-gate if (textrel) { 4300Sstevel@tonic-gate if (rp->r_type == RELOC_RELATIVE) 4310Sstevel@tonic-gate iflush_range((caddr_t)(ra - 1), 0x8); 4320Sstevel@tonic-gate else 4330Sstevel@tonic-gate iflush_range((caddr_t)ra, 0x4); 4340Sstevel@tonic-gate } 4350Sstevel@tonic-gate } 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate return (relocate_finish(lmp, bound, textrel, ret)); 4380Sstevel@tonic-gate } 439