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 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * 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 */ 211618Srie 220Sstevel@tonic-gate /* 236812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 246812Sraf * Use is subject to license terms. 256812Sraf */ 266812Sraf 276812Sraf /* 281618Srie * Copyright (c) 1988 AT&T 291618Srie * All Rights Reserved 300Sstevel@tonic-gate */ 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 370Sstevel@tonic-gate #include <stdio.h> 380Sstevel@tonic-gate #include <sys/types.h> 390Sstevel@tonic-gate #include <sys/mman.h> 400Sstevel@tonic-gate #include <synch.h> 410Sstevel@tonic-gate #include <dlfcn.h> 421618Srie #include <debug.h> 430Sstevel@tonic-gate #include "_a.out.h" 440Sstevel@tonic-gate #include "_rtld.h" 450Sstevel@tonic-gate #include "_audit.h" 460Sstevel@tonic-gate #include "msg.h" 470Sstevel@tonic-gate 480Sstevel@tonic-gate extern void iflush_range(caddr_t, size_t); 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * Function binding routine - invoked on the first call to a function through 520Sstevel@tonic-gate * the procedure linkage table; 530Sstevel@tonic-gate * passes first through an assembly language interface. 540Sstevel@tonic-gate * 550Sstevel@tonic-gate * Takes the address of the PLT entry where the call originated, 560Sstevel@tonic-gate * the offset into the relocation table of the associated 570Sstevel@tonic-gate * relocation entry and the address of the link map (rt_private_map struct) 580Sstevel@tonic-gate * for the entry. 590Sstevel@tonic-gate * 600Sstevel@tonic-gate * Returns the address of the function referenced after re-writing the PLT 610Sstevel@tonic-gate * entry to invoke the function directly. 620Sstevel@tonic-gate * 630Sstevel@tonic-gate * On error, causes process to terminate with a signal. 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate ulong_t 660Sstevel@tonic-gate aout_bndr(caddr_t pc) 670Sstevel@tonic-gate { 681618Srie Rt_map *lmp, *nlmp, *llmp; 690Sstevel@tonic-gate struct relocation_info *rp; 700Sstevel@tonic-gate struct nlist *sp; 711618Srie Sym *sym; 720Sstevel@tonic-gate char *name; 730Sstevel@tonic-gate int rndx, entry; 740Sstevel@tonic-gate ulong_t symval; 750Sstevel@tonic-gate Slookup sl; 760Sstevel@tonic-gate uint_t binfo; 771618Srie Lm_list *lml; 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 800Sstevel@tonic-gate * For compatibility with libthread (TI_VERSION 1) we track the entry 810Sstevel@tonic-gate * value. A zero value indicates we have recursed into ld.so.1 to 820Sstevel@tonic-gate * further process a locking request (see comments in completion()). 830Sstevel@tonic-gate * Under this recursion we disable tsort and cleanup activities. 840Sstevel@tonic-gate */ 856515Sraf entry = enter(0); 860Sstevel@tonic-gate 87*8394SAli.Bahrami@Sun.COM for (lmp = lml_main.lm_head; lmp; lmp = NEXT_RT_MAP(lmp)) { 880Sstevel@tonic-gate if (FCT(lmp) == &aout_fct) { 890Sstevel@tonic-gate if (pc > (caddr_t)(LM2LP(lmp)->lp_plt) && 900Sstevel@tonic-gate pc < (caddr_t)((int)LM2LP(lmp)->lp_plt + 910Sstevel@tonic-gate AOUTDYN(lmp)->v2->ld_plt_sz)) { 920Sstevel@tonic-gate break; 930Sstevel@tonic-gate } 940Sstevel@tonic-gate } 950Sstevel@tonic-gate } 960Sstevel@tonic-gate 970Sstevel@tonic-gate #define LAST22BITS 0x3fffff 980Sstevel@tonic-gate 990Sstevel@tonic-gate /* LINTED */ 1000Sstevel@tonic-gate rndx = *(int *)(pc + (sizeof (ulong_t *) * 2)) & LAST22BITS; 1010Sstevel@tonic-gate rp = &LM2LP(lmp)->lp_rp[rndx]; 1020Sstevel@tonic-gate sp = &LM2LP(lmp)->lp_symtab[rp->r_symbolnum]; 1030Sstevel@tonic-gate name = &LM2LP(lmp)->lp_symstr[sp->n_un.n_strx]; 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * Determine the last link-map of this list, this'll be the starting 1070Sstevel@tonic-gate * point for any tsort() processing. 1080Sstevel@tonic-gate */ 1091618Srie lml = LIST(lmp); 1101618Srie llmp = lml->lm_tail; 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate /* 1135950Srie * Find definition for symbol. Initialize the symbol lookup data 1145950Srie * structure. 1150Sstevel@tonic-gate */ 1165950Srie SLOOKUP_INIT(sl, name, lmp, lml->lm_head, ld_entry_cnt, 0, 0, 0, 0, 1175950Srie LKUP_DEFT); 1180Sstevel@tonic-gate 1196387Srie if ((sym = aout_lookup_sym(&sl, &nlmp, &binfo, NULL)) == 0) { 1201618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 1210Sstevel@tonic-gate demangle(name)); 1221618Srie rtldexit(lml, 1); 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate symval = sym->st_value; 1260Sstevel@tonic-gate if (!(FLAGS(nlmp) & FLG_RT_FIXED) && 1270Sstevel@tonic-gate (sym->st_shndx != SHN_ABS)) 1280Sstevel@tonic-gate symval += (int)(ADDR(nlmp)); 1290Sstevel@tonic-gate if ((lmp != nlmp) && ((FLAGS1(nlmp) & FL1_RT_NOINIFIN) == 0)) { 1300Sstevel@tonic-gate /* 1310Sstevel@tonic-gate * Record that this new link map is now bound to the caller. 1320Sstevel@tonic-gate */ 1330Sstevel@tonic-gate if (bind_one(lmp, nlmp, BND_REFER) == 0) 1341618Srie rtldexit(lml, 1); 1350Sstevel@tonic-gate } 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* 1380Sstevel@tonic-gate * Print binding information and rebuild PLT entry. 1390Sstevel@tonic-gate */ 1401618Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)(ADDR(lmp) + rp->r_address), 1411618Srie (Off)rp->r_address, (Xword)(-1), PLT_T_NONE, nlmp, 1421618Srie (Addr)symval, sym->st_value, name, binfo)); 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate if (!(rtld_flags & RT_FL_NOBIND)) 1450Sstevel@tonic-gate aout_plt_write((caddr_t)(ADDR(lmp) + rp->r_address), symval); 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* 1480Sstevel@tonic-gate * Complete any processing for newly loaded objects. Note we don't 1490Sstevel@tonic-gate * know exactly where any new objects are loaded (we know the object 1500Sstevel@tonic-gate * that supplied the symbol, but others may have been loaded lazily as 1510Sstevel@tonic-gate * we searched for the symbol), so sorting starts from the last 1520Sstevel@tonic-gate * link-map know on entry to this routine. 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate if (entry) 1554679Srie load_completion(llmp); 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* 1580Sstevel@tonic-gate * If the object we've bound to is in the process of being initialized 1590Sstevel@tonic-gate * by another thread, determine whether we should block. 1600Sstevel@tonic-gate */ 1610Sstevel@tonic-gate is_dep_ready(nlmp, lmp, DBG_WAIT_SYMBOL); 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* 1640Sstevel@tonic-gate * Make sure the object to which we've bound has had it's .init fired. 1650Sstevel@tonic-gate * Cleanup before return to user code. 1660Sstevel@tonic-gate */ 1670Sstevel@tonic-gate if (entry) { 1680Sstevel@tonic-gate is_dep_init(nlmp, lmp); 1696515Sraf leave(lml, 0); 1700Sstevel@tonic-gate } 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate return (symval); 1730Sstevel@tonic-gate } 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate #define IS_PC_RELATIVE(X) (pc_rel_type[(X)] == 1) 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate static const uchar_t pc_rel_type[] = { 1790Sstevel@tonic-gate 0, /* RELOC_8 */ 1800Sstevel@tonic-gate 0, /* RELOC_16 */ 1810Sstevel@tonic-gate 0, /* RELOC_32 */ 1820Sstevel@tonic-gate 1, /* RELOC_DISP8 */ 1830Sstevel@tonic-gate 1, /* RELOC_DISP16 */ 1840Sstevel@tonic-gate 1, /* RELOC_DISP32 */ 1850Sstevel@tonic-gate 1, /* RELOC_WDISP30 */ 1860Sstevel@tonic-gate 1, /* RELOC_WDISP22 */ 1870Sstevel@tonic-gate 0, /* RELOC_HI22 */ 1880Sstevel@tonic-gate 0, /* RELOC_22 */ 1890Sstevel@tonic-gate 0, /* RELOC_13 */ 1900Sstevel@tonic-gate 0, /* RELOC_LO10 */ 1910Sstevel@tonic-gate 0, /* RELOC_SFA_BASE */ 1920Sstevel@tonic-gate 0, /* RELOC_SFA_OFF13 */ 1930Sstevel@tonic-gate 0, /* RELOC_BASE10 */ 1940Sstevel@tonic-gate 0, /* RELOC_BASE13 */ 1950Sstevel@tonic-gate 0, /* RELOC_BASE22 */ 1960Sstevel@tonic-gate 0, /* RELOC_PC10 */ 1970Sstevel@tonic-gate 0, /* RELOC_PC22 */ 1980Sstevel@tonic-gate 0, /* RELOC_JMP_TBL */ 1990Sstevel@tonic-gate 0, /* RELOC_SEGOFF16 */ 2000Sstevel@tonic-gate 0, /* RELOC_GLOB_DAT */ 2010Sstevel@tonic-gate 0, /* RELOC_JMP_SLOT */ 2020Sstevel@tonic-gate 0 /* RELOC_RELATIVE */ 2030Sstevel@tonic-gate }; 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate int 2066387Srie aout_reloc(Rt_map * lmp, uint_t plt, int *in_nfavl) 2070Sstevel@tonic-gate { 2080Sstevel@tonic-gate int k; /* loop temporary */ 2090Sstevel@tonic-gate int nr; /* number of relocations */ 2100Sstevel@tonic-gate char *name; /* symbol being searched for */ 2110Sstevel@tonic-gate long *et; /* cached _etext of object */ 2120Sstevel@tonic-gate long value; /* relocation temporary */ 2130Sstevel@tonic-gate long *ra; /* cached relocation address */ 2140Sstevel@tonic-gate struct relocation_info *rp; /* current relocation */ 2150Sstevel@tonic-gate struct nlist *sp; /* symbol table of "symbol" */ 2160Sstevel@tonic-gate Rt_map * _lmp; /* lm which holds symbol definition */ 2170Sstevel@tonic-gate Sym * sym; /* symbol definition */ 2180Sstevel@tonic-gate int textrel = 0, ret = 1; 2195892Sab196087 APlist *bound = NULL; 2201618Srie Lm_list *lml = LIST(lmp); 2210Sstevel@tonic-gate 2221618Srie DBG_CALL(Dbg_reloc_run(lmp, SHT_RELA, plt, DBG_REL_START)); 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * If we've been called upon to promote an RTLD_LAZY object to an 2260Sstevel@tonic-gate * RTLD_NOW don't bother to do anything - a.out's are bound as if 2270Sstevel@tonic-gate * RTLD_NOW regardless. 2280Sstevel@tonic-gate */ 2290Sstevel@tonic-gate if (plt) 2300Sstevel@tonic-gate return (1); 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate rp = LM2LP(lmp)->lp_rp; 2330Sstevel@tonic-gate et = (long *)ETEXT(lmp); 2340Sstevel@tonic-gate nr = GETRELSZ(AOUTDYN(lmp)) / sizeof (struct relocation_info); 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate /* 2370Sstevel@tonic-gate * Initialize _PLT_, if any. 2380Sstevel@tonic-gate */ 2390Sstevel@tonic-gate if (AOUTDYN(lmp)->v2->ld_plt_sz) 2400Sstevel@tonic-gate aout_plt_write((caddr_t)LM2LP(lmp)->lp_plt->jb_inst, 2410Sstevel@tonic-gate (ulong_t)aout_rtbndr); 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate /* 2440Sstevel@tonic-gate * Loop through relocations. 2450Sstevel@tonic-gate */ 2460Sstevel@tonic-gate for (k = 0; k < nr; k++, rp++) { 2470Sstevel@tonic-gate /* LINTED */ 2480Sstevel@tonic-gate ra = (long *)&((char *)ADDR(lmp))[rp->r_address]; 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate /* 2510Sstevel@tonic-gate * Check to see if we're relocating in the text segment 2520Sstevel@tonic-gate * and turn off the write protect if necessary. 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate if ((ra < et) && (textrel == 0)) { 2550Sstevel@tonic-gate if (aout_set_prot(lmp, PROT_WRITE) == 0) { 2560Sstevel@tonic-gate ret = 0; 2570Sstevel@tonic-gate break; 2580Sstevel@tonic-gate } 2590Sstevel@tonic-gate textrel = 1; 2600Sstevel@tonic-gate } 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate /* 2630Sstevel@tonic-gate * Perform the relocation. 2640Sstevel@tonic-gate */ 2650Sstevel@tonic-gate if (rp->r_extern == 0) { 2660Sstevel@tonic-gate name = (char *)0; 2670Sstevel@tonic-gate value = ADDR(lmp); 2680Sstevel@tonic-gate } else { 2690Sstevel@tonic-gate Slookup sl; 2700Sstevel@tonic-gate uint_t binfo; 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate if (rp->r_type == RELOC_JMP_SLOT) 2730Sstevel@tonic-gate continue; 2740Sstevel@tonic-gate sp = &LM2LP(lmp)->lp_symtab[rp->r_symbolnum]; 2750Sstevel@tonic-gate name = &LM2LP(lmp)->lp_symstr[sp->n_un.n_strx]; 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate /* 2785950Srie * Locate symbol. Initialize the symbol lookup data 2795950Srie * structure. 2800Sstevel@tonic-gate */ 2815950Srie SLOOKUP_INIT(sl, name, lmp, 0, ld_entry_cnt, 0, 0, 0, 0, 2825950Srie LKUP_STDRELOC); 2830Sstevel@tonic-gate 2846387Srie if ((sym = aout_lookup_sym(&sl, &_lmp, 2856387Srie &binfo, in_nfavl)) == 0) { 2861618Srie if (lml->lm_flags & LML_FLG_TRC_WARN) { 2870Sstevel@tonic-gate (void) 2880Sstevel@tonic-gate printf(MSG_INTL(MSG_LDD_SYM_NFOUND), 2890Sstevel@tonic-gate demangle(name), NAME(lmp)); 2900Sstevel@tonic-gate continue; 2910Sstevel@tonic-gate } else { 2921618Srie eprintf(lml, ERR_FATAL, 2930Sstevel@tonic-gate MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 2940Sstevel@tonic-gate demangle(name)); 2950Sstevel@tonic-gate ret = 0; 2960Sstevel@tonic-gate break; 2970Sstevel@tonic-gate } 2980Sstevel@tonic-gate } 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate /* 3010Sstevel@tonic-gate * If symbol was found in an object other than the 3020Sstevel@tonic-gate * referencing object then record the binding. 3030Sstevel@tonic-gate */ 3040Sstevel@tonic-gate if ((lmp != _lmp) && 3050Sstevel@tonic-gate ((FLAGS1(_lmp) & FL1_RT_NOINIFIN) == 0)) { 3065892Sab196087 if (aplist_test(&bound, _lmp, 3070Sstevel@tonic-gate AL_CNT_RELBIND) == 0) { 3080Sstevel@tonic-gate ret = 0; 3090Sstevel@tonic-gate break; 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate } 3120Sstevel@tonic-gate 3130Sstevel@tonic-gate value = sym->st_value + rp->r_addend; 3140Sstevel@tonic-gate if (!(FLAGS(_lmp) & FLG_RT_FIXED) && 3150Sstevel@tonic-gate (sym->st_shndx != SHN_COMMON) && 3160Sstevel@tonic-gate (sym->st_shndx != SHN_ABS)) 3170Sstevel@tonic-gate value += ADDR(_lmp); 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate if (IS_PC_RELATIVE(rp->r_type)) 3200Sstevel@tonic-gate value -= (long)ADDR(lmp); 3210Sstevel@tonic-gate 3221618Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)ra, 3231618Srie (Off)(ra - ADDR(lmp)), (Xword)(-1), PLT_T_NONE, 3241618Srie _lmp, (Addr)value, sym->st_value, name, binfo)); 3250Sstevel@tonic-gate } 3260Sstevel@tonic-gate 3270Sstevel@tonic-gate /* 3280Sstevel@tonic-gate * Perform a specific relocation operation. 3290Sstevel@tonic-gate */ 3300Sstevel@tonic-gate switch (rp->r_type) { 3310Sstevel@tonic-gate case RELOC_RELATIVE: 3320Sstevel@tonic-gate value += *ra << (32-22); 3330Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3344679Srie ((value >> (32 - 22)) & S_MASK(22)); 3350Sstevel@tonic-gate ra++; 3360Sstevel@tonic-gate value += (*ra & S_MASK(10)); 3370Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(10)) | 3384679Srie (value & S_MASK(10)); 3390Sstevel@tonic-gate break; 3400Sstevel@tonic-gate case RELOC_8: 3410Sstevel@tonic-gate case RELOC_DISP8: 3420Sstevel@tonic-gate value += *ra & S_MASK(8); 3434679Srie if (!S_INRANGE(value, 8)) { 3444679Srie eprintf(lml, ERR_FATAL, 3454679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 3464679Srie (name ? demangle(name) : 3474679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 8, 3484679Srie (uint_t)ra); 3494679Srie } 3500Sstevel@tonic-gate *ra = value; 3510Sstevel@tonic-gate break; 3520Sstevel@tonic-gate case RELOC_LO10: 3530Sstevel@tonic-gate case RELOC_BASE10: 3540Sstevel@tonic-gate value += *ra & S_MASK(10); 3550Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(10)) | 3564679Srie (value & S_MASK(10)); 3570Sstevel@tonic-gate break; 3580Sstevel@tonic-gate case RELOC_BASE13: 3590Sstevel@tonic-gate case RELOC_13: 3600Sstevel@tonic-gate value += *ra & S_MASK(13); 3610Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(13)) | 3624679Srie (value & S_MASK(13)); 3630Sstevel@tonic-gate break; 3640Sstevel@tonic-gate case RELOC_16: 3650Sstevel@tonic-gate case RELOC_DISP16: 3660Sstevel@tonic-gate value += *ra & S_MASK(16); 3674679Srie if (!S_INRANGE(value, 16)) { 3684679Srie eprintf(lml, ERR_FATAL, 3694679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 3704679Srie (name ? demangle(name) : 3714679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 16, 3724679Srie (uint_t)ra); 3734679Srie } 3740Sstevel@tonic-gate *(short *)ra = value; 3750Sstevel@tonic-gate break; 3760Sstevel@tonic-gate case RELOC_22: 3770Sstevel@tonic-gate case RELOC_BASE22: 3780Sstevel@tonic-gate value += *ra & S_MASK(22); 3794679Srie if (!S_INRANGE(value, 22)) { 3804679Srie eprintf(lml, ERR_FATAL, 3814679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 3824679Srie (name ? demangle(name) : 3834679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 22, 3844679Srie (uint_t)ra); 3854679Srie } 3860Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3874679Srie (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)) | 3924679Srie ((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; 3974679Srie if (!S_INRANGE(value, 22)) { 3984679Srie eprintf(lml, ERR_FATAL, 3994679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 4004679Srie (name ? demangle(name) : 4014679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 22, 4024679Srie (uint_t)ra); 4034679Srie } 4040Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 4054679Srie (value & S_MASK(22)); 4060Sstevel@tonic-gate break; 4070Sstevel@tonic-gate case RELOC_WDISP30: 4080Sstevel@tonic-gate value += *ra & S_MASK(30); 4090Sstevel@tonic-gate value >>= 2; 4100Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(30)) | 4114679Srie (value & S_MASK(30)); 4120Sstevel@tonic-gate break; 4130Sstevel@tonic-gate case RELOC_32: 4140Sstevel@tonic-gate case RELOC_GLOB_DAT: 4150Sstevel@tonic-gate case RELOC_DISP32: 4160Sstevel@tonic-gate value += *ra; 4170Sstevel@tonic-gate *(long *)ra = value; 4180Sstevel@tonic-gate break; 4190Sstevel@tonic-gate default: 4201618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_UNIMPL), 4211618Srie NAME(lmp), (name ? demangle(name) : 4221618Srie MSG_INTL(MSG_STR_UNKNOWN)), rp->r_type); 4230Sstevel@tonic-gate ret = 0; 4240Sstevel@tonic-gate break; 4250Sstevel@tonic-gate } 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate /* 4280Sstevel@tonic-gate * If this relocation is against a text segment we must make 4290Sstevel@tonic-gate * sure that the instruction cache is flushed. 4300Sstevel@tonic-gate */ 4310Sstevel@tonic-gate if (textrel) { 4320Sstevel@tonic-gate if (rp->r_type == RELOC_RELATIVE) 4330Sstevel@tonic-gate iflush_range((caddr_t)(ra - 1), 0x8); 4340Sstevel@tonic-gate else 4350Sstevel@tonic-gate iflush_range((caddr_t)ra, 0x4); 4360Sstevel@tonic-gate } 4370Sstevel@tonic-gate } 4380Sstevel@tonic-gate 4390Sstevel@tonic-gate return (relocate_finish(lmp, bound, textrel, ret)); 4400Sstevel@tonic-gate } 441