usr/src/cmd/sgs/rtld/i386/i386_elf.c
author Rod Evans <Rod.Evans@Sun.COM>
Wed, 19 May 2010 22:33:49 -0700
changeset 12449 a87750d92895
parent 11827 d7ef53deac3f
permissions -rw-r--r--
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW PSARC/2010/175 Deferred symbol references 6943432 dlsym(RTLD_PROBE) should only bind to symbol definitions 6668759 an external method for determining whether an ELF dependency is optional
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     1
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     2
 * CDDL HEADER START
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     3
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
     5
 * Common Development and Distribution License (the "License").
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
     6
 * You may not use this file except in compliance with the License.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     7
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    11
 * and limitations under the License.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    12
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    18
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    19
 * CDDL HEADER END
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    20
 */
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
    21
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    22
/*
6812
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 6515
diff changeset
    23
 *	Copyright (c) 1988 AT&T
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 6515
diff changeset
    24
 *	  All Rights Reserved
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
    25
 *
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
    26
 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
6812
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 6515
diff changeset
    27
 */
febeba71273d PSARC 2008/309 expunge synonyms.h
raf
parents: 6515
diff changeset
    28
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    29
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    30
 * x86 machine dependent and ELF file class dependent functions.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    31
 * Contains routines for performing function binding and symbol relocations.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    32
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    33
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    34
#include	<stdio.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    35
#include	<sys/elf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    36
#include	<sys/elf_386.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    37
#include	<sys/mman.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    38
#include	<dlfcn.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    39
#include	<synch.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    40
#include	<string.h>
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
    41
#include	<debug.h>
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
    42
#include	<reloc.h>
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
    43
#include	<conv.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    44
#include	"_rtld.h"
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    45
#include	"_audit.h"
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    46
#include	"_elf.h"
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
    47
#include	"_inline_gen.h"
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
    48
#include	"_inline_reloc.h"
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    49
#include	"msg.h"
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    50
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    51
extern void	elf_rtbndr(Rt_map *, ulong_t, caddr_t);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    52
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    53
int
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    54
elf_mach_flags_check(Rej_desc *rej, Ehdr *ehdr)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    55
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    56
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    57
	 * Check machine type and flags.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    58
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    59
	if (ehdr->e_flags != 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    60
		rej->rej_type = SGS_REJ_BADFLAG;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    61
		rej->rej_info = (uint_t)ehdr->e_flags;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    62
		return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    63
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    64
	return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    65
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    66
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    67
void
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
    68
ldso_plt_init(Rt_map *lmp)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    69
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    70
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    71
	 * There is no need to analyze ld.so because we don't map in any of
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    72
	 * its dependencies.  However we may map these dependencies in later
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    73
	 * (as if ld.so had dlopened them), so initialize the plt and the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    74
	 * permission information.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    75
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    76
	if (PLTGOT(lmp))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    77
		elf_plt_init((PLTGOT(lmp)), (caddr_t)lmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    78
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    79
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    80
static const uchar_t dyn_plt_template[] = {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    81
/* 0x00 */  0x55,				/* pushl %ebp */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    82
/* 0x01 */  0x8b, 0xec,				/* movl %esp, %ebp */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    83
/* 0x03 */  0x68, 0x00, 0x00, 0x00, 0x00,	/* pushl trace_fields */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    84
/* 0x08 */  0xe9, 0xfc, 0xff, 0xff, 0xff, 0xff	/* jmp  elf_plt_trace */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    85
};
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    86
int	dyn_plt_ent_size = sizeof (dyn_plt_template);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    87
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    88
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    89
 * the dynamic plt entry is:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    90
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    91
 *	pushl	%ebp
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    92
 *	movl	%esp, %ebp
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    93
 *	pushl	tfp
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    94
 *	jmp	elf_plt_trace
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    95
 * dyn_data:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    96
 *	.align  4
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    97
 *	uintptr_t	reflmp
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    98
 *	uintptr_t	deflmp
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    99
 *	uint_t		symndx
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   100
 *	uint_t		sb_flags
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   101
 *	Sym		symdef
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   102
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   103
static caddr_t
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   104
elf_plt_trace_write(uint_t roffset, Rt_map *rlmp, Rt_map *dlmp, Sym *sym,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   105
    uint_t symndx, uint_t pltndx, caddr_t to, uint_t sb_flags, int *fail)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   106
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   107
	extern int	elf_plt_trace();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   108
	ulong_t		got_entry;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   109
	uchar_t		*dyn_plt;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   110
	uintptr_t	*dyndata;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   111
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   112
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   113
	 * We only need to add the glue code if there is an auditing
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   114
	 * library that is interested in this binding.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   115
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   116
	dyn_plt = (uchar_t *)((uintptr_t)AUDINFO(rlmp)->ai_dynplts +
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   117
	    (pltndx * dyn_plt_ent_size));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   118
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   119
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   120
	 * Have we initialized this dynamic plt entry yet?  If we haven't do it
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   121
	 * now.  Otherwise this function has been called before, but from a
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   122
	 * different plt (ie. from another shared object).  In that case
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   123
	 * we just set the plt to point to the new dyn_plt.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   124
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   125
	if (*dyn_plt == 0) {
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   126
		Sym	*symp;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   127
		Word	symvalue;
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   128
		Lm_list	*lml = LIST(rlmp);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   129
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   130
		(void) memcpy((void *)dyn_plt, dyn_plt_template,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   131
		    sizeof (dyn_plt_template));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   132
		dyndata = (uintptr_t *)((uintptr_t)dyn_plt +
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   133
		    ROUND(sizeof (dyn_plt_template), M_WORD_ALIGN));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   134
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   135
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   136
		 * relocate:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   137
		 *	pushl	dyn_data
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   138
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   139
		symvalue = (Word)dyndata;
5189
66a4f4f8a159 6610591 do_reloc() should not require unused arguments
ab196087
parents: 4947
diff changeset
   140
		if (do_reloc_rtld(R_386_32, &dyn_plt[4], &symvalue,
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   141
		    MSG_ORIG(MSG_SYM_LADYNDATA),
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   142
		    MSG_ORIG(MSG_SPECFIL_DYNPLT), lml) == 0) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   143
			*fail = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   144
			return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   145
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   146
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   147
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   148
		 * jmps are relative, so I need to figure out the relative
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   149
		 * address to elf_plt_trace.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   150
		 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   151
		 * relocating:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   152
		 *	jmp	elf_plt_trace
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   153
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   154
		symvalue = (ulong_t)(elf_plt_trace) - (ulong_t)(dyn_plt + 9);
5189
66a4f4f8a159 6610591 do_reloc() should not require unused arguments
ab196087
parents: 4947
diff changeset
   155
		if (do_reloc_rtld(R_386_PC32, &dyn_plt[9], &symvalue,
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   156
		    MSG_ORIG(MSG_SYM_ELFPLTTRACE),
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   157
		    MSG_ORIG(MSG_SPECFIL_DYNPLT), lml) == 0) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   158
			*fail = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   159
			return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   160
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   161
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   162
		*dyndata++ = (uintptr_t)rlmp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   163
		*dyndata++ = (uintptr_t)dlmp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   164
		*dyndata++ = (uint_t)symndx;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   165
		*dyndata++ = (uint_t)sb_flags;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   166
		symp = (Sym *)dyndata;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   167
		*symp = *sym;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   168
		symp->st_name += (Word)STRTAB(dlmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   169
		symp->st_value = (Addr)to;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   170
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   171
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   172
	got_entry = (ulong_t)roffset;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   173
	*(ulong_t *)got_entry = (ulong_t)dyn_plt;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   174
	return ((caddr_t)dyn_plt);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   175
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   176
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   177
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   178
 * Function binding routine - invoked on the first call to a function through
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   179
 * the procedure linkage table;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   180
 * passes first through an assembly language interface.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   181
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   182
 * Takes the offset into the relocation table of the associated
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   183
 * relocation entry and the address of the link map (rt_private_map struct)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   184
 * for the entry.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   185
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   186
 * Returns the address of the function referenced after re-writing the PLT
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   187
 * entry to invoke the function directly.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   188
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   189
 * On error, causes process to terminate with a signal.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   190
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   191
ulong_t
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   192
elf_bndr(Rt_map *lmp, ulong_t reloff, caddr_t from)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   193
{
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   194
	Rt_map		*nlmp, *llmp;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   195
	ulong_t		addr, symval, rsymndx;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   196
	char		*name;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   197
	Rel		*rptr;
5220
caa2c0074088 PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents: 5189
diff changeset
   198
	Sym		*rsym, *nsym;
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   199
	uint_t		binfo, sb_flags = 0, dbg_class;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   200
	Slookup		sl;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   201
	Sresult		sr;
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   202
	int		entry, lmflags;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   203
	Lm_list		*lml;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   204
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   205
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   206
	 * For compatibility with libthread (TI_VERSION 1) we track the entry
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   207
	 * value.  A zero value indicates we have recursed into ld.so.1 to
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   208
	 * further process a locking request.  Under this recursion we disable
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   209
	 * tsort and cleanup activities.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   210
	 */
6515
10dab2b883e0 6678310 using LD_AUDIT, ld.so.1 calls shared library's .init before library is fully relocated
raf
parents: 6387
diff changeset
   211
	entry = enter(0);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   212
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   213
	lml = LIST(lmp);
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   214
	if ((lmflags = lml->lm_flags) & LML_FLG_RTLDLM) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   215
		dbg_class = dbg_desc->d_class;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   216
		dbg_desc->d_class = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   217
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   218
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   219
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   220
	 * Perform some basic sanity checks.  If we didn't get a load map or
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   221
	 * the relocation offset is invalid then its possible someone has walked
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   222
	 * over the .got entries or jumped to plt0 out of the blue.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   223
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   224
	if (!lmp || ((reloff % sizeof (Rel)) != 0)) {
4734
a4708faa3e85 6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents: 4679
diff changeset
   225
		Conv_inv_buf_t inv_buf;
a4708faa3e85 6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents: 4679
diff changeset
   226
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   227
		eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_PLTREF),
4734
a4708faa3e85 6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents: 4679
diff changeset
   228
		    conv_reloc_386_type(R_386_JMP_SLOT, 0, &inv_buf),
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   229
		    EC_NATPTR(lmp), EC_XWORD(reloff), EC_NATPTR(from));
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   230
		rtldexit(lml, 1);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   231
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   232
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   233
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   234
	 * Use relocation entry to get symbol table entry and symbol name.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   235
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   236
	addr = (ulong_t)JMPREL(lmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   237
	rptr = (Rel *)(addr + reloff);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   238
	rsymndx = ELF_R_SYM(rptr->r_info);
5220
caa2c0074088 PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents: 5189
diff changeset
   239
	rsym = (Sym *)((ulong_t)SYMTAB(lmp) + (rsymndx * SYMENT(lmp)));
caa2c0074088 PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents: 5189
diff changeset
   240
	name = (char *)(STRTAB(lmp) + rsym->st_name);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   241
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   242
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   243
	 * Determine the last link-map of this list, this'll be the starting
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   244
	 * point for any tsort() processing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   245
	 */
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   246
	llmp = lml->lm_tail;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   247
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   248
	/*
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   249
	 * Find definition for symbol.  Initialize the symbol lookup, and
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   250
	 * symbol result, data structures.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   251
	 */
5950
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   252
	SLOOKUP_INIT(sl, name, lmp, lml->lm_head, ld_entry_cnt, 0,
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   253
	    rsymndx, rsym, 0, LKUP_DEFT);
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   254
	SRESULT_INIT(sr, name);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   255
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   256
	if (lookup_sym(&sl, &sr, &binfo, NULL) == 0) {
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   257
		eprintf(lml, ERR_FATAL, MSG_INTL(MSG_REL_NOSYM), NAME(lmp),
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   258
		    demangle(name));
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   259
		rtldexit(lml, 1);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   260
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   261
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   262
	name = (char *)sr.sr_name;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   263
	nlmp = sr.sr_dmap;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   264
	nsym = sr.sr_sym;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   265
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   266
	symval = nsym->st_value;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   267
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   268
	if (!(FLAGS(nlmp) & FLG_RT_FIXED) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   269
	    (nsym->st_shndx != SHN_ABS))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   270
		symval += ADDR(nlmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   271
	if ((lmp != nlmp) && ((FLAGS1(nlmp) & FL1_RT_NOINIFIN) == 0)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   272
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   273
		 * Record that this new link map is now bound to the caller.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   274
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   275
		if (bind_one(lmp, nlmp, BND_REFER) == 0)
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   276
			rtldexit(lml, 1);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   277
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   278
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   279
	if ((lml->lm_tflags | AFLAGS(lmp)) & LML_TFLG_AUD_SYMBIND) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   280
		uint_t	symndx = (((uintptr_t)nsym -
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   281
		    (uintptr_t)SYMTAB(nlmp)) / SYMENT(nlmp));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   282
		symval = audit_symbind(lmp, nlmp, nsym, symndx, symval,
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   283
		    &sb_flags);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   284
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   285
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   286
	if (!(rtld_flags & RT_FL_NOBIND)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   287
		addr = rptr->r_offset;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   288
		if (!(FLAGS(lmp) & FLG_RT_FIXED))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   289
			addr += ADDR(lmp);
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   290
		if (((lml->lm_tflags | AFLAGS(lmp)) &
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   291
		    (LML_TFLG_AUD_PLTENTER | LML_TFLG_AUD_PLTEXIT)) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   292
		    AUDINFO(lmp)->ai_dynplts) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   293
			int	fail = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   294
			uint_t	pltndx = reloff / sizeof (Rel);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   295
			uint_t	symndx = (((uintptr_t)nsym -
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   296
			    (uintptr_t)SYMTAB(nlmp)) / SYMENT(nlmp));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   297
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   298
			symval = (ulong_t)elf_plt_trace_write(addr, lmp, nlmp,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   299
			    nsym, symndx, pltndx, (caddr_t)symval, sb_flags,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   300
			    &fail);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   301
			if (fail)
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   302
				rtldexit(lml, 1);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   303
		} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   304
			/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   305
			 * Write standard PLT entry to jump directly
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   306
			 * to newly bound function.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   307
			 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   308
			*(ulong_t *)addr = symval;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   309
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   310
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   311
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   312
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   313
	 * Print binding information and rebuild PLT entry.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   314
	 */
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   315
	DBG_CALL(Dbg_bind_global(lmp, (Addr)from, (Off)(from - ADDR(lmp)),
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   316
	    (Xword)(reloff / sizeof (Rel)), PLT_T_FULL, nlmp, (Addr)symval,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   317
	    nsym->st_value, name, binfo));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   318
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   319
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   320
	 * Complete any processing for newly loaded objects.  Note we don't
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   321
	 * know exactly where any new objects are loaded (we know the object
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   322
	 * that supplied the symbol, but others may have been loaded lazily as
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   323
	 * we searched for the symbol), so sorting starts from the last
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   324
	 * link-map know on entry to this routine.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   325
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   326
	if (entry)
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   327
		load_completion(llmp);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   328
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   329
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   330
	 * Some operations like dldump() or dlopen()'ing a relocatable object
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   331
	 * result in objects being loaded on rtld's link-map, make sure these
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   332
	 * objects are initialized also.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   333
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   334
	if ((LIST(nlmp)->lm_flags & LML_FLG_RTLDLM) && LIST(nlmp)->lm_init)
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   335
		load_completion(nlmp);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   336
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   337
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   338
	 * Make sure the object to which we've bound has had it's .init fired.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   339
	 * Cleanup before return to user code.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   340
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   341
	if (entry) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   342
		is_dep_init(nlmp, lmp);
6515
10dab2b883e0 6678310 using LD_AUDIT, ld.so.1 calls shared library's .init before library is fully relocated
raf
parents: 6387
diff changeset
   343
		leave(lml, 0);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   344
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   345
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   346
	if (lmflags & LML_FLG_RTLDLM)
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   347
		dbg_desc->d_class = dbg_class;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   348
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   349
	return (symval);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   350
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   351
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   352
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   353
 * Read and process the relocations for one link object, we assume all
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   354
 * relocation sections for loadable segments are stored contiguously in
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   355
 * the file.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   356
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   357
int
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   358
elf_reloc(Rt_map *lmp, uint_t plt, int *in_nfavl, APlist **textrel)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   359
{
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   360
	ulong_t		relbgn, relend, relsiz, basebgn, pltbgn, pltend;
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   361
	ulong_t		_pltbgn, _pltend;
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   362
	ulong_t		dsymndx, roffset, rsymndx, psymndx = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   363
	uchar_t		rtype;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   364
	long		value, pvalue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   365
	Sym		*symref, *psymref, *symdef, *psymdef;
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   366
	Syminfo		*sip;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   367
	char		*name, *pname;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   368
	Rt_map		*_lmp, *plmp;
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   369
	int		ret = 1, noplt = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   370
	int		relacount = RELACOUNT(lmp), plthint = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   371
	Rel		*rel;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   372
	uint_t		binfo, pbinfo;
5892
b863dde33f1b 6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents: 5220
diff changeset
   373
	APlist		*bound = NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   374
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   375
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   376
	 * Although only necessary for lazy binding, initialize the first
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   377
	 * global offset entry to go to elf_rtbndr().  dbx(1) seems
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   378
	 * to find this useful.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   379
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   380
	if ((plt == 0) && PLTGOT(lmp)) {
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   381
		mmapobj_result_t	*mpp;
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   382
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   383
		/*
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   384
		 * Make sure the segment is writable.
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   385
		 */
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   386
		if ((((mpp =
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   387
		    find_segment((caddr_t)PLTGOT(lmp), lmp)) != NULL) &&
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   388
		    ((mpp->mr_prot & PROT_WRITE) == 0)) &&
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   389
		    ((set_prot(lmp, mpp, 1) == 0) ||
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   390
		    (aplist_append(textrel, mpp, AL_CNT_TEXTREL) == NULL)))
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   391
			return (0);
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   392
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   393
		elf_plt_init(PLTGOT(lmp), (caddr_t)lmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   394
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   395
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   396
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   397
	 * Initialize the plt start and end addresses.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   398
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   399
	if ((pltbgn = (ulong_t)JMPREL(lmp)) != 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   400
		pltend = pltbgn + (ulong_t)(PLTRELSZ(lmp));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   401
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   402
	relsiz = (ulong_t)(RELENT(lmp));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   403
	basebgn = ADDR(lmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   404
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   405
	if (PLTRELSZ(lmp))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   406
		plthint = PLTRELSZ(lmp) / relsiz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   407
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   408
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   409
	 * If we've been called upon to promote an RTLD_LAZY object to an
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   410
	 * RTLD_NOW then we're only interested in scaning the .plt table.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   411
	 * An uninitialized .plt is the case where the associated got entry
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   412
	 * points back to the plt itself.  Determine the range of the real .plt
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   413
	 * entries using the _PROCEDURE_LINKAGE_TABLE_ symbol.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   414
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   415
	if (plt) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   416
		Slookup	sl;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   417
		Sresult	sr;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   418
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   419
		relbgn = pltbgn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   420
		relend = pltend;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   421
		if (!relbgn || (relbgn == relend))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   422
			return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   423
5950
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   424
		/*
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   425
		 * Initialize the symbol lookup, and symbol result, data
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   426
		 * structures.
5950
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   427
		 */
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   428
		SLOOKUP_INIT(sl, MSG_ORIG(MSG_SYM_PLT), lmp, lmp, ld_entry_cnt,
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   429
		    elf_hash(MSG_ORIG(MSG_SYM_PLT)), 0, 0, 0, LKUP_DEFT);
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   430
		SRESULT_INIT(sr, MSG_ORIG(MSG_SYM_PLT));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   431
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   432
		if (elf_find_sym(&sl, &sr, &binfo, NULL) == 0)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   433
			return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   434
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   435
		symdef = sr.sr_sym;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   436
		_pltbgn = symdef->st_value;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   437
		if (!(FLAGS(lmp) & FLG_RT_FIXED) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   438
		    (symdef->st_shndx != SHN_ABS))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   439
			_pltbgn += basebgn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   440
		_pltend = _pltbgn + (((PLTRELSZ(lmp) / relsiz)) *
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   441
		    M_PLT_ENTSIZE) + M_PLT_RESERVSZ;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   442
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   443
	} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   444
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   445
		 * The relocation sections appear to the run-time linker as a
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   446
		 * single table.  Determine the address of the beginning and end
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   447
		 * of this table.  There are two different interpretations of
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   448
		 * the ABI at this point:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   449
		 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   450
		 *   o	The REL table and its associated RELSZ indicate the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   451
		 *	concatenation of *all* relocation sections (this is the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   452
		 *	model our link-editor constructs).
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   453
		 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   454
		 *   o	The REL table and its associated RELSZ indicate the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   455
		 *	concatenation of all *but* the .plt relocations.  These
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   456
		 *	relocations are specified individually by the JMPREL and
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   457
		 *	PLTRELSZ entries.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   458
		 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   459
		 * Determine from our knowledege of the relocation range and
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   460
		 * .plt range, the range of the total relocation table.  Note
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   461
		 * that one other ABI assumption seems to be that the .plt
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   462
		 * relocations always follow any other relocations, the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   463
		 * following range checking drops that assumption.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   464
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   465
		relbgn = (ulong_t)(REL(lmp));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   466
		relend = relbgn + (ulong_t)(RELSZ(lmp));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   467
		if (pltbgn) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   468
			if (!relbgn || (relbgn > pltbgn))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   469
				relbgn = pltbgn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   470
			if (!relbgn || (relend < pltend))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   471
				relend = pltend;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   472
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   473
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   474
	if (!relbgn || (relbgn == relend)) {
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   475
		DBG_CALL(Dbg_reloc_run(lmp, 0, plt, DBG_REL_NONE));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   476
		return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   477
	}
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   478
	DBG_CALL(Dbg_reloc_run(lmp, M_REL_SHT_TYPE, plt, DBG_REL_START));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   479
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   480
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   481
	 * If we're processing a dynamic executable in lazy mode there is no
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   482
	 * need to scan the .rel.plt table, however if we're processing a shared
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   483
	 * object in lazy mode the .got addresses associated to each .plt must
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   484
	 * be relocated to reflect the location of the shared object.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   485
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   486
	if (pltbgn && ((MODE(lmp) & RTLD_NOW) == 0) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   487
	    (FLAGS(lmp) & FLG_RT_FIXED))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   488
		noplt = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   489
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   490
	sip = SYMINFO(lmp);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   491
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   492
	 * Loop through relocations.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   493
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   494
	while (relbgn < relend) {
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   495
		mmapobj_result_t	*mpp;
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   496
		uint_t			sb_flags = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   497
6206
6b0ed502a8e7 PSARC 2008/179 cross link-editor
ab196087
parents: 6150
diff changeset
   498
		rtype = ELF_R_TYPE(((Rel *)relbgn)->r_info, M_MACH);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   499
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   500
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   501
		 * If this is a RELATIVE relocation in a shared object (the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   502
		 * common case), and if we are not debugging, then jump into a
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   503
		 * tighter relocation loop (elf_reloc_relative).
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   504
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   505
		if ((rtype == R_386_RELATIVE) &&
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   506
		    ((FLAGS(lmp) & FLG_RT_FIXED) == 0) && (DBG_ENABLED == 0)) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   507
			if (relacount) {
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   508
				relbgn = elf_reloc_relative_count(relbgn,
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   509
				    relacount, relsiz, basebgn, lmp,
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   510
				    textrel, 0);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   511
				relacount = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   512
			} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   513
				relbgn = elf_reloc_relative(relbgn, relend,
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   514
				    relsiz, basebgn, lmp, textrel, 0);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   515
			}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   516
			if (relbgn >= relend)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   517
				break;
6206
6b0ed502a8e7 PSARC 2008/179 cross link-editor
ab196087
parents: 6150
diff changeset
   518
			rtype = ELF_R_TYPE(((Rel *)relbgn)->r_info, M_MACH);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   519
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   520
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   521
		roffset = ((Rel *)relbgn)->r_offset;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   522
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   523
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   524
		 * If this is a shared object, add the base address to offset.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   525
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   526
		if (!(FLAGS(lmp) & FLG_RT_FIXED)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   527
			/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   528
			 * If we're processing lazy bindings, we have to step
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   529
			 * through the plt entries and add the base address
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   530
			 * to the corresponding got entry.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   531
			 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   532
			if (plthint && (plt == 0) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   533
			    (rtype == R_386_JMP_SLOT) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   534
			    ((MODE(lmp) & RTLD_NOW) == 0)) {
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   535
				relbgn = elf_reloc_relative_count(relbgn,
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   536
				    plthint, relsiz, basebgn, lmp, textrel, 0);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   537
				plthint = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   538
				continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   539
			}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   540
			roffset += basebgn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   541
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   542
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   543
		rsymndx = ELF_R_SYM(((Rel *)relbgn)->r_info);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   544
		rel = (Rel *)relbgn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   545
		relbgn += relsiz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   546
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   547
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   548
		 * Optimizations.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   549
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   550
		if (rtype == R_386_NONE)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   551
			continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   552
		if (noplt && ((ulong_t)rel >= pltbgn) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   553
		    ((ulong_t)rel < pltend)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   554
			relbgn = pltend;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   555
			continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   556
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   557
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   558
		/*
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   559
		 * If we're promoting plts, determine if this one has already
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   560
		 * been written.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   561
		 */
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   562
		if (plt && ((*(ulong_t *)roffset < _pltbgn) ||
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   563
		    (*(ulong_t *)roffset > _pltend)))
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   564
			continue;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   565
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   566
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   567
		 * If this relocation is not against part of the image
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   568
		 * mapped into memory we skip it.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   569
		 */
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   570
		if ((mpp = find_segment((caddr_t)roffset, lmp)) == NULL) {
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   571
			elf_reloc_bad(lmp, (void *)rel, rtype, roffset,
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   572
			    rsymndx);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   573
			continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   574
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   575
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   576
		binfo = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   577
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   578
		 * If a symbol index is specified then get the symbol table
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   579
		 * entry, locate the symbol definition, and determine its
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   580
		 * address.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   581
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   582
		if (rsymndx) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   583
			/*
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   584
			 * If a Syminfo section is provided, determine if this
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   585
			 * symbol is deferred, and if so, skip this relocation.
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   586
			 */
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   587
			if (sip && is_sym_deferred((ulong_t)rel, basebgn, lmp,
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   588
			    textrel, sip, rsymndx))
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   589
				continue;
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   590
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   591
			/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   592
			 * Get the local symbol table entry.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   593
			 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   594
			symref = (Sym *)((ulong_t)SYMTAB(lmp) +
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   595
			    (rsymndx * SYMENT(lmp)));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   596
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   597
			/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   598
			 * If this is a local symbol, just use the base address.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   599
			 * (we should have no local relocations in the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   600
			 * executable).
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   601
			 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   602
			if (ELF_ST_BIND(symref->st_info) == STB_LOCAL) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   603
				value = basebgn;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   604
				name = NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   605
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   606
				/*
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   607
				 * Special case TLS relocations.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   608
				 */
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   609
				if (rtype == R_386_TLS_DTPMOD32) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   610
					/*
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   611
					 * Use the TLS modid.
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   612
					 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   613
					value = TLSMODID(lmp);
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   614
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   615
				} else if (rtype == R_386_TLS_TPOFF) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   616
					if ((value = elf_static_tls(lmp, symref,
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   617
					    rel, rtype, 0, roffset, 0)) == 0) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   618
						ret = 0;
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   619
						break;
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   620
					}
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   621
				}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   622
			} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   623
				/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   624
				 * If the symbol index is equal to the previous
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   625
				 * symbol index relocation we processed then
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   626
				 * reuse the previous values. (Note that there
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   627
				 * have been cases where a relocation exists
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   628
				 * against a copy relocation symbol, our ld(1)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   629
				 * should optimize this away, but make sure we
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   630
				 * don't use the same symbol information should
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   631
				 * this case exist).
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   632
				 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   633
				if ((rsymndx == psymndx) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   634
				    (rtype != R_386_COPY)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   635
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   636
					if (psymdef == 0) {
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   637
						DBG_CALL(Dbg_bind_weak(lmp,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   638
						    (Addr)roffset, (Addr)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   639
						    (roffset - basebgn), name));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   640
						continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   641
					}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   642
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   643
					value = pvalue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   644
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   645
					name = pname;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   646
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   647
					symdef = psymdef;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   648
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   649
					symref = psymref;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   650
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   651
					_lmp = plmp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   652
					/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   653
					binfo = pbinfo;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   654
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   655
					if ((LIST(_lmp)->lm_tflags |
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   656
					    AFLAGS(_lmp)) &
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   657
					    LML_TFLG_AUD_SYMBIND) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   658
						value = audit_symbind(lmp, _lmp,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   659
						    /* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   660
						    symdef, dsymndx, value,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   661
						    &sb_flags);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   662
					}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   663
				} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   664
					Slookup		sl;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   665
					Sresult		sr;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   666
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   667
					/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   668
					 * Lookup the symbol definition.
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   669
					 * Initialize the symbol lookup, and
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   670
					 * symbol result, data structures.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   671
					 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   672
					name = (char *)(STRTAB(lmp) +
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   673
					    symref->st_name);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   674
5950
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   675
					SLOOKUP_INIT(sl, name, lmp, 0,
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   676
					    ld_entry_cnt, 0, rsymndx, symref,
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   677
					    rtype, LKUP_STDRELOC);
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   678
					SRESULT_INIT(sr, name);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   679
					symdef = NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   680
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   681
					if (lookup_sym(&sl, &sr, &binfo,
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   682
					    in_nfavl)) {
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   683
						name = (char *)sr.sr_name;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   684
						_lmp = sr.sr_dmap;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   685
						symdef = sr.sr_sym;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   686
					}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   687
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   688
					/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   689
					 * If the symbol is not found and the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   690
					 * reference was not to a weak symbol,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   691
					 * report an error.  Weak references
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   692
					 * may be unresolved.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   693
					 */
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   694
					/* BEGIN CSTYLED */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   695
					if (symdef == 0) {
6150
bdc7a464af94 PSARC/2008/148: new ldd(1) -p option
rie
parents: 5950
diff changeset
   696
					    if (sl.sl_bind != STB_WEAK) {
bdc7a464af94 PSARC/2008/148: new ldd(1) -p option
rie
parents: 5950
diff changeset
   697
						if (elf_reloc_error(lmp, name,
bdc7a464af94 PSARC/2008/148: new ldd(1) -p option
rie
parents: 5950
diff changeset
   698
						    rel, binfo))
bdc7a464af94 PSARC/2008/148: new ldd(1) -p option
rie
parents: 5950
diff changeset
   699
							continue;
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   700
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   701
					   	ret = 0;
6150
bdc7a464af94 PSARC/2008/148: new ldd(1) -p option
rie
parents: 5950
diff changeset
   702
						break;
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   703
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   704
					    } else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   705
						psymndx = rsymndx;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   706
						psymdef = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   707
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   708
						DBG_CALL(Dbg_bind_weak(lmp,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   709
						    (Addr)roffset, (Addr)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   710
						    (roffset - basebgn), name));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   711
						continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   712
					    }
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   713
					}
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   714
					/* END CSTYLED */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   715
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   716
					/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   717
					 * If symbol was found in an object
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   718
					 * other than the referencing object
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   719
					 * then record the binding.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   720
					 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   721
					if ((lmp != _lmp) && ((FLAGS1(_lmp) &
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   722
					    FL1_RT_NOINIFIN) == 0)) {
5892
b863dde33f1b 6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents: 5220
diff changeset
   723
						if (aplist_test(&bound, _lmp,
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   724
						    AL_CNT_RELBIND) == 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   725
							ret = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   726
							break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   727
						}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   728
					}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   729
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   730
					/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   731
					 * Calculate the location of definition;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   732
					 * symbol value plus base address of
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   733
					 * containing shared object.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   734
					 */
2850
689acf945b89 PSARC/2006/558 R_*_SIZE relocation support
rie
parents: 2145
diff changeset
   735
					if (IS_SIZE(rtype))
689acf945b89 PSARC/2006/558 R_*_SIZE relocation support
rie
parents: 2145
diff changeset
   736
						value = symdef->st_size;
689acf945b89 PSARC/2006/558 R_*_SIZE relocation support
rie
parents: 2145
diff changeset
   737
					else
689acf945b89 PSARC/2006/558 R_*_SIZE relocation support
rie
parents: 2145
diff changeset
   738
						value = symdef->st_value;
689acf945b89 PSARC/2006/558 R_*_SIZE relocation support
rie
parents: 2145
diff changeset
   739
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   740
					if (!(FLAGS(_lmp) & FLG_RT_FIXED) &&
2850
689acf945b89 PSARC/2006/558 R_*_SIZE relocation support
rie
parents: 2145
diff changeset
   741
					    !(IS_SIZE(rtype)) &&
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   742
					    (symdef->st_shndx != SHN_ABS) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   743
					    (ELF_ST_TYPE(symdef->st_info) !=
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   744
					    STT_TLS))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   745
						value += ADDR(_lmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   746
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   747
					/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   748
					 * Retain this symbol index and the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   749
					 * value in case it can be used for the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   750
					 * subsequent relocations.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   751
					 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   752
					if (rtype != R_386_COPY) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   753
						psymndx = rsymndx;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   754
						pvalue = value;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   755
						pname = name;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   756
						psymdef = symdef;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   757
						psymref = symref;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   758
						plmp = _lmp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   759
						pbinfo = binfo;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   760
					}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   761
					if ((LIST(_lmp)->lm_tflags |
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   762
					    AFLAGS(_lmp)) &
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   763
					    LML_TFLG_AUD_SYMBIND) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   764
						dsymndx = (((uintptr_t)symdef -
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   765
						    (uintptr_t)SYMTAB(_lmp)) /
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   766
						    SYMENT(_lmp));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   767
						value = audit_symbind(lmp, _lmp,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   768
						    symdef, dsymndx, value,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   769
						    &sb_flags);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   770
					}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   771
				}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   772
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   773
				/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   774
				 * If relocation is PC-relative, subtract
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   775
				 * offset address.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   776
				 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   777
				if (IS_PC_RELATIVE(rtype))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   778
					value -= roffset;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   779
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   780
				/*
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   781
				 * Special case TLS relocations.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   782
				 */
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   783
				if (rtype == R_386_TLS_DTPMOD32) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   784
					/*
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   785
					 * Relocation value is the TLS modid.
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   786
					 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   787
					value = TLSMODID(_lmp);
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   788
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   789
				} else if (rtype == R_386_TLS_TPOFF) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   790
					if ((value = elf_static_tls(_lmp,
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   791
					    symdef, rel, rtype, name, roffset,
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   792
					    value)) == 0) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   793
						ret = 0;
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   794
						break;
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   795
					}
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   796
				}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   797
			}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   798
		} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   799
			/*
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   800
			 * Special cases.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   801
			 */
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   802
			if (rtype == R_386_TLS_DTPMOD32) {
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   803
				/*
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   804
				 * TLS relocation value is the TLS modid.
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   805
				 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   806
				value = TLSMODID(lmp);
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   807
			} else
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   808
				value = basebgn;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   809
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   810
			name = NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   811
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   812
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   813
		DBG_CALL(Dbg_reloc_in(LIST(lmp), ELF_DBG_RTLD, M_MACH,
9406
264141fcf761 6831285 linker LD_DEBUG support needs improvements
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 8598
diff changeset
   814
		    M_REL_SHT_TYPE, rel, NULL, 0, name));
2145
f3828f946507 6423051 static TLS support within the link-editors needs a major face lift
rie
parents: 1976
diff changeset
   815
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   816
		/*
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   817
		 * Make sure the segment is writable.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   818
		 */
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   819
		if (((mpp->mr_prot & PROT_WRITE) == 0) &&
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   820
		    ((set_prot(lmp, mpp, 1) == 0) ||
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   821
		    (aplist_append(textrel, mpp, AL_CNT_TEXTREL) == NULL))) {
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   822
			ret = 0;
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   823
			break;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   824
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   825
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   826
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   827
		 * Call relocation routine to perform required relocation.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   828
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   829
		switch (rtype) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   830
		case R_386_COPY:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   831
			if (elf_copy_reloc(name, symref, lmp, (void *)roffset,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   832
			    symdef, _lmp, (const void *)value) == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   833
				ret = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   834
			break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   835
		case R_386_JMP_SLOT:
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   836
			if (((LIST(lmp)->lm_tflags | AFLAGS(lmp)) &
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   837
			    (LML_TFLG_AUD_PLTENTER | LML_TFLG_AUD_PLTEXIT)) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   838
			    AUDINFO(lmp)->ai_dynplts) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   839
				int	fail = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   840
				int	pltndx = (((ulong_t)rel -
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   841
				    (uintptr_t)JMPREL(lmp)) / relsiz);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   842
				int	symndx = (((uintptr_t)symdef -
4679
3d9b5e6569cc PSARC/2007/413 Add -zglobalaudit option to ld
rie
parents: 2850
diff changeset
   843
				    (uintptr_t)SYMTAB(_lmp)) / SYMENT(_lmp));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   844
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   845
				(void) elf_plt_trace_write(roffset, lmp, _lmp,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   846
				    symdef, symndx, pltndx, (caddr_t)value,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   847
				    sb_flags, &fail);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   848
				if (fail)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   849
					ret = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   850
			} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   851
				/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   852
				 * Write standard PLT entry to jump directly
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   853
				 * to newly bound function.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   854
				 */
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   855
				DBG_CALL(Dbg_reloc_apply_val(LIST(lmp),
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   856
				    ELF_DBG_RTLD, (Xword)roffset,
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   857
				    (Xword)value));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   858
				*(ulong_t *)roffset = value;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   859
			}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   860
			break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   861
		default:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   862
			/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   863
			 * Write the relocation out.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   864
			 */
5189
66a4f4f8a159 6610591 do_reloc() should not require unused arguments
ab196087
parents: 4947
diff changeset
   865
			if (do_reloc_rtld(rtype, (uchar_t *)roffset,
66a4f4f8a159 6610591 do_reloc() should not require unused arguments
ab196087
parents: 4947
diff changeset
   866
			    (Word *)&value, name, NAME(lmp), LIST(lmp)) == 0)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   867
				ret = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   868
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   869
			DBG_CALL(Dbg_reloc_apply_val(LIST(lmp), ELF_DBG_RTLD,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   870
			    (Xword)roffset, (Xword)value));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   871
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   872
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   873
		if ((ret == 0) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   874
		    ((LIST(lmp)->lm_flags & LML_FLG_TRC_WARN) == 0))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   875
			break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   876
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   877
		if (binfo) {
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   878
			DBG_CALL(Dbg_bind_global(lmp, (Addr)roffset,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   879
			    (Off)(roffset - basebgn), (Xword)(-1), PLT_T_FULL,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   880
			    _lmp, (Addr)value, symdef->st_value, name, binfo));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   881
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   882
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   883
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
   884
	return (relocate_finish(lmp, bound, ret));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   885
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   886
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   887
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   888
 * Initialize the first few got entries so that function calls go to
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   889
 * elf_rtbndr:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   890
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   891
 *	GOT[GOT_XLINKMAP] =	the address of the link map
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   892
 *	GOT[GOT_XRTLD] =	the address of rtbinder
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   893
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   894
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   895
elf_plt_init(void *got, caddr_t l)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   896
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   897
	uint_t		*_got;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   898
	/* LINTED */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   899
	Rt_map		*lmp = (Rt_map *)l;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   900
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   901
	_got = (uint_t *)got + M_GOT_XLINKMAP;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   902
	*_got = (uint_t)lmp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   903
	_got = (uint_t *)got + M_GOT_XRTLD;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   904
	*_got = (uint_t)elf_rtbndr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   905
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   906
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   907
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   908
 * For SVR4 Intel compatability.  USL uses /usr/lib/libc.so.1 as the run-time
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   909
 * linker, so the interpreter's address will differ from /usr/lib/ld.so.1.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   910
 * Further, USL has special _iob[] and _ctype[] processing that makes up for the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   911
 * fact that these arrays do not have associated copy relocations.  So we try
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   912
 * and make up for that here.  Any relocations found will be added to the global
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   913
 * copy relocation list and will be processed in setup().
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   914
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   915
static int
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   916
_elf_copy_reloc(const char *name, Rt_map *rlmp, Rt_map *dlmp)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   917
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   918
	Sym		*symref, *symdef;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   919
	caddr_t 	ref, def;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   920
	Rt_map		*_lmp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   921
	Rel		rel;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   922
	Slookup		sl;
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   923
	Sresult		sr;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   924
	uint_t		binfo;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   925
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   926
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   927
	 * Determine if the special symbol exists as a reference in the dynamic
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   928
	 * executable, and that an associated definition exists in libc.so.1.
5950
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   929
	 *
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   930
	 * Initialize the symbol lookup, and symbol result, data structures.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   931
	 */
5950
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   932
	SLOOKUP_INIT(sl, name, rlmp, rlmp, ld_entry_cnt, 0, 0, 0, 0,
a449a24f9be0 6654381 lazy loading fall-back needs optimizing
rie
parents: 5892
diff changeset
   933
	    LKUP_FIRST);
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   934
	SRESULT_INIT(sr, name);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   935
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   936
	if (lookup_sym(&sl, &sr, &binfo, NULL) == 0)
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   937
		return (1);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   938
	symref = sr.sr_sym;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   939
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   940
	SLOOKUP_INIT(sl, name, rlmp, dlmp, ld_entry_cnt, 0, 0, 0, 0,
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   941
	    LKUP_DEFT);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   942
	SRESULT_INIT(sr, name);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   943
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   944
	if (lookup_sym(&sl, &sr, &binfo, NULL) == 0)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   945
		return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   946
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   947
	_lmp = sr.sr_dmap;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   948
	symdef = sr.sr_sym;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   949
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   950
	if (strcmp(NAME(sr.sr_dmap), MSG_ORIG(MSG_PTH_LIBC)))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   951
		return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   952
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   953
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   954
	 * Determine the reference and definition addresses.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   955
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   956
	ref = (void *)(symref->st_value);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   957
	if (!(FLAGS(rlmp) & FLG_RT_FIXED))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   958
		ref += ADDR(rlmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   959
	def = (void *)(symdef->st_value);
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 9406
diff changeset
   960
	if (!(FLAGS(sr.sr_dmap) & FLG_RT_FIXED))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   961
		def += ADDR(_lmp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   962
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   963
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   964
	 * Set up a relocation entry for debugging and call the generic copy
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   965
	 * relocation function to provide symbol size error checking and to
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   966
	 * record the copy relocation that must be performed.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   967
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   968
	rel.r_offset = (Addr)ref;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   969
	rel.r_info = (Word)R_386_COPY;
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   970
	DBG_CALL(Dbg_reloc_in(LIST(rlmp), ELF_DBG_RTLD, M_MACH, M_REL_SHT_TYPE,
9406
264141fcf761 6831285 linker LD_DEBUG support needs improvements
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents: 8598
diff changeset
   971
	    &rel, NULL, 0, name));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   972
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   973
	return (elf_copy_reloc((char *)name, symref, rlmp, (void *)ref, symdef,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   974
	    _lmp, (void *)def));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   975
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   976
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   977
int
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   978
elf_copy_gen(Rt_map *lmp)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   979
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   980
	if (interp && ((ulong_t)interp->i_faddr !=
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   981
	    r_debug.rtd_rdebug.r_ldbase) &&
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   982
	    !(strcmp(interp->i_name, MSG_ORIG(MSG_PTH_LIBC)))) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   983
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
   984
		DBG_CALL(Dbg_reloc_run(lmp, M_REL_SHT_TYPE, 0,
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   985
		    DBG_REL_START));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   986
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   987
		if (_elf_copy_reloc(MSG_ORIG(MSG_SYM_CTYPE), lmp,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   988
		    (Rt_map *)NEXT(lmp)) == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   989
			return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   990
		if (_elf_copy_reloc(MSG_ORIG(MSG_SYM_IOB), lmp,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   991
		    (Rt_map *)NEXT(lmp)) == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   992
			return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   993
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   994
	return (1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   995
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   996
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   997
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   998
 * Plt writing interface to allow debugging initialization to be generic.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   999
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1000
Pltbindtype
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1001
/* ARGSUSED1 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1002
elf_plt_write(uintptr_t addr, uintptr_t vaddr, void *rptr, uintptr_t symval,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1003
	Xword pltndx)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1004
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1005
	Rel		*rel = (Rel*)rptr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1006
	uintptr_t	pltaddr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1007
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1008
	pltaddr = addr + rel->r_offset;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1009
	*(ulong_t *)pltaddr = (ulong_t)symval;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1010
	DBG_CALL(pltcntfull++);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1011
	return (PLT_T_FULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1012
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1013
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1014
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1015
 * Provide a machine specific interface to the conversion routine.  By calling
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1016
 * the machine specific version, rather than the generic version, we insure that
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1017
 * the data tables/strings for all known machine versions aren't dragged into
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1018
 * ld.so.1.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1019
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1020
const char *
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents: 546
diff changeset
  1021
_conv_reloc_type(uint_t rel)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1022
{
8598
0867fc633d66 6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents: 6812
diff changeset
  1023
	static Conv_inv_buf_t	inv_buf;
4734
a4708faa3e85 6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents: 4679
diff changeset
  1024
a4708faa3e85 6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents: 4679
diff changeset
  1025
	return (conv_reloc_386_type(rel, 0, &inv_buf));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1026
}