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 /* 237257d1b4Sraf * Copyright (c) 1988 AT&T 247257d1b4Sraf * All Rights Reserved 25f441771bSRod Evans * 26f441771bSRod Evans * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. 27*38f4bdddSBryan Cantrill * Copyright (c) 2012, Joyent, Inc. All rights reserved. 287257d1b4Sraf */ 297257d1b4Sraf 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * x86 machine dependent and ELF file class dependent functions. 327c478bd9Sstevel@tonic-gate * Contains routines for performing function binding and symbol relocations. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <stdio.h> 367c478bd9Sstevel@tonic-gate #include <sys/elf.h> 377c478bd9Sstevel@tonic-gate #include <sys/elf_386.h> 387c478bd9Sstevel@tonic-gate #include <sys/mman.h> 397c478bd9Sstevel@tonic-gate #include <dlfcn.h> 407c478bd9Sstevel@tonic-gate #include <synch.h> 417c478bd9Sstevel@tonic-gate #include <string.h> 425aefb655Srie #include <debug.h> 435aefb655Srie #include <reloc.h> 445aefb655Srie #include <conv.h> 457c478bd9Sstevel@tonic-gate #include "_rtld.h" 467c478bd9Sstevel@tonic-gate #include "_audit.h" 477c478bd9Sstevel@tonic-gate #include "_elf.h" 48f441771bSRod Evans #include "_inline_gen.h" 49f441771bSRod Evans #include "_inline_reloc.h" 507c478bd9Sstevel@tonic-gate #include "msg.h" 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate extern void elf_rtbndr(Rt_map *, ulong_t, caddr_t); 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate int 557c478bd9Sstevel@tonic-gate elf_mach_flags_check(Rej_desc *rej, Ehdr *ehdr) 567c478bd9Sstevel@tonic-gate { 577c478bd9Sstevel@tonic-gate /* 587c478bd9Sstevel@tonic-gate * Check machine type and flags. 597c478bd9Sstevel@tonic-gate */ 607c478bd9Sstevel@tonic-gate if (ehdr->e_flags != 0) { 617c478bd9Sstevel@tonic-gate rej->rej_type = SGS_REJ_BADFLAG; 627c478bd9Sstevel@tonic-gate rej->rej_info = (uint_t)ehdr->e_flags; 637c478bd9Sstevel@tonic-gate return (0); 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate return (1); 667c478bd9Sstevel@tonic-gate } 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate void 697c478bd9Sstevel@tonic-gate ldso_plt_init(Rt_map *lmp) 707c478bd9Sstevel@tonic-gate { 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * There is no need to analyze ld.so because we don't map in any of 737c478bd9Sstevel@tonic-gate * its dependencies. However we may map these dependencies in later 747c478bd9Sstevel@tonic-gate * (as if ld.so had dlopened them), so initialize the plt and the 757c478bd9Sstevel@tonic-gate * permission information. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate if (PLTGOT(lmp)) 787c478bd9Sstevel@tonic-gate elf_plt_init((PLTGOT(lmp)), (caddr_t)lmp); 797c478bd9Sstevel@tonic-gate } 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate static const uchar_t dyn_plt_template[] = { 827c478bd9Sstevel@tonic-gate /* 0x00 */ 0x55, /* pushl %ebp */ 837c478bd9Sstevel@tonic-gate /* 0x01 */ 0x8b, 0xec, /* movl %esp, %ebp */ 847c478bd9Sstevel@tonic-gate /* 0x03 */ 0x68, 0x00, 0x00, 0x00, 0x00, /* pushl trace_fields */ 857c478bd9Sstevel@tonic-gate /* 0x08 */ 0xe9, 0xfc, 0xff, 0xff, 0xff, 0xff /* jmp elf_plt_trace */ 867c478bd9Sstevel@tonic-gate }; 877c478bd9Sstevel@tonic-gate int dyn_plt_ent_size = sizeof (dyn_plt_template); 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * the dynamic plt entry is: 917c478bd9Sstevel@tonic-gate * 927c478bd9Sstevel@tonic-gate * pushl %ebp 937c478bd9Sstevel@tonic-gate * movl %esp, %ebp 947c478bd9Sstevel@tonic-gate * pushl tfp 957c478bd9Sstevel@tonic-gate * jmp elf_plt_trace 967c478bd9Sstevel@tonic-gate * dyn_data: 977c478bd9Sstevel@tonic-gate * .align 4 987c478bd9Sstevel@tonic-gate * uintptr_t reflmp 997c478bd9Sstevel@tonic-gate * uintptr_t deflmp 1007c478bd9Sstevel@tonic-gate * uint_t symndx 1017c478bd9Sstevel@tonic-gate * uint_t sb_flags 1027c478bd9Sstevel@tonic-gate * Sym symdef 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate static caddr_t 1057c478bd9Sstevel@tonic-gate elf_plt_trace_write(uint_t roffset, Rt_map *rlmp, Rt_map *dlmp, Sym *sym, 1067c478bd9Sstevel@tonic-gate uint_t symndx, uint_t pltndx, caddr_t to, uint_t sb_flags, int *fail) 1077c478bd9Sstevel@tonic-gate { 1087c478bd9Sstevel@tonic-gate extern int elf_plt_trace(); 1097c478bd9Sstevel@tonic-gate ulong_t got_entry; 1107c478bd9Sstevel@tonic-gate uchar_t *dyn_plt; 1117c478bd9Sstevel@tonic-gate uintptr_t *dyndata; 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * We only need to add the glue code if there is an auditing 1157c478bd9Sstevel@tonic-gate * library that is interested in this binding. 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate dyn_plt = (uchar_t *)((uintptr_t)AUDINFO(rlmp)->ai_dynplts + 1187c478bd9Sstevel@tonic-gate (pltndx * dyn_plt_ent_size)); 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * Have we initialized this dynamic plt entry yet? If we haven't do it 1227c478bd9Sstevel@tonic-gate * now. Otherwise this function has been called before, but from a 1237c478bd9Sstevel@tonic-gate * different plt (ie. from another shared object). In that case 1247c478bd9Sstevel@tonic-gate * we just set the plt to point to the new dyn_plt. 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate if (*dyn_plt == 0) { 1277c478bd9Sstevel@tonic-gate Sym *symp; 1287c478bd9Sstevel@tonic-gate Word symvalue; 1295aefb655Srie Lm_list *lml = LIST(rlmp); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate (void) memcpy((void *)dyn_plt, dyn_plt_template, 1327c478bd9Sstevel@tonic-gate sizeof (dyn_plt_template)); 1337c478bd9Sstevel@tonic-gate dyndata = (uintptr_t *)((uintptr_t)dyn_plt + 1347c478bd9Sstevel@tonic-gate ROUND(sizeof (dyn_plt_template), M_WORD_ALIGN)); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate /* 1377c478bd9Sstevel@tonic-gate * relocate: 1387c478bd9Sstevel@tonic-gate * pushl dyn_data 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate symvalue = (Word)dyndata; 141f3324781Sab196087 if (do_reloc_rtld(R_386_32, &dyn_plt[4], &symvalue, 1427c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_SYM_LADYNDATA), 1435aefb655Srie MSG_ORIG(MSG_SPECFIL_DYNPLT), lml) == 0) { 1447c478bd9Sstevel@tonic-gate *fail = 1; 1457c478bd9Sstevel@tonic-gate return (0); 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate /* 1497c478bd9Sstevel@tonic-gate * jmps are relative, so I need to figure out the relative 1507c478bd9Sstevel@tonic-gate * address to elf_plt_trace. 1517c478bd9Sstevel@tonic-gate * 1527c478bd9Sstevel@tonic-gate * relocating: 1537c478bd9Sstevel@tonic-gate * jmp elf_plt_trace 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate symvalue = (ulong_t)(elf_plt_trace) - (ulong_t)(dyn_plt + 9); 156f3324781Sab196087 if (do_reloc_rtld(R_386_PC32, &dyn_plt[9], &symvalue, 1577c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_SYM_ELFPLTTRACE), 1585aefb655Srie MSG_ORIG(MSG_SPECFIL_DYNPLT), lml) == 0) { 1597c478bd9Sstevel@tonic-gate *fail = 1; 1607c478bd9Sstevel@tonic-gate return (0); 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate 1637c478bd9Sstevel@tonic-gate *dyndata++ = (uintptr_t)rlmp; 1647c478bd9Sstevel@tonic-gate *dyndata++ = (uintptr_t)dlmp; 1657c478bd9Sstevel@tonic-gate *dyndata++ = (uint_t)symndx; 1667c478bd9Sstevel@tonic-gate *dyndata++ = (uint_t)sb_flags; 1677c478bd9Sstevel@tonic-gate symp = (Sym *)dyndata; 1687c478bd9Sstevel@tonic-gate *symp = *sym; 1697c478bd9Sstevel@tonic-gate symp->st_name += (Word)STRTAB(dlmp); 1707c478bd9Sstevel@tonic-gate symp->st_value = (Addr)to; 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate got_entry = (ulong_t)roffset; 1747c478bd9Sstevel@tonic-gate *(ulong_t *)got_entry = (ulong_t)dyn_plt; 1757c478bd9Sstevel@tonic-gate return ((caddr_t)dyn_plt); 1767c478bd9Sstevel@tonic-gate } 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate /* 1797c478bd9Sstevel@tonic-gate * Function binding routine - invoked on the first call to a function through 1807c478bd9Sstevel@tonic-gate * the procedure linkage table; 1817c478bd9Sstevel@tonic-gate * passes first through an assembly language interface. 1827c478bd9Sstevel@tonic-gate * 1837c478bd9Sstevel@tonic-gate * Takes the offset into the relocation table of the associated 1847c478bd9Sstevel@tonic-gate * relocation entry and the address of the link map (rt_private_map struct) 1857c478bd9Sstevel@tonic-gate * for the entry. 1867c478bd9Sstevel@tonic-gate * 1877c478bd9Sstevel@tonic-gate * Returns the address of the function referenced after re-writing the PLT 1887c478bd9Sstevel@tonic-gate * entry to invoke the function directly. 1897c478bd9Sstevel@tonic-gate * 1907c478bd9Sstevel@tonic-gate * On error, causes process to terminate with a signal. 1917c478bd9Sstevel@tonic-gate */ 1927c478bd9Sstevel@tonic-gate ulong_t 1937c478bd9Sstevel@tonic-gate elf_bndr(Rt_map *lmp, ulong_t reloff, caddr_t from) 1947c478bd9Sstevel@tonic-gate { 1957c478bd9Sstevel@tonic-gate Rt_map *nlmp, *llmp; 1967c478bd9Sstevel@tonic-gate ulong_t addr, symval, rsymndx; 1977c478bd9Sstevel@tonic-gate char *name; 1987c478bd9Sstevel@tonic-gate Rel *rptr; 19960758829Srie Sym *rsym, *nsym; 2005aefb655Srie uint_t binfo, sb_flags = 0, dbg_class; 2017c478bd9Sstevel@tonic-gate Slookup sl; 20208278a5eSRod Evans Sresult sr; 2035aefb655Srie int entry, lmflags; 2045aefb655Srie Lm_list *lml; 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate /* 2077c478bd9Sstevel@tonic-gate * For compatibility with libthread (TI_VERSION 1) we track the entry 2087c478bd9Sstevel@tonic-gate * value. A zero value indicates we have recursed into ld.so.1 to 2097c478bd9Sstevel@tonic-gate * further process a locking request. Under this recursion we disable 2107c478bd9Sstevel@tonic-gate * tsort and cleanup activities. 2117c478bd9Sstevel@tonic-gate */ 2128cd45542Sraf entry = enter(0); 2137c478bd9Sstevel@tonic-gate 2145aefb655Srie lml = LIST(lmp); 2155aefb655Srie if ((lmflags = lml->lm_flags) & LML_FLG_RTLDLM) { 2165aefb655Srie dbg_class = dbg_desc->d_class; 2175aefb655Srie dbg_desc->d_class = 0; 2187c478bd9Sstevel@tonic-gate } 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate /* 2217c478bd9Sstevel@tonic-gate * Perform some basic sanity checks. If we didn't get a load map or 2227c478bd9Sstevel@tonic-gate * the relocation offset is invalid then its possible someone has walked 2237c478bd9Sstevel@tonic-gate * over the .got entries or jumped to plt0 out of the blue. 2247c478bd9Sstevel@tonic-gate */ 2257c478bd9Sstevel@tonic-gate if (!lmp || ((reloff % sizeof (Rel)) != 0)) { 226de777a60Sab196087 Conv_inv_buf_t inv_buf; 227de777a60Sab196087 2285aefb655Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_PLTREF), 229de777a60Sab196087 conv_reloc_386_type(R_386_JMP_SLOT, 0, &inv_buf), 2305aefb655Srie EC_NATPTR(lmp), EC_XWORD(reloff), EC_NATPTR(from)); 2315aefb655Srie rtldexit(lml, 1); 2327c478bd9Sstevel@tonic-gate } 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate /* 2357c478bd9Sstevel@tonic-gate * Use relocation entry to get symbol table entry and symbol name. 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate addr = (ulong_t)JMPREL(lmp); 2387c478bd9Sstevel@tonic-gate rptr = (Rel *)(addr + reloff); 2397c478bd9Sstevel@tonic-gate rsymndx = ELF_R_SYM(rptr->r_info); 24060758829Srie rsym = (Sym *)((ulong_t)SYMTAB(lmp) + (rsymndx * SYMENT(lmp))); 24160758829Srie name = (char *)(STRTAB(lmp) + rsym->st_name); 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate /* 2447c478bd9Sstevel@tonic-gate * Determine the last link-map of this list, this'll be the starting 2457c478bd9Sstevel@tonic-gate * point for any tsort() processing. 2467c478bd9Sstevel@tonic-gate */ 2475aefb655Srie llmp = lml->lm_tail; 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate /* 25008278a5eSRod Evans * Find definition for symbol. Initialize the symbol lookup, and 25108278a5eSRod Evans * symbol result, data structures. 2527c478bd9Sstevel@tonic-gate */ 25375e7992aSrie SLOOKUP_INIT(sl, name, lmp, lml->lm_head, ld_entry_cnt, 0, 25475e7992aSrie rsymndx, rsym, 0, LKUP_DEFT); 25508278a5eSRod Evans SRESULT_INIT(sr, name); 2567c478bd9Sstevel@tonic-gate 25708278a5eSRod Evans if (lookup_sym(&sl, &sr, &binfo, NULL) == 0) { 2585aefb655Srie eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_NOSYM), NAME(lmp), 2597c478bd9Sstevel@tonic-gate demangle(name)); 2605aefb655Srie rtldexit(lml, 1); 2617c478bd9Sstevel@tonic-gate } 2627c478bd9Sstevel@tonic-gate 26308278a5eSRod Evans name = (char *)sr.sr_name; 26408278a5eSRod Evans nlmp = sr.sr_dmap; 26508278a5eSRod Evans nsym = sr.sr_sym; 26608278a5eSRod Evans 2677c478bd9Sstevel@tonic-gate symval = nsym->st_value; 26808278a5eSRod Evans 2697c478bd9Sstevel@tonic-gate if (!(FLAGS(nlmp) & FLG_RT_FIXED) && 2707c478bd9Sstevel@tonic-gate (nsym->st_shndx != SHN_ABS)) 2717c478bd9Sstevel@tonic-gate symval += ADDR(nlmp); 2727c478bd9Sstevel@tonic-gate if ((lmp != nlmp) && ((FLAGS1(nlmp) & FL1_RT_NOINIFIN) == 0)) { 2737c478bd9Sstevel@tonic-gate /* 2747c478bd9Sstevel@tonic-gate * Record that this new link map is now bound to the caller. 2757c478bd9Sstevel@tonic-gate */ 2767c478bd9Sstevel@tonic-gate if (bind_one(lmp, nlmp, BND_REFER) == 0) 2775aefb655Srie rtldexit(lml, 1); 2787c478bd9Sstevel@tonic-gate } 2797c478bd9Sstevel@tonic-gate 280*38f4bdddSBryan Cantrill if ((lml->lm_tflags | AFLAGS(lmp) | AFLAGS(nlmp)) & 281*38f4bdddSBryan Cantrill LML_TFLG_AUD_SYMBIND) { 2827c478bd9Sstevel@tonic-gate uint_t symndx = (((uintptr_t)nsym - 2837c478bd9Sstevel@tonic-gate (uintptr_t)SYMTAB(nlmp)) / SYMENT(nlmp)); 2847c478bd9Sstevel@tonic-gate symval = audit_symbind(lmp, nlmp, nsym, symndx, symval, 2857c478bd9Sstevel@tonic-gate &sb_flags); 2867c478bd9Sstevel@tonic-gate } 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate if (!(rtld_flags & RT_FL_NOBIND)) { 2897c478bd9Sstevel@tonic-gate addr = rptr->r_offset; 2907c478bd9Sstevel@tonic-gate if (!(FLAGS(lmp) & FLG_RT_FIXED)) 2917c478bd9Sstevel@tonic-gate addr += ADDR(lmp); 29256deab07SRod Evans if (((lml->lm_tflags | AFLAGS(lmp)) & 2937c478bd9Sstevel@tonic-gate (LML_TFLG_AUD_PLTENTER | LML_TFLG_AUD_PLTEXIT)) && 2947c478bd9Sstevel@tonic-gate AUDINFO(lmp)->ai_dynplts) { 2957c478bd9Sstevel@tonic-gate int fail = 0; 2967c478bd9Sstevel@tonic-gate uint_t pltndx = reloff / sizeof (Rel); 2977c478bd9Sstevel@tonic-gate uint_t symndx = (((uintptr_t)nsym - 2987247f888Srie (uintptr_t)SYMTAB(nlmp)) / SYMENT(nlmp)); 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate symval = (ulong_t)elf_plt_trace_write(addr, lmp, nlmp, 3017c478bd9Sstevel@tonic-gate nsym, symndx, pltndx, (caddr_t)symval, sb_flags, 3027c478bd9Sstevel@tonic-gate &fail); 3037c478bd9Sstevel@tonic-gate if (fail) 3045aefb655Srie rtldexit(lml, 1); 3057c478bd9Sstevel@tonic-gate } else { 3067c478bd9Sstevel@tonic-gate /* 3077c478bd9Sstevel@tonic-gate * Write standard PLT entry to jump directly 3087c478bd9Sstevel@tonic-gate * to newly bound function. 3097c478bd9Sstevel@tonic-gate */ 3107c478bd9Sstevel@tonic-gate *(ulong_t *)addr = symval; 3117c478bd9Sstevel@tonic-gate } 3127c478bd9Sstevel@tonic-gate } 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate /* 3157c478bd9Sstevel@tonic-gate * Print binding information and rebuild PLT entry. 3167c478bd9Sstevel@tonic-gate */ 3175aefb655Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)from, (Off)(from - ADDR(lmp)), 3185aefb655Srie (Xword)(reloff / sizeof (Rel)), PLT_T_FULL, nlmp, (Addr)symval, 3195aefb655Srie nsym->st_value, name, binfo)); 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate /* 3227c478bd9Sstevel@tonic-gate * Complete any processing for newly loaded objects. Note we don't 3237c478bd9Sstevel@tonic-gate * know exactly where any new objects are loaded (we know the object 3247c478bd9Sstevel@tonic-gate * that supplied the symbol, but others may have been loaded lazily as 3257c478bd9Sstevel@tonic-gate * we searched for the symbol), so sorting starts from the last 3267c478bd9Sstevel@tonic-gate * link-map know on entry to this routine. 3277c478bd9Sstevel@tonic-gate */ 3287c478bd9Sstevel@tonic-gate if (entry) 3297247f888Srie load_completion(llmp); 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate /* 3327c478bd9Sstevel@tonic-gate * Some operations like dldump() or dlopen()'ing a relocatable object 3337c478bd9Sstevel@tonic-gate * result in objects being loaded on rtld's link-map, make sure these 3347c478bd9Sstevel@tonic-gate * objects are initialized also. 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate if ((LIST(nlmp)->lm_flags & LML_FLG_RTLDLM) && LIST(nlmp)->lm_init) 3377247f888Srie load_completion(nlmp); 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate /* 3407c478bd9Sstevel@tonic-gate * Make sure the object to which we've bound has had it's .init fired. 3417c478bd9Sstevel@tonic-gate * Cleanup before return to user code. 3427c478bd9Sstevel@tonic-gate */ 3437c478bd9Sstevel@tonic-gate if (entry) { 3447c478bd9Sstevel@tonic-gate is_dep_init(nlmp, lmp); 3458cd45542Sraf leave(lml, 0); 3467c478bd9Sstevel@tonic-gate } 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate if (lmflags & LML_FLG_RTLDLM) 3495aefb655Srie dbg_desc->d_class = dbg_class; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate return (symval); 3527c478bd9Sstevel@tonic-gate } 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate /* 3557c478bd9Sstevel@tonic-gate * Read and process the relocations for one link object, we assume all 3567c478bd9Sstevel@tonic-gate * relocation sections for loadable segments are stored contiguously in 3577c478bd9Sstevel@tonic-gate * the file. 3587c478bd9Sstevel@tonic-gate */ 3597c478bd9Sstevel@tonic-gate int 36056deab07SRod Evans elf_reloc(Rt_map *lmp, uint_t plt, int *in_nfavl, APlist **textrel) 3617c478bd9Sstevel@tonic-gate { 36256deab07SRod Evans ulong_t relbgn, relend, relsiz, basebgn, pltbgn, pltend; 36356deab07SRod Evans ulong_t _pltbgn, _pltend; 36456deab07SRod Evans ulong_t dsymndx, roffset, rsymndx, psymndx = 0; 3657c478bd9Sstevel@tonic-gate uchar_t rtype; 3667c478bd9Sstevel@tonic-gate long value, pvalue; 3677c478bd9Sstevel@tonic-gate Sym *symref, *psymref, *symdef, *psymdef; 368f441771bSRod Evans Syminfo *sip; 3697c478bd9Sstevel@tonic-gate char *name, *pname; 3707c478bd9Sstevel@tonic-gate Rt_map *_lmp, *plmp; 37156deab07SRod Evans int ret = 1, noplt = 0; 3727c478bd9Sstevel@tonic-gate int relacount = RELACOUNT(lmp), plthint = 0; 3737c478bd9Sstevel@tonic-gate Rel *rel; 3747c478bd9Sstevel@tonic-gate uint_t binfo, pbinfo; 375cce0e03bSab196087 APlist *bound = NULL; 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate /* 3787c478bd9Sstevel@tonic-gate * Although only necessary for lazy binding, initialize the first 3797c478bd9Sstevel@tonic-gate * global offset entry to go to elf_rtbndr(). dbx(1) seems 3807c478bd9Sstevel@tonic-gate * to find this useful. 3817c478bd9Sstevel@tonic-gate */ 3827c478bd9Sstevel@tonic-gate if ((plt == 0) && PLTGOT(lmp)) { 38356deab07SRod Evans mmapobj_result_t *mpp; 38456deab07SRod Evans 38556deab07SRod Evans /* 38656deab07SRod Evans * Make sure the segment is writable. 38756deab07SRod Evans */ 38856deab07SRod Evans if ((((mpp = 38956deab07SRod Evans find_segment((caddr_t)PLTGOT(lmp), lmp)) != NULL) && 39056deab07SRod Evans ((mpp->mr_prot & PROT_WRITE) == 0)) && 39156deab07SRod Evans ((set_prot(lmp, mpp, 1) == 0) || 39256deab07SRod Evans (aplist_append(textrel, mpp, AL_CNT_TEXTREL) == NULL))) 3937c478bd9Sstevel@tonic-gate return (0); 39456deab07SRod Evans 3957c478bd9Sstevel@tonic-gate elf_plt_init(PLTGOT(lmp), (caddr_t)lmp); 3967c478bd9Sstevel@tonic-gate } 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate /* 3997c478bd9Sstevel@tonic-gate * Initialize the plt start and end addresses. 4007c478bd9Sstevel@tonic-gate */ 4017c478bd9Sstevel@tonic-gate if ((pltbgn = (ulong_t)JMPREL(lmp)) != 0) 4027c478bd9Sstevel@tonic-gate pltend = pltbgn + (ulong_t)(PLTRELSZ(lmp)); 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate relsiz = (ulong_t)(RELENT(lmp)); 4057c478bd9Sstevel@tonic-gate basebgn = ADDR(lmp); 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate if (PLTRELSZ(lmp)) 4087c478bd9Sstevel@tonic-gate plthint = PLTRELSZ(lmp) / relsiz; 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate /* 4117c478bd9Sstevel@tonic-gate * If we've been called upon to promote an RTLD_LAZY object to an 4127c478bd9Sstevel@tonic-gate * RTLD_NOW then we're only interested in scaning the .plt table. 4137c478bd9Sstevel@tonic-gate * An uninitialized .plt is the case where the associated got entry 4147c478bd9Sstevel@tonic-gate * points back to the plt itself. Determine the range of the real .plt 4157c478bd9Sstevel@tonic-gate * entries using the _PROCEDURE_LINKAGE_TABLE_ symbol. 4167c478bd9Sstevel@tonic-gate */ 4177c478bd9Sstevel@tonic-gate if (plt) { 4187c478bd9Sstevel@tonic-gate Slookup sl; 41908278a5eSRod Evans Sresult sr; 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate relbgn = pltbgn; 4227c478bd9Sstevel@tonic-gate relend = pltend; 4237c478bd9Sstevel@tonic-gate if (!relbgn || (relbgn == relend)) 4247c478bd9Sstevel@tonic-gate return (1); 4257c478bd9Sstevel@tonic-gate 42675e7992aSrie /* 42708278a5eSRod Evans * Initialize the symbol lookup, and symbol result, data 42808278a5eSRod Evans * structures. 42975e7992aSrie */ 43075e7992aSrie SLOOKUP_INIT(sl, MSG_ORIG(MSG_SYM_PLT), lmp, lmp, ld_entry_cnt, 43175e7992aSrie elf_hash(MSG_ORIG(MSG_SYM_PLT)), 0, 0, 0, LKUP_DEFT); 43208278a5eSRod Evans SRESULT_INIT(sr, MSG_ORIG(MSG_SYM_PLT)); 4337c478bd9Sstevel@tonic-gate 43408278a5eSRod Evans if (elf_find_sym(&sl, &sr, &binfo, NULL) == 0) 4357c478bd9Sstevel@tonic-gate return (1); 4367c478bd9Sstevel@tonic-gate 43708278a5eSRod Evans symdef = sr.sr_sym; 4387c478bd9Sstevel@tonic-gate _pltbgn = symdef->st_value; 4397c478bd9Sstevel@tonic-gate if (!(FLAGS(lmp) & FLG_RT_FIXED) && 4407c478bd9Sstevel@tonic-gate (symdef->st_shndx != SHN_ABS)) 4417c478bd9Sstevel@tonic-gate _pltbgn += basebgn; 4427c478bd9Sstevel@tonic-gate _pltend = _pltbgn + (((PLTRELSZ(lmp) / relsiz)) * 4437c478bd9Sstevel@tonic-gate M_PLT_ENTSIZE) + M_PLT_RESERVSZ; 4447c478bd9Sstevel@tonic-gate 4457c478bd9Sstevel@tonic-gate } else { 4467c478bd9Sstevel@tonic-gate /* 4477c478bd9Sstevel@tonic-gate * The relocation sections appear to the run-time linker as a 4487c478bd9Sstevel@tonic-gate * single table. Determine the address of the beginning and end 4497c478bd9Sstevel@tonic-gate * of this table. There are two different interpretations of 4507c478bd9Sstevel@tonic-gate * the ABI at this point: 4517c478bd9Sstevel@tonic-gate * 4527c478bd9Sstevel@tonic-gate * o The REL table and its associated RELSZ indicate the 4537c478bd9Sstevel@tonic-gate * concatenation of *all* relocation sections (this is the 4547c478bd9Sstevel@tonic-gate * model our link-editor constructs). 4557c478bd9Sstevel@tonic-gate * 4567c478bd9Sstevel@tonic-gate * o The REL table and its associated RELSZ indicate the 4577c478bd9Sstevel@tonic-gate * concatenation of all *but* the .plt relocations. These 4587c478bd9Sstevel@tonic-gate * relocations are specified individually by the JMPREL and 4597c478bd9Sstevel@tonic-gate * PLTRELSZ entries. 4607c478bd9Sstevel@tonic-gate * 4617c478bd9Sstevel@tonic-gate * Determine from our knowledege of the relocation range and 4627c478bd9Sstevel@tonic-gate * .plt range, the range of the total relocation table. Note 4637c478bd9Sstevel@tonic-gate * that one other ABI assumption seems to be that the .plt 4647c478bd9Sstevel@tonic-gate * relocations always follow any other relocations, the 4657c478bd9Sstevel@tonic-gate * following range checking drops that assumption. 4667c478bd9Sstevel@tonic-gate */ 4677c478bd9Sstevel@tonic-gate relbgn = (ulong_t)(REL(lmp)); 4687c478bd9Sstevel@tonic-gate relend = relbgn + (ulong_t)(RELSZ(lmp)); 4697c478bd9Sstevel@tonic-gate if (pltbgn) { 4707c478bd9Sstevel@tonic-gate if (!relbgn || (relbgn > pltbgn)) 4717c478bd9Sstevel@tonic-gate relbgn = pltbgn; 4727c478bd9Sstevel@tonic-gate if (!relbgn || (relend < pltend)) 4737c478bd9Sstevel@tonic-gate relend = pltend; 4747c478bd9Sstevel@tonic-gate } 4757c478bd9Sstevel@tonic-gate } 4767c478bd9Sstevel@tonic-gate if (!relbgn || (relbgn == relend)) { 4775aefb655Srie DBG_CALL(Dbg_reloc_run(lmp, 0, plt, DBG_REL_NONE)); 4787c478bd9Sstevel@tonic-gate return (1); 4797c478bd9Sstevel@tonic-gate } 4805aefb655Srie DBG_CALL(Dbg_reloc_run(lmp, M_REL_SHT_TYPE, plt, DBG_REL_START)); 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate /* 4837c478bd9Sstevel@tonic-gate * If we're processing a dynamic executable in lazy mode there is no 4847c478bd9Sstevel@tonic-gate * need to scan the .rel.plt table, however if we're processing a shared 4857c478bd9Sstevel@tonic-gate * object in lazy mode the .got addresses associated to each .plt must 4867c478bd9Sstevel@tonic-gate * be relocated to reflect the location of the shared object. 4877c478bd9Sstevel@tonic-gate */ 4887c478bd9Sstevel@tonic-gate if (pltbgn && ((MODE(lmp) & RTLD_NOW) == 0) && 4897c478bd9Sstevel@tonic-gate (FLAGS(lmp) & FLG_RT_FIXED)) 4907c478bd9Sstevel@tonic-gate noplt = 1; 4917c478bd9Sstevel@tonic-gate 492f441771bSRod Evans sip = SYMINFO(lmp); 4937c478bd9Sstevel@tonic-gate /* 4947c478bd9Sstevel@tonic-gate * Loop through relocations. 4957c478bd9Sstevel@tonic-gate */ 4967c478bd9Sstevel@tonic-gate while (relbgn < relend) { 49756deab07SRod Evans mmapobj_result_t *mpp; 4987c478bd9Sstevel@tonic-gate uint_t sb_flags = 0; 4997c478bd9Sstevel@tonic-gate 500ba2be530Sab196087 rtype = ELF_R_TYPE(((Rel *)relbgn)->r_info, M_MACH); 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate /* 5037c478bd9Sstevel@tonic-gate * If this is a RELATIVE relocation in a shared object (the 5047c478bd9Sstevel@tonic-gate * common case), and if we are not debugging, then jump into a 50556deab07SRod Evans * tighter relocation loop (elf_reloc_relative). 5067c478bd9Sstevel@tonic-gate */ 5077c478bd9Sstevel@tonic-gate if ((rtype == R_386_RELATIVE) && 5085aefb655Srie ((FLAGS(lmp) & FLG_RT_FIXED) == 0) && (DBG_ENABLED == 0)) { 5097c478bd9Sstevel@tonic-gate if (relacount) { 51056deab07SRod Evans relbgn = elf_reloc_relative_count(relbgn, 511f441771bSRod Evans relacount, relsiz, basebgn, lmp, 512f441771bSRod Evans textrel, 0); 5137c478bd9Sstevel@tonic-gate relacount = 0; 5147c478bd9Sstevel@tonic-gate } else { 5157c478bd9Sstevel@tonic-gate relbgn = elf_reloc_relative(relbgn, relend, 516f441771bSRod Evans relsiz, basebgn, lmp, textrel, 0); 5177c478bd9Sstevel@tonic-gate } 5187c478bd9Sstevel@tonic-gate if (relbgn >= relend) 5197c478bd9Sstevel@tonic-gate break; 520ba2be530Sab196087 rtype = ELF_R_TYPE(((Rel *)relbgn)->r_info, M_MACH); 5217c478bd9Sstevel@tonic-gate } 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate roffset = ((Rel *)relbgn)->r_offset; 5247c478bd9Sstevel@tonic-gate 5257c478bd9Sstevel@tonic-gate /* 5267c478bd9Sstevel@tonic-gate * If this is a shared object, add the base address to offset. 5277c478bd9Sstevel@tonic-gate */ 5287c478bd9Sstevel@tonic-gate if (!(FLAGS(lmp) & FLG_RT_FIXED)) { 5297c478bd9Sstevel@tonic-gate /* 5307c478bd9Sstevel@tonic-gate * If we're processing lazy bindings, we have to step 5317c478bd9Sstevel@tonic-gate * through the plt entries and add the base address 5327c478bd9Sstevel@tonic-gate * to the corresponding got entry. 5337c478bd9Sstevel@tonic-gate */ 5347c478bd9Sstevel@tonic-gate if (plthint && (plt == 0) && 5357c478bd9Sstevel@tonic-gate (rtype == R_386_JMP_SLOT) && 5367c478bd9Sstevel@tonic-gate ((MODE(lmp) & RTLD_NOW) == 0)) { 53756deab07SRod Evans relbgn = elf_reloc_relative_count(relbgn, 538f441771bSRod Evans plthint, relsiz, basebgn, lmp, textrel, 0); 5397c478bd9Sstevel@tonic-gate plthint = 0; 5407c478bd9Sstevel@tonic-gate continue; 5417c478bd9Sstevel@tonic-gate } 5427c478bd9Sstevel@tonic-gate roffset += basebgn; 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate rsymndx = ELF_R_SYM(((Rel *)relbgn)->r_info); 5467c478bd9Sstevel@tonic-gate rel = (Rel *)relbgn; 5477c478bd9Sstevel@tonic-gate relbgn += relsiz; 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate /* 5507c478bd9Sstevel@tonic-gate * Optimizations. 5517c478bd9Sstevel@tonic-gate */ 5527c478bd9Sstevel@tonic-gate if (rtype == R_386_NONE) 5537c478bd9Sstevel@tonic-gate continue; 5547c478bd9Sstevel@tonic-gate if (noplt && ((ulong_t)rel >= pltbgn) && 5557c478bd9Sstevel@tonic-gate ((ulong_t)rel < pltend)) { 5567c478bd9Sstevel@tonic-gate relbgn = pltend; 5577c478bd9Sstevel@tonic-gate continue; 5587c478bd9Sstevel@tonic-gate } 5597c478bd9Sstevel@tonic-gate 5607c478bd9Sstevel@tonic-gate /* 56156deab07SRod Evans * If we're promoting plts, determine if this one has already 5627c478bd9Sstevel@tonic-gate * been written. 5637c478bd9Sstevel@tonic-gate */ 56456deab07SRod Evans if (plt && ((*(ulong_t *)roffset < _pltbgn) || 56556deab07SRod Evans (*(ulong_t *)roffset > _pltend))) 5667c478bd9Sstevel@tonic-gate continue; 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate /* 5697c478bd9Sstevel@tonic-gate * If this relocation is not against part of the image 5707c478bd9Sstevel@tonic-gate * mapped into memory we skip it. 5717c478bd9Sstevel@tonic-gate */ 57256deab07SRod Evans if ((mpp = find_segment((caddr_t)roffset, lmp)) == NULL) { 5737247f888Srie elf_reloc_bad(lmp, (void *)rel, rtype, roffset, 5747247f888Srie rsymndx); 5757c478bd9Sstevel@tonic-gate continue; 5767c478bd9Sstevel@tonic-gate } 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate binfo = 0; 5797c478bd9Sstevel@tonic-gate /* 5807c478bd9Sstevel@tonic-gate * If a symbol index is specified then get the symbol table 5817c478bd9Sstevel@tonic-gate * entry, locate the symbol definition, and determine its 5827c478bd9Sstevel@tonic-gate * address. 5837c478bd9Sstevel@tonic-gate */ 5847c478bd9Sstevel@tonic-gate if (rsymndx) { 5857c478bd9Sstevel@tonic-gate /* 586f441771bSRod Evans * If a Syminfo section is provided, determine if this 587f441771bSRod Evans * symbol is deferred, and if so, skip this relocation. 588f441771bSRod Evans */ 589f441771bSRod Evans if (sip && is_sym_deferred((ulong_t)rel, basebgn, lmp, 590f441771bSRod Evans textrel, sip, rsymndx)) 591f441771bSRod Evans continue; 592f441771bSRod Evans 593f441771bSRod Evans /* 5947c478bd9Sstevel@tonic-gate * Get the local symbol table entry. 5957c478bd9Sstevel@tonic-gate */ 5967c478bd9Sstevel@tonic-gate symref = (Sym *)((ulong_t)SYMTAB(lmp) + 5977c478bd9Sstevel@tonic-gate (rsymndx * SYMENT(lmp))); 5987c478bd9Sstevel@tonic-gate 5997c478bd9Sstevel@tonic-gate /* 6007c478bd9Sstevel@tonic-gate * If this is a local symbol, just use the base address. 6017c478bd9Sstevel@tonic-gate * (we should have no local relocations in the 6027c478bd9Sstevel@tonic-gate * executable). 6037c478bd9Sstevel@tonic-gate */ 6047c478bd9Sstevel@tonic-gate if (ELF_ST_BIND(symref->st_info) == STB_LOCAL) { 6057c478bd9Sstevel@tonic-gate value = basebgn; 60608278a5eSRod Evans name = NULL; 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate /* 609d326b23bSrie * Special case TLS relocations. 6107c478bd9Sstevel@tonic-gate */ 611d326b23bSrie if (rtype == R_386_TLS_DTPMOD32) { 612d326b23bSrie /* 613d326b23bSrie * Use the TLS modid. 614d326b23bSrie */ 6157c478bd9Sstevel@tonic-gate value = TLSMODID(lmp); 616d326b23bSrie 617d326b23bSrie } else if (rtype == R_386_TLS_TPOFF) { 618d326b23bSrie if ((value = elf_static_tls(lmp, symref, 619d326b23bSrie rel, rtype, 0, roffset, 0)) == 0) { 620d326b23bSrie ret = 0; 621d326b23bSrie break; 622d326b23bSrie } 623d326b23bSrie } 6247c478bd9Sstevel@tonic-gate } else { 6257c478bd9Sstevel@tonic-gate /* 6267c478bd9Sstevel@tonic-gate * If the symbol index is equal to the previous 6277c478bd9Sstevel@tonic-gate * symbol index relocation we processed then 6287c478bd9Sstevel@tonic-gate * reuse the previous values. (Note that there 6297c478bd9Sstevel@tonic-gate * have been cases where a relocation exists 6307c478bd9Sstevel@tonic-gate * against a copy relocation symbol, our ld(1) 6317c478bd9Sstevel@tonic-gate * should optimize this away, but make sure we 6327c478bd9Sstevel@tonic-gate * don't use the same symbol information should 6337c478bd9Sstevel@tonic-gate * this case exist). 6347c478bd9Sstevel@tonic-gate */ 6357c478bd9Sstevel@tonic-gate if ((rsymndx == psymndx) && 6367c478bd9Sstevel@tonic-gate (rtype != R_386_COPY)) { 6377c478bd9Sstevel@tonic-gate /* LINTED */ 6387c478bd9Sstevel@tonic-gate if (psymdef == 0) { 6395aefb655Srie DBG_CALL(Dbg_bind_weak(lmp, 6405aefb655Srie (Addr)roffset, (Addr) 6417c478bd9Sstevel@tonic-gate (roffset - basebgn), name)); 6427c478bd9Sstevel@tonic-gate continue; 6437c478bd9Sstevel@tonic-gate } 6447c478bd9Sstevel@tonic-gate /* LINTED */ 6457c478bd9Sstevel@tonic-gate value = pvalue; 6467c478bd9Sstevel@tonic-gate /* LINTED */ 6477c478bd9Sstevel@tonic-gate name = pname; 6487c478bd9Sstevel@tonic-gate /* LINTED */ 6497c478bd9Sstevel@tonic-gate symdef = psymdef; 6507c478bd9Sstevel@tonic-gate /* LINTED */ 6517c478bd9Sstevel@tonic-gate symref = psymref; 6527c478bd9Sstevel@tonic-gate /* LINTED */ 6537c478bd9Sstevel@tonic-gate _lmp = plmp; 6547c478bd9Sstevel@tonic-gate /* LINTED */ 6557c478bd9Sstevel@tonic-gate binfo = pbinfo; 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate if ((LIST(_lmp)->lm_tflags | 65856deab07SRod Evans AFLAGS(_lmp)) & 6597c478bd9Sstevel@tonic-gate LML_TFLG_AUD_SYMBIND) { 6607c478bd9Sstevel@tonic-gate value = audit_symbind(lmp, _lmp, 6617c478bd9Sstevel@tonic-gate /* LINTED */ 6627c478bd9Sstevel@tonic-gate symdef, dsymndx, value, 6637c478bd9Sstevel@tonic-gate &sb_flags); 6647c478bd9Sstevel@tonic-gate } 6657c478bd9Sstevel@tonic-gate } else { 6667c478bd9Sstevel@tonic-gate Slookup sl; 66708278a5eSRod Evans Sresult sr; 6687c478bd9Sstevel@tonic-gate 6697c478bd9Sstevel@tonic-gate /* 6707c478bd9Sstevel@tonic-gate * Lookup the symbol definition. 67108278a5eSRod Evans * Initialize the symbol lookup, and 67208278a5eSRod Evans * symbol result, data structures. 6737c478bd9Sstevel@tonic-gate */ 6747c478bd9Sstevel@tonic-gate name = (char *)(STRTAB(lmp) + 6757c478bd9Sstevel@tonic-gate symref->st_name); 6767c478bd9Sstevel@tonic-gate 67775e7992aSrie SLOOKUP_INIT(sl, name, lmp, 0, 67875e7992aSrie ld_entry_cnt, 0, rsymndx, symref, 67975e7992aSrie rtype, LKUP_STDRELOC); 68008278a5eSRod Evans SRESULT_INIT(sr, name); 68108278a5eSRod Evans symdef = NULL; 6827c478bd9Sstevel@tonic-gate 68308278a5eSRod Evans if (lookup_sym(&sl, &sr, &binfo, 68408278a5eSRod Evans in_nfavl)) { 68508278a5eSRod Evans name = (char *)sr.sr_name; 68608278a5eSRod Evans _lmp = sr.sr_dmap; 68708278a5eSRod Evans symdef = sr.sr_sym; 68808278a5eSRod Evans } 6897c478bd9Sstevel@tonic-gate 6907c478bd9Sstevel@tonic-gate /* 6917c478bd9Sstevel@tonic-gate * If the symbol is not found and the 6927c478bd9Sstevel@tonic-gate * reference was not to a weak symbol, 6937c478bd9Sstevel@tonic-gate * report an error. Weak references 6947c478bd9Sstevel@tonic-gate * may be unresolved. 6957c478bd9Sstevel@tonic-gate */ 6967247f888Srie /* BEGIN CSTYLED */ 6977c478bd9Sstevel@tonic-gate if (symdef == 0) { 69860758829Srie if (sl.sl_bind != STB_WEAK) { 699dae2dfb7Srie if (elf_reloc_error(lmp, name, 700dae2dfb7Srie rel, binfo)) 7017c478bd9Sstevel@tonic-gate continue; 702dae2dfb7Srie 7037c478bd9Sstevel@tonic-gate ret = 0; 7047c478bd9Sstevel@tonic-gate break; 705dae2dfb7Srie 7067c478bd9Sstevel@tonic-gate } else { 7077c478bd9Sstevel@tonic-gate psymndx = rsymndx; 7087c478bd9Sstevel@tonic-gate psymdef = 0; 7097c478bd9Sstevel@tonic-gate 7105aefb655Srie DBG_CALL(Dbg_bind_weak(lmp, 7115aefb655Srie (Addr)roffset, (Addr) 7127c478bd9Sstevel@tonic-gate (roffset - basebgn), name)); 7137c478bd9Sstevel@tonic-gate continue; 7147c478bd9Sstevel@tonic-gate } 7157c478bd9Sstevel@tonic-gate } 7167247f888Srie /* END CSTYLED */ 7177c478bd9Sstevel@tonic-gate 7187c478bd9Sstevel@tonic-gate /* 7197c478bd9Sstevel@tonic-gate * If symbol was found in an object 7207c478bd9Sstevel@tonic-gate * other than the referencing object 7217c478bd9Sstevel@tonic-gate * then record the binding. 7227c478bd9Sstevel@tonic-gate */ 7237c478bd9Sstevel@tonic-gate if ((lmp != _lmp) && ((FLAGS1(_lmp) & 7247c478bd9Sstevel@tonic-gate FL1_RT_NOINIFIN) == 0)) { 725cce0e03bSab196087 if (aplist_test(&bound, _lmp, 7267c478bd9Sstevel@tonic-gate AL_CNT_RELBIND) == 0) { 7277c478bd9Sstevel@tonic-gate ret = 0; 7287c478bd9Sstevel@tonic-gate break; 7297c478bd9Sstevel@tonic-gate } 7307c478bd9Sstevel@tonic-gate } 7317c478bd9Sstevel@tonic-gate 7327c478bd9Sstevel@tonic-gate /* 7337c478bd9Sstevel@tonic-gate * Calculate the location of definition; 7347c478bd9Sstevel@tonic-gate * symbol value plus base address of 7357c478bd9Sstevel@tonic-gate * containing shared object. 7367c478bd9Sstevel@tonic-gate */ 7372926dd2eSrie if (IS_SIZE(rtype)) 7382926dd2eSrie value = symdef->st_size; 7392926dd2eSrie else 7407c478bd9Sstevel@tonic-gate value = symdef->st_value; 7412926dd2eSrie 7427c478bd9Sstevel@tonic-gate if (!(FLAGS(_lmp) & FLG_RT_FIXED) && 7432926dd2eSrie !(IS_SIZE(rtype)) && 7447c478bd9Sstevel@tonic-gate (symdef->st_shndx != SHN_ABS) && 7457c478bd9Sstevel@tonic-gate (ELF_ST_TYPE(symdef->st_info) != 7467c478bd9Sstevel@tonic-gate STT_TLS)) 7477c478bd9Sstevel@tonic-gate value += ADDR(_lmp); 7487c478bd9Sstevel@tonic-gate 7497c478bd9Sstevel@tonic-gate /* 7507c478bd9Sstevel@tonic-gate * Retain this symbol index and the 7517c478bd9Sstevel@tonic-gate * value in case it can be used for the 7527c478bd9Sstevel@tonic-gate * subsequent relocations. 7537c478bd9Sstevel@tonic-gate */ 7547c478bd9Sstevel@tonic-gate if (rtype != R_386_COPY) { 7557c478bd9Sstevel@tonic-gate psymndx = rsymndx; 7567c478bd9Sstevel@tonic-gate pvalue = value; 7577c478bd9Sstevel@tonic-gate pname = name; 7587c478bd9Sstevel@tonic-gate psymdef = symdef; 7597c478bd9Sstevel@tonic-gate psymref = symref; 7607c478bd9Sstevel@tonic-gate plmp = _lmp; 7617c478bd9Sstevel@tonic-gate pbinfo = binfo; 7627c478bd9Sstevel@tonic-gate } 7637c478bd9Sstevel@tonic-gate if ((LIST(_lmp)->lm_tflags | 76456deab07SRod Evans AFLAGS(_lmp)) & 7657c478bd9Sstevel@tonic-gate LML_TFLG_AUD_SYMBIND) { 7667c478bd9Sstevel@tonic-gate dsymndx = (((uintptr_t)symdef - 7677c478bd9Sstevel@tonic-gate (uintptr_t)SYMTAB(_lmp)) / 7687c478bd9Sstevel@tonic-gate SYMENT(_lmp)); 7697c478bd9Sstevel@tonic-gate value = audit_symbind(lmp, _lmp, 7707c478bd9Sstevel@tonic-gate symdef, dsymndx, value, 7717c478bd9Sstevel@tonic-gate &sb_flags); 7727c478bd9Sstevel@tonic-gate } 7737c478bd9Sstevel@tonic-gate } 7747c478bd9Sstevel@tonic-gate 7757c478bd9Sstevel@tonic-gate /* 7767c478bd9Sstevel@tonic-gate * If relocation is PC-relative, subtract 7777c478bd9Sstevel@tonic-gate * offset address. 7787c478bd9Sstevel@tonic-gate */ 7797c478bd9Sstevel@tonic-gate if (IS_PC_RELATIVE(rtype)) 7807c478bd9Sstevel@tonic-gate value -= roffset; 7817c478bd9Sstevel@tonic-gate 7827c478bd9Sstevel@tonic-gate /* 783d326b23bSrie * Special case TLS relocations. 7847c478bd9Sstevel@tonic-gate */ 785d326b23bSrie if (rtype == R_386_TLS_DTPMOD32) { 786d326b23bSrie /* 787d326b23bSrie * Relocation value is the TLS modid. 788d326b23bSrie */ 7897c478bd9Sstevel@tonic-gate value = TLSMODID(_lmp); 790d326b23bSrie 791d326b23bSrie } else if (rtype == R_386_TLS_TPOFF) { 792d326b23bSrie if ((value = elf_static_tls(_lmp, 793d326b23bSrie symdef, rel, rtype, name, roffset, 794d326b23bSrie value)) == 0) { 795d326b23bSrie ret = 0; 796d326b23bSrie break; 797d326b23bSrie } 798d326b23bSrie } 7997c478bd9Sstevel@tonic-gate } 8007c478bd9Sstevel@tonic-gate } else { 8017c478bd9Sstevel@tonic-gate /* 802d326b23bSrie * Special cases. 8037c478bd9Sstevel@tonic-gate */ 804d326b23bSrie if (rtype == R_386_TLS_DTPMOD32) { 805d326b23bSrie /* 806d326b23bSrie * TLS relocation value is the TLS modid. 807d326b23bSrie */ 8087c478bd9Sstevel@tonic-gate value = TLSMODID(lmp); 809d326b23bSrie } else 8107c478bd9Sstevel@tonic-gate value = basebgn; 81108278a5eSRod Evans 81208278a5eSRod Evans name = NULL; 8137c478bd9Sstevel@tonic-gate } 8147c478bd9Sstevel@tonic-gate 815d326b23bSrie DBG_CALL(Dbg_reloc_in(LIST(lmp), ELF_DBG_RTLD, M_MACH, 816e23c41c9SAli Bahrami M_REL_SHT_TYPE, rel, NULL, 0, name)); 817d326b23bSrie 8187c478bd9Sstevel@tonic-gate /* 81956deab07SRod Evans * Make sure the segment is writable. 8207c478bd9Sstevel@tonic-gate */ 82156deab07SRod Evans if (((mpp->mr_prot & PROT_WRITE) == 0) && 82256deab07SRod Evans ((set_prot(lmp, mpp, 1) == 0) || 82356deab07SRod Evans (aplist_append(textrel, mpp, AL_CNT_TEXTREL) == NULL))) { 8247c478bd9Sstevel@tonic-gate ret = 0; 8257c478bd9Sstevel@tonic-gate break; 8267c478bd9Sstevel@tonic-gate } 8277c478bd9Sstevel@tonic-gate 8287c478bd9Sstevel@tonic-gate /* 8297c478bd9Sstevel@tonic-gate * Call relocation routine to perform required relocation. 8307c478bd9Sstevel@tonic-gate */ 8317c478bd9Sstevel@tonic-gate switch (rtype) { 8327c478bd9Sstevel@tonic-gate case R_386_COPY: 8337c478bd9Sstevel@tonic-gate if (elf_copy_reloc(name, symref, lmp, (void *)roffset, 8347c478bd9Sstevel@tonic-gate symdef, _lmp, (const void *)value) == 0) 8357c478bd9Sstevel@tonic-gate ret = 0; 8367c478bd9Sstevel@tonic-gate break; 8377c478bd9Sstevel@tonic-gate case R_386_JMP_SLOT: 83856deab07SRod Evans if (((LIST(lmp)->lm_tflags | AFLAGS(lmp)) & 8397c478bd9Sstevel@tonic-gate (LML_TFLG_AUD_PLTENTER | LML_TFLG_AUD_PLTEXIT)) && 8407c478bd9Sstevel@tonic-gate AUDINFO(lmp)->ai_dynplts) { 8417c478bd9Sstevel@tonic-gate int fail = 0; 8427c478bd9Sstevel@tonic-gate int pltndx = (((ulong_t)rel - 8437c478bd9Sstevel@tonic-gate (uintptr_t)JMPREL(lmp)) / relsiz); 8447c478bd9Sstevel@tonic-gate int symndx = (((uintptr_t)symdef - 8457247f888Srie (uintptr_t)SYMTAB(_lmp)) / SYMENT(_lmp)); 8467c478bd9Sstevel@tonic-gate 8477c478bd9Sstevel@tonic-gate (void) elf_plt_trace_write(roffset, lmp, _lmp, 8487c478bd9Sstevel@tonic-gate symdef, symndx, pltndx, (caddr_t)value, 8497c478bd9Sstevel@tonic-gate sb_flags, &fail); 8507c478bd9Sstevel@tonic-gate if (fail) 8517c478bd9Sstevel@tonic-gate ret = 0; 8527c478bd9Sstevel@tonic-gate } else { 8537c478bd9Sstevel@tonic-gate /* 8547c478bd9Sstevel@tonic-gate * Write standard PLT entry to jump directly 8557c478bd9Sstevel@tonic-gate * to newly bound function. 8567c478bd9Sstevel@tonic-gate */ 8575aefb655Srie DBG_CALL(Dbg_reloc_apply_val(LIST(lmp), 8585aefb655Srie ELF_DBG_RTLD, (Xword)roffset, 8597c478bd9Sstevel@tonic-gate (Xword)value)); 8607c478bd9Sstevel@tonic-gate *(ulong_t *)roffset = value; 8617c478bd9Sstevel@tonic-gate } 8627c478bd9Sstevel@tonic-gate break; 8637c478bd9Sstevel@tonic-gate default: 8647c478bd9Sstevel@tonic-gate /* 8657c478bd9Sstevel@tonic-gate * Write the relocation out. 8667c478bd9Sstevel@tonic-gate */ 867f3324781Sab196087 if (do_reloc_rtld(rtype, (uchar_t *)roffset, 868f3324781Sab196087 (Word *)&value, name, NAME(lmp), LIST(lmp)) == 0) 8697c478bd9Sstevel@tonic-gate ret = 0; 8707c478bd9Sstevel@tonic-gate 8715aefb655Srie DBG_CALL(Dbg_reloc_apply_val(LIST(lmp), ELF_DBG_RTLD, 8725aefb655Srie (Xword)roffset, (Xword)value)); 8737c478bd9Sstevel@tonic-gate } 8747c478bd9Sstevel@tonic-gate 8757c478bd9Sstevel@tonic-gate if ((ret == 0) && 8767c478bd9Sstevel@tonic-gate ((LIST(lmp)->lm_flags & LML_FLG_TRC_WARN) == 0)) 8777c478bd9Sstevel@tonic-gate break; 8787c478bd9Sstevel@tonic-gate 8797c478bd9Sstevel@tonic-gate if (binfo) { 8805aefb655Srie DBG_CALL(Dbg_bind_global(lmp, (Addr)roffset, 8815aefb655Srie (Off)(roffset - basebgn), (Xword)(-1), PLT_T_FULL, 8825aefb655Srie _lmp, (Addr)value, symdef->st_value, name, binfo)); 8837c478bd9Sstevel@tonic-gate } 8847c478bd9Sstevel@tonic-gate } 8857c478bd9Sstevel@tonic-gate 88656deab07SRod Evans return (relocate_finish(lmp, bound, ret)); 8877c478bd9Sstevel@tonic-gate } 8887c478bd9Sstevel@tonic-gate 8897c478bd9Sstevel@tonic-gate /* 8907c478bd9Sstevel@tonic-gate * Initialize the first few got entries so that function calls go to 8917c478bd9Sstevel@tonic-gate * elf_rtbndr: 8927c478bd9Sstevel@tonic-gate * 8937c478bd9Sstevel@tonic-gate * GOT[GOT_XLINKMAP] = the address of the link map 8947c478bd9Sstevel@tonic-gate * GOT[GOT_XRTLD] = the address of rtbinder 8957c478bd9Sstevel@tonic-gate */ 8967c478bd9Sstevel@tonic-gate void 8977c478bd9Sstevel@tonic-gate elf_plt_init(void *got, caddr_t l) 8987c478bd9Sstevel@tonic-gate { 8997c478bd9Sstevel@tonic-gate uint_t *_got; 9007c478bd9Sstevel@tonic-gate /* LINTED */ 9017c478bd9Sstevel@tonic-gate Rt_map *lmp = (Rt_map *)l; 9027c478bd9Sstevel@tonic-gate 9037c478bd9Sstevel@tonic-gate _got = (uint_t *)got + M_GOT_XLINKMAP; 9047c478bd9Sstevel@tonic-gate *_got = (uint_t)lmp; 9057c478bd9Sstevel@tonic-gate _got = (uint_t *)got + M_GOT_XRTLD; 9067c478bd9Sstevel@tonic-gate *_got = (uint_t)elf_rtbndr; 9077c478bd9Sstevel@tonic-gate } 9087c478bd9Sstevel@tonic-gate 9097c478bd9Sstevel@tonic-gate /* 9107c478bd9Sstevel@tonic-gate * For SVR4 Intel compatability. USL uses /usr/lib/libc.so.1 as the run-time 9117c478bd9Sstevel@tonic-gate * linker, so the interpreter's address will differ from /usr/lib/ld.so.1. 9127c478bd9Sstevel@tonic-gate * Further, USL has special _iob[] and _ctype[] processing that makes up for the 9137c478bd9Sstevel@tonic-gate * fact that these arrays do not have associated copy relocations. So we try 9147c478bd9Sstevel@tonic-gate * and make up for that here. Any relocations found will be added to the global 9157c478bd9Sstevel@tonic-gate * copy relocation list and will be processed in setup(). 9167c478bd9Sstevel@tonic-gate */ 9177c478bd9Sstevel@tonic-gate static int 9187c478bd9Sstevel@tonic-gate _elf_copy_reloc(const char *name, Rt_map *rlmp, Rt_map *dlmp) 9197c478bd9Sstevel@tonic-gate { 9207c478bd9Sstevel@tonic-gate Sym *symref, *symdef; 9217c478bd9Sstevel@tonic-gate caddr_t ref, def; 9227c478bd9Sstevel@tonic-gate Rt_map *_lmp; 9237c478bd9Sstevel@tonic-gate Rel rel; 9247c478bd9Sstevel@tonic-gate Slookup sl; 92508278a5eSRod Evans Sresult sr; 9267c478bd9Sstevel@tonic-gate uint_t binfo; 9277c478bd9Sstevel@tonic-gate 9287c478bd9Sstevel@tonic-gate /* 9297c478bd9Sstevel@tonic-gate * Determine if the special symbol exists as a reference in the dynamic 9307c478bd9Sstevel@tonic-gate * executable, and that an associated definition exists in libc.so.1. 93175e7992aSrie * 93208278a5eSRod Evans * Initialize the symbol lookup, and symbol result, data structures. 9337c478bd9Sstevel@tonic-gate */ 93475e7992aSrie SLOOKUP_INIT(sl, name, rlmp, rlmp, ld_entry_cnt, 0, 0, 0, 0, 93575e7992aSrie LKUP_FIRST); 93608278a5eSRod Evans SRESULT_INIT(sr, name); 9377c478bd9Sstevel@tonic-gate 93808278a5eSRod Evans if (lookup_sym(&sl, &sr, &binfo, NULL) == 0) 93908278a5eSRod Evans return (1); 94008278a5eSRod Evans symref = sr.sr_sym; 94108278a5eSRod Evans 94208278a5eSRod Evans SLOOKUP_INIT(sl, name, rlmp, dlmp, ld_entry_cnt, 0, 0, 0, 0, 94308278a5eSRod Evans LKUP_DEFT); 94408278a5eSRod Evans SRESULT_INIT(sr, name); 94508278a5eSRod Evans 94608278a5eSRod Evans if (lookup_sym(&sl, &sr, &binfo, NULL) == 0) 9477c478bd9Sstevel@tonic-gate return (1); 9487c478bd9Sstevel@tonic-gate 94908278a5eSRod Evans _lmp = sr.sr_dmap; 95008278a5eSRod Evans symdef = sr.sr_sym; 9517c478bd9Sstevel@tonic-gate 95208278a5eSRod Evans if (strcmp(NAME(sr.sr_dmap), MSG_ORIG(MSG_PTH_LIBC))) 9537c478bd9Sstevel@tonic-gate return (1); 9547c478bd9Sstevel@tonic-gate 9557c478bd9Sstevel@tonic-gate /* 9567c478bd9Sstevel@tonic-gate * Determine the reference and definition addresses. 9577c478bd9Sstevel@tonic-gate */ 9587c478bd9Sstevel@tonic-gate ref = (void *)(symref->st_value); 9597c478bd9Sstevel@tonic-gate if (!(FLAGS(rlmp) & FLG_RT_FIXED)) 9607c478bd9Sstevel@tonic-gate ref += ADDR(rlmp); 9617c478bd9Sstevel@tonic-gate def = (void *)(symdef->st_value); 96208278a5eSRod Evans if (!(FLAGS(sr.sr_dmap) & FLG_RT_FIXED)) 9637c478bd9Sstevel@tonic-gate def += ADDR(_lmp); 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate /* 9667c478bd9Sstevel@tonic-gate * Set up a relocation entry for debugging and call the generic copy 9677c478bd9Sstevel@tonic-gate * relocation function to provide symbol size error checking and to 9687c478bd9Sstevel@tonic-gate * record the copy relocation that must be performed. 9697c478bd9Sstevel@tonic-gate */ 9707c478bd9Sstevel@tonic-gate rel.r_offset = (Addr)ref; 9717c478bd9Sstevel@tonic-gate rel.r_info = (Word)R_386_COPY; 9725aefb655Srie DBG_CALL(Dbg_reloc_in(LIST(rlmp), ELF_DBG_RTLD, M_MACH, M_REL_SHT_TYPE, 973e23c41c9SAli Bahrami &rel, NULL, 0, name)); 9747c478bd9Sstevel@tonic-gate 9757c478bd9Sstevel@tonic-gate return (elf_copy_reloc((char *)name, symref, rlmp, (void *)ref, symdef, 9767c478bd9Sstevel@tonic-gate _lmp, (void *)def)); 9777c478bd9Sstevel@tonic-gate } 9787c478bd9Sstevel@tonic-gate 9797c478bd9Sstevel@tonic-gate int 9807c478bd9Sstevel@tonic-gate elf_copy_gen(Rt_map *lmp) 9817c478bd9Sstevel@tonic-gate { 9827c478bd9Sstevel@tonic-gate if (interp && ((ulong_t)interp->i_faddr != 9837c478bd9Sstevel@tonic-gate r_debug.rtd_rdebug.r_ldbase) && 9847c478bd9Sstevel@tonic-gate !(strcmp(interp->i_name, MSG_ORIG(MSG_PTH_LIBC)))) { 9857c478bd9Sstevel@tonic-gate 9865aefb655Srie DBG_CALL(Dbg_reloc_run(lmp, M_REL_SHT_TYPE, 0, 9877c478bd9Sstevel@tonic-gate DBG_REL_START)); 9887c478bd9Sstevel@tonic-gate 9897c478bd9Sstevel@tonic-gate if (_elf_copy_reloc(MSG_ORIG(MSG_SYM_CTYPE), lmp, 9907c478bd9Sstevel@tonic-gate (Rt_map *)NEXT(lmp)) == 0) 9917c478bd9Sstevel@tonic-gate return (0); 9927c478bd9Sstevel@tonic-gate if (_elf_copy_reloc(MSG_ORIG(MSG_SYM_IOB), lmp, 9937c478bd9Sstevel@tonic-gate (Rt_map *)NEXT(lmp)) == 0) 9947c478bd9Sstevel@tonic-gate return (0); 9957c478bd9Sstevel@tonic-gate } 9967c478bd9Sstevel@tonic-gate return (1); 9977c478bd9Sstevel@tonic-gate } 9987c478bd9Sstevel@tonic-gate 9997c478bd9Sstevel@tonic-gate /* 10007c478bd9Sstevel@tonic-gate * Plt writing interface to allow debugging initialization to be generic. 10017c478bd9Sstevel@tonic-gate */ 10027c478bd9Sstevel@tonic-gate Pltbindtype 10037c478bd9Sstevel@tonic-gate /* ARGSUSED1 */ 10047c478bd9Sstevel@tonic-gate elf_plt_write(uintptr_t addr, uintptr_t vaddr, void *rptr, uintptr_t symval, 10057c478bd9Sstevel@tonic-gate Xword pltndx) 10067c478bd9Sstevel@tonic-gate { 10077c478bd9Sstevel@tonic-gate Rel *rel = (Rel*)rptr; 10087c478bd9Sstevel@tonic-gate uintptr_t pltaddr; 10097c478bd9Sstevel@tonic-gate 10107c478bd9Sstevel@tonic-gate pltaddr = addr + rel->r_offset; 10117c478bd9Sstevel@tonic-gate *(ulong_t *)pltaddr = (ulong_t)symval; 10127c478bd9Sstevel@tonic-gate DBG_CALL(pltcntfull++); 10137c478bd9Sstevel@tonic-gate return (PLT_T_FULL); 10147c478bd9Sstevel@tonic-gate } 10157c478bd9Sstevel@tonic-gate 10167c478bd9Sstevel@tonic-gate /* 10177c478bd9Sstevel@tonic-gate * Provide a machine specific interface to the conversion routine. By calling 10187c478bd9Sstevel@tonic-gate * the machine specific version, rather than the generic version, we insure that 10197c478bd9Sstevel@tonic-gate * the data tables/strings for all known machine versions aren't dragged into 10207c478bd9Sstevel@tonic-gate * ld.so.1. 10217c478bd9Sstevel@tonic-gate */ 10227c478bd9Sstevel@tonic-gate const char * 10235aefb655Srie _conv_reloc_type(uint_t rel) 10247c478bd9Sstevel@tonic-gate { 1025de777a60Sab196087 static Conv_inv_buf_t inv_buf; 1026de777a60Sab196087 1027de777a60Sab196087 return (conv_reloc_386_type(rel, 0, &inv_buf)); 10287c478bd9Sstevel@tonic-gate } 1029