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 /* 231618Srie * Copyright (c) 1988 AT&T 241618Srie * All Rights Reserved 251618Srie * 265892Sab196087 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 271618Srie * 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> 431618Srie #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 { 691618Srie Rt_map *lmp, *nlmp, *llmp; 700Sstevel@tonic-gate struct relocation_info *rp; 710Sstevel@tonic-gate struct nlist *sp; 721618Srie 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; 781618Srie 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 */ 86*6515Sraf entry = enter(0); 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 */ 1101618Srie lml = LIST(lmp); 1111618Srie llmp = lml->lm_tail; 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* 1145950Srie * Find definition for symbol. Initialize the symbol lookup data 1155950Srie * structure. 1160Sstevel@tonic-gate */ 1175950Srie SLOOKUP_INIT(sl, name, lmp, lml->lm_head, ld_entry_cnt, 0, 0, 0, 0, 1185950Srie LKUP_DEFT); 1190Sstevel@tonic-gate 1206387Srie if ((sym = aout_lookup_sym(&sl, &nlmp, &binfo, NULL)) == 0) { 1211618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 1220Sstevel@tonic-gate demangle(name)); 1231618Srie rtldexit(lml, 1); 1240Sstevel@tonic-gate } 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate symval = sym->st_value; 1270Sstevel@tonic-gate if (!(FLAGS(nlmp) & FLG_RT_FIXED) && 1280Sstevel@tonic-gate (sym->st_shndx != SHN_ABS)) 1290Sstevel@tonic-gate symval += (int)(ADDR(nlmp)); 1300Sstevel@tonic-gate if ((lmp != nlmp) && ((FLAGS1(nlmp) & FL1_RT_NOINIFIN) == 0)) { 1310Sstevel@tonic-gate /* 1320Sstevel@tonic-gate * Record that this new link map is now bound to the caller. 1330Sstevel@tonic-gate */ 1340Sstevel@tonic-gate if (bind_one(lmp, nlmp, BND_REFER) == 0) 1351618Srie rtldexit(lml, 1); 1360Sstevel@tonic-gate } 1370Sstevel@tonic-gate 1380Sstevel@tonic-gate /* 1390Sstevel@tonic-gate * Print binding information and rebuild PLT entry. 1400Sstevel@tonic-gate */ 1411618Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)(ADDR(lmp) + rp->r_address), 1421618Srie (Off)rp->r_address, (Xword)(-1), PLT_T_NONE, nlmp, 1431618Srie (Addr)symval, sym->st_value, name, binfo)); 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate if (!(rtld_flags & RT_FL_NOBIND)) 1460Sstevel@tonic-gate aout_plt_write((caddr_t)(ADDR(lmp) + rp->r_address), symval); 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate /* 1490Sstevel@tonic-gate * Complete any processing for newly loaded objects. Note we don't 1500Sstevel@tonic-gate * know exactly where any new objects are loaded (we know the object 1510Sstevel@tonic-gate * that supplied the symbol, but others may have been loaded lazily as 1520Sstevel@tonic-gate * we searched for the symbol), so sorting starts from the last 1530Sstevel@tonic-gate * link-map know on entry to this routine. 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate if (entry) 1564679Srie load_completion(llmp); 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate /* 1590Sstevel@tonic-gate * If the object we've bound to is in the process of being initialized 1600Sstevel@tonic-gate * by another thread, determine whether we should block. 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate is_dep_ready(nlmp, lmp, DBG_WAIT_SYMBOL); 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * Make sure the object to which we've bound has had it's .init fired. 1660Sstevel@tonic-gate * Cleanup before return to user code. 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate if (entry) { 1690Sstevel@tonic-gate is_dep_init(nlmp, lmp); 170*6515Sraf leave(lml, 0); 1710Sstevel@tonic-gate } 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate return (symval); 1740Sstevel@tonic-gate } 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate #define IS_PC_RELATIVE(X) (pc_rel_type[(X)] == 1) 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate static const uchar_t pc_rel_type[] = { 1800Sstevel@tonic-gate 0, /* RELOC_8 */ 1810Sstevel@tonic-gate 0, /* RELOC_16 */ 1820Sstevel@tonic-gate 0, /* RELOC_32 */ 1830Sstevel@tonic-gate 1, /* RELOC_DISP8 */ 1840Sstevel@tonic-gate 1, /* RELOC_DISP16 */ 1850Sstevel@tonic-gate 1, /* RELOC_DISP32 */ 1860Sstevel@tonic-gate 1, /* RELOC_WDISP30 */ 1870Sstevel@tonic-gate 1, /* RELOC_WDISP22 */ 1880Sstevel@tonic-gate 0, /* RELOC_HI22 */ 1890Sstevel@tonic-gate 0, /* RELOC_22 */ 1900Sstevel@tonic-gate 0, /* RELOC_13 */ 1910Sstevel@tonic-gate 0, /* RELOC_LO10 */ 1920Sstevel@tonic-gate 0, /* RELOC_SFA_BASE */ 1930Sstevel@tonic-gate 0, /* RELOC_SFA_OFF13 */ 1940Sstevel@tonic-gate 0, /* RELOC_BASE10 */ 1950Sstevel@tonic-gate 0, /* RELOC_BASE13 */ 1960Sstevel@tonic-gate 0, /* RELOC_BASE22 */ 1970Sstevel@tonic-gate 0, /* RELOC_PC10 */ 1980Sstevel@tonic-gate 0, /* RELOC_PC22 */ 1990Sstevel@tonic-gate 0, /* RELOC_JMP_TBL */ 2000Sstevel@tonic-gate 0, /* RELOC_SEGOFF16 */ 2010Sstevel@tonic-gate 0, /* RELOC_GLOB_DAT */ 2020Sstevel@tonic-gate 0, /* RELOC_JMP_SLOT */ 2030Sstevel@tonic-gate 0 /* RELOC_RELATIVE */ 2040Sstevel@tonic-gate }; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate int 2076387Srie aout_reloc(Rt_map * lmp, uint_t plt, int *in_nfavl) 2080Sstevel@tonic-gate { 2090Sstevel@tonic-gate int k; /* loop temporary */ 2100Sstevel@tonic-gate int nr; /* number of relocations */ 2110Sstevel@tonic-gate char *name; /* symbol being searched for */ 2120Sstevel@tonic-gate long *et; /* cached _etext of object */ 2130Sstevel@tonic-gate long value; /* relocation temporary */ 2140Sstevel@tonic-gate long *ra; /* cached relocation address */ 2150Sstevel@tonic-gate struct relocation_info *rp; /* current relocation */ 2160Sstevel@tonic-gate struct nlist *sp; /* symbol table of "symbol" */ 2170Sstevel@tonic-gate Rt_map * _lmp; /* lm which holds symbol definition */ 2180Sstevel@tonic-gate Sym * sym; /* symbol definition */ 2190Sstevel@tonic-gate int textrel = 0, ret = 1; 2205892Sab196087 APlist *bound = NULL; 2211618Srie Lm_list *lml = LIST(lmp); 2220Sstevel@tonic-gate 2231618Srie DBG_CALL(Dbg_reloc_run(lmp, SHT_RELA, plt, DBG_REL_START)); 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate /* 2260Sstevel@tonic-gate * If we've been called upon to promote an RTLD_LAZY object to an 2270Sstevel@tonic-gate * RTLD_NOW don't bother to do anything - a.out's are bound as if 2280Sstevel@tonic-gate * RTLD_NOW regardless. 2290Sstevel@tonic-gate */ 2300Sstevel@tonic-gate if (plt) 2310Sstevel@tonic-gate return (1); 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate rp = LM2LP(lmp)->lp_rp; 2340Sstevel@tonic-gate et = (long *)ETEXT(lmp); 2350Sstevel@tonic-gate nr = GETRELSZ(AOUTDYN(lmp)) / sizeof (struct relocation_info); 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * Initialize _PLT_, if any. 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate if (AOUTDYN(lmp)->v2->ld_plt_sz) 2410Sstevel@tonic-gate aout_plt_write((caddr_t)LM2LP(lmp)->lp_plt->jb_inst, 2420Sstevel@tonic-gate (ulong_t)aout_rtbndr); 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate /* 2450Sstevel@tonic-gate * Loop through relocations. 2460Sstevel@tonic-gate */ 2470Sstevel@tonic-gate for (k = 0; k < nr; k++, rp++) { 2480Sstevel@tonic-gate /* LINTED */ 2490Sstevel@tonic-gate ra = (long *)&((char *)ADDR(lmp))[rp->r_address]; 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate /* 2520Sstevel@tonic-gate * Check to see if we're relocating in the text segment 2530Sstevel@tonic-gate * and turn off the write protect if necessary. 2540Sstevel@tonic-gate */ 2550Sstevel@tonic-gate if ((ra < et) && (textrel == 0)) { 2560Sstevel@tonic-gate if (aout_set_prot(lmp, PROT_WRITE) == 0) { 2570Sstevel@tonic-gate ret = 0; 2580Sstevel@tonic-gate break; 2590Sstevel@tonic-gate } 2600Sstevel@tonic-gate textrel = 1; 2610Sstevel@tonic-gate } 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* 2640Sstevel@tonic-gate * Perform the relocation. 2650Sstevel@tonic-gate */ 2660Sstevel@tonic-gate if (rp->r_extern == 0) { 2670Sstevel@tonic-gate name = (char *)0; 2680Sstevel@tonic-gate value = ADDR(lmp); 2690Sstevel@tonic-gate } else { 2700Sstevel@tonic-gate Slookup sl; 2710Sstevel@tonic-gate uint_t binfo; 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate if (rp->r_type == RELOC_JMP_SLOT) 2740Sstevel@tonic-gate continue; 2750Sstevel@tonic-gate sp = &LM2LP(lmp)->lp_symtab[rp->r_symbolnum]; 2760Sstevel@tonic-gate name = &LM2LP(lmp)->lp_symstr[sp->n_un.n_strx]; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate /* 2795950Srie * Locate symbol. Initialize the symbol lookup data 2805950Srie * structure. 2810Sstevel@tonic-gate */ 2825950Srie SLOOKUP_INIT(sl, name, lmp, 0, ld_entry_cnt, 0, 0, 0, 0, 2835950Srie LKUP_STDRELOC); 2840Sstevel@tonic-gate 2856387Srie if ((sym = aout_lookup_sym(&sl, &_lmp, 2866387Srie &binfo, in_nfavl)) == 0) { 2871618Srie if (lml->lm_flags & LML_FLG_TRC_WARN) { 2880Sstevel@tonic-gate (void) 2890Sstevel@tonic-gate printf(MSG_INTL(MSG_LDD_SYM_NFOUND), 2900Sstevel@tonic-gate demangle(name), NAME(lmp)); 2910Sstevel@tonic-gate continue; 2920Sstevel@tonic-gate } else { 2931618Srie eprintf(lml, ERR_FATAL, 2940Sstevel@tonic-gate MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 2950Sstevel@tonic-gate demangle(name)); 2960Sstevel@tonic-gate ret = 0; 2970Sstevel@tonic-gate break; 2980Sstevel@tonic-gate } 2990Sstevel@tonic-gate } 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate /* 3020Sstevel@tonic-gate * If symbol was found in an object other than the 3030Sstevel@tonic-gate * referencing object then record the binding. 3040Sstevel@tonic-gate */ 3050Sstevel@tonic-gate if ((lmp != _lmp) && 3060Sstevel@tonic-gate ((FLAGS1(_lmp) & FL1_RT_NOINIFIN) == 0)) { 3075892Sab196087 if (aplist_test(&bound, _lmp, 3080Sstevel@tonic-gate AL_CNT_RELBIND) == 0) { 3090Sstevel@tonic-gate ret = 0; 3100Sstevel@tonic-gate break; 3110Sstevel@tonic-gate } 3120Sstevel@tonic-gate } 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate value = sym->st_value + rp->r_addend; 3150Sstevel@tonic-gate if (!(FLAGS(_lmp) & FLG_RT_FIXED) && 3160Sstevel@tonic-gate (sym->st_shndx != SHN_COMMON) && 3170Sstevel@tonic-gate (sym->st_shndx != SHN_ABS)) 3180Sstevel@tonic-gate value += ADDR(_lmp); 3190Sstevel@tonic-gate 3200Sstevel@tonic-gate if (IS_PC_RELATIVE(rp->r_type)) 3210Sstevel@tonic-gate value -= (long)ADDR(lmp); 3220Sstevel@tonic-gate 3231618Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)ra, 3241618Srie (Off)(ra - ADDR(lmp)), (Xword)(-1), PLT_T_NONE, 3251618Srie _lmp, (Addr)value, sym->st_value, name, binfo)); 3260Sstevel@tonic-gate } 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate /* 3290Sstevel@tonic-gate * Perform a specific relocation operation. 3300Sstevel@tonic-gate */ 3310Sstevel@tonic-gate switch (rp->r_type) { 3320Sstevel@tonic-gate case RELOC_RELATIVE: 3330Sstevel@tonic-gate value += *ra << (32-22); 3340Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3354679Srie ((value >> (32 - 22)) & S_MASK(22)); 3360Sstevel@tonic-gate ra++; 3370Sstevel@tonic-gate value += (*ra & S_MASK(10)); 3380Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(10)) | 3394679Srie (value & S_MASK(10)); 3400Sstevel@tonic-gate break; 3410Sstevel@tonic-gate case RELOC_8: 3420Sstevel@tonic-gate case RELOC_DISP8: 3430Sstevel@tonic-gate value += *ra & S_MASK(8); 3444679Srie if (!S_INRANGE(value, 8)) { 3454679Srie eprintf(lml, ERR_FATAL, 3464679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 3474679Srie (name ? demangle(name) : 3484679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 8, 3494679Srie (uint_t)ra); 3504679Srie } 3510Sstevel@tonic-gate *ra = value; 3520Sstevel@tonic-gate break; 3530Sstevel@tonic-gate case RELOC_LO10: 3540Sstevel@tonic-gate case RELOC_BASE10: 3550Sstevel@tonic-gate value += *ra & S_MASK(10); 3560Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(10)) | 3574679Srie (value & S_MASK(10)); 3580Sstevel@tonic-gate break; 3590Sstevel@tonic-gate case RELOC_BASE13: 3600Sstevel@tonic-gate case RELOC_13: 3610Sstevel@tonic-gate value += *ra & S_MASK(13); 3620Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(13)) | 3634679Srie (value & S_MASK(13)); 3640Sstevel@tonic-gate break; 3650Sstevel@tonic-gate case RELOC_16: 3660Sstevel@tonic-gate case RELOC_DISP16: 3670Sstevel@tonic-gate value += *ra & S_MASK(16); 3684679Srie if (!S_INRANGE(value, 16)) { 3694679Srie eprintf(lml, ERR_FATAL, 3704679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 3714679Srie (name ? demangle(name) : 3724679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 16, 3734679Srie (uint_t)ra); 3744679Srie } 3750Sstevel@tonic-gate *(short *)ra = value; 3760Sstevel@tonic-gate break; 3770Sstevel@tonic-gate case RELOC_22: 3780Sstevel@tonic-gate case RELOC_BASE22: 3790Sstevel@tonic-gate value += *ra & S_MASK(22); 3804679Srie if (!S_INRANGE(value, 22)) { 3814679Srie eprintf(lml, ERR_FATAL, 3824679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 3834679Srie (name ? demangle(name) : 3844679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 22, 3854679Srie (uint_t)ra); 3864679Srie } 3870Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3884679Srie (value & S_MASK(22)); 3890Sstevel@tonic-gate break; 3900Sstevel@tonic-gate case RELOC_HI22: 3910Sstevel@tonic-gate value += (*ra & S_MASK(22)) << (32 - 22); 3920Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 3934679Srie ((value >> (32 - 22)) & S_MASK(22)); 3940Sstevel@tonic-gate break; 3950Sstevel@tonic-gate case RELOC_WDISP22: 3960Sstevel@tonic-gate value += *ra & S_MASK(22); 3970Sstevel@tonic-gate value >>= 2; 3984679Srie if (!S_INRANGE(value, 22)) { 3994679Srie eprintf(lml, ERR_FATAL, 4004679Srie MSG_INTL(MSG_REL_OVERFLOW), NAME(lmp), 4014679Srie (name ? demangle(name) : 4024679Srie MSG_INTL(MSG_STR_UNKNOWN)), (int)value, 22, 4034679Srie (uint_t)ra); 4044679Srie } 4050Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(22)) | 4064679Srie (value & S_MASK(22)); 4070Sstevel@tonic-gate break; 4080Sstevel@tonic-gate case RELOC_WDISP30: 4090Sstevel@tonic-gate value += *ra & S_MASK(30); 4100Sstevel@tonic-gate value >>= 2; 4110Sstevel@tonic-gate *(long *)ra = (*(long *)ra & ~S_MASK(30)) | 4124679Srie (value & S_MASK(30)); 4130Sstevel@tonic-gate break; 4140Sstevel@tonic-gate case RELOC_32: 4150Sstevel@tonic-gate case RELOC_GLOB_DAT: 4160Sstevel@tonic-gate case RELOC_DISP32: 4170Sstevel@tonic-gate value += *ra; 4180Sstevel@tonic-gate *(long *)ra = value; 4190Sstevel@tonic-gate break; 4200Sstevel@tonic-gate default: 4211618Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_UNIMPL), 4221618Srie NAME(lmp), (name ? demangle(name) : 4231618Srie MSG_INTL(MSG_STR_UNKNOWN)), rp->r_type); 4240Sstevel@tonic-gate ret = 0; 4250Sstevel@tonic-gate break; 4260Sstevel@tonic-gate } 4270Sstevel@tonic-gate 4280Sstevel@tonic-gate /* 4290Sstevel@tonic-gate * If this relocation is against a text segment we must make 4300Sstevel@tonic-gate * sure that the instruction cache is flushed. 4310Sstevel@tonic-gate */ 4320Sstevel@tonic-gate if (textrel) { 4330Sstevel@tonic-gate if (rp->r_type == RELOC_RELATIVE) 4340Sstevel@tonic-gate iflush_range((caddr_t)(ra - 1), 0x8); 4350Sstevel@tonic-gate else 4360Sstevel@tonic-gate iflush_range((caddr_t)ra, 0x4); 4370Sstevel@tonic-gate } 4380Sstevel@tonic-gate } 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate return (relocate_finish(lmp, bound, textrel, ret)); 4410Sstevel@tonic-gate } 442