machrel.sparc.c revision f3324781c875e2f9865c291e43f86ee710b0c145
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <stdio.h>
#include <sys/elf_SPARC.h>
#include <debug.h>
#include <reloc.h>
#include "msg.h"
#include "_libld.h"
/*
* Local Variable Definitions
*/
{
/* LINTED */
}
void
{
static int firstpass;
/*
* If a *PLUS relocatable is included, the output object is type *PLUS.
*/
/*
* On the first pass, we don't yet have a memory model to compare
* against, therefore the initial file becomes our baseline. Subsequent
* passes will do the comparison described below.
*/
if (firstpass == 0) {
firstpass++;
return;
}
/*
* Determine which memory model to mark the binary with. The options
* are (most restrictive to least):
*
* EF_SPARCV9_TSO 0x0 Total Store Order
* EF_SPARCV9_PSO 0x1 Partial Store Order
* EF_SPARCV9_RMO 0x2 Relaxed Memory Order
*
* Mark the binary with the most restrictive option encountered from a
* relocatable object included in the link.
*/
eflags &= ~EF_SPARCV9_MM;
/* EMPTY */
;
eflags |= EF_SPARCV9_PSO;
else
eflags |= EF_SPARCV9_RMO;
}
void
{
/*
* Create this entry if we are going to create a PLT table.
*/
if (ofl->ofl_pltcnt)
(*cnt)++; /* DT_PLTGOT */
}
}
void
{
else
(*dyn)++;
}
}
#if defined(_ELF64)
{
if ((pltndx) < M64_PLT_NEARPLTS) {
(pltndx * M_PLT_ENTSIZE);
return (value);
}
/*
* pltoffset of a far plt is calculated by:
*
* <size of near plt table> +
* <size of preceding far plt blocks> +
* <blockndx * sizeof (far plt entsize)>
*/
value =
/* size of near plt table */
/* size of preceding far plt blocks */
((farpltndx / M64_PLT_FBLKCNTS) *
((M64_PLT_FENTSIZE + sizeof (Addr)) *
M64_PLT_FBLKCNTS)) +
/* pltblockendx * fentsize */
return (value);
}
/*
* Instructions required for Far PLT's
*/
0x8a10000f, /* mov %o7, %g5 */
0x40000002, /* call . + 0x8 */
0x01000000, /* nop */
0xc25be000, /* ldx [%o7 + 0], %g1 */
0x83c3c001, /* jmpl %o7 + %g1, %g1 */
0x9e100005 /* mov %g5, %o7 */
};
/*
* Far PLT'S:
*
* Far PLT's are established in blocks of '160' at a time. These
* PLT's consist of 6 instructions (24 bytes) and 1 pointer (8 bytes).
* The instructions are collected together in blocks of 160 entries
* followed by 160 pointers. The last group of entries and pointers
* may contain less then 160 items. No padding is required.
*
* .PLT32768:
* mov %o7, %g5
* call . + 8
* nop
* ldx [%o7 + .PLTP32768 - (.PLT32768 + 4)], %g1
* jmpl %o7 + %g1, %g1
* mov %g5, %o7
* ................................
* .PLT32927:
* mov %o7, %g5
* call . + 8
* nop
* ldx [%o7 + .PLTP32927 - (.PLT32927 + 4)], %g1
* jmpl %o7 + %g1, %g1
* mov %g5, %o7
* .PLTP32768:
* .xword .PLT0-(.PLT32768+4)
* ................................
* .PLTP32927:
* .xword .PLT0-(.PLT32927+4)
*
*/
void
{
/*
* Determine the 'Far' PLT index.
*/
/*
* Determine what FPLT block this plt falls into.
*/
/*
* Calculate the starting offset of the Far PLT block
* that this PLT is a member of.
*/
(blockndx * M64_PLT_FBLOCKSZ);
pltoff = pltblockoff +
/*
* If this is a full block - the 'pltptroffs' start
* after 160 fplts.
*/
} else {
/*
* If this is the last block - the the pltptr's start
* after the last FPLT instruction sequence.
*/
}
/*
* For far-plts, the Raddend and Roffset fields are defined
* to be:
*
* roffset: address of .PLTP#
* raddend: -(.PLT#+4)
*/
/* LINTED */
/* LINTED */
/*
* update
* ldx [%o7 + 0], %g1
* to
* ldx [%o7 + .PLTP# - (.PLT# + 4)], %g1
*/
/* LINTED */
/*
* Store:
* .PLTP#
* .xword .PLT0 - .PLT# + 4
*/
}
/*
* Build a single V9 P.L.T. entry - code is:
*
* For Target Addresses +/- 4GB of the entry
* -----------------------------------------
* sethi (. - .PLT0), %g1
* ba,a %xcc, .PLT1
* nop
* nop
* nop
* nop
* nop
* nop
*
* For Target Addresses +/- 2GB of the entry
* -----------------------------------------
*
* .PLT0 is the address of the first entry in the P.L.T.
* This one is filled in by the run-time link editor. We just
* have to leave space for it.
*/
static void
{
/*
* The second part of the V9 ABI (sec. 5.2.4)
* applies to plt entries greater than 0x8000 (32,768).
* This is handled in 'plt_far_entry()'
*/
return;
}
*raddend = 0;
/*
* PLT[0]: sethi %hi(. - .L0), %g1
*/
/* LINTED */
/*
* PLT[1]: ba,a %xcc, .PLT1 (.PLT1 accessed as a
* PC-relative index of longwords).
*/
pltent += M_PLT_INSSIZE;
pltoff += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[2]: sethi 0, %g0 (NOP for delay slot of eventual CTI).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[3]: sethi 0, %g0 (NOP for PLT padding).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[4]: sethi 0, %g0 (NOP for PLT padding).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[5]: sethi 0, %g0 (NOP for PLT padding).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[6]: sethi 0, %g0 (NOP for PLT padding).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[7]: sethi 0, %g0 (NOP for PLT padding).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
}
#else /* Elf 32 */
{
(pltndx * M_PLT_ENTSIZE);
return (value);
}
/*
* Build a single P.L.T. entry - code is:
*
* sethi (. - .L0), %g1
* ba,a .L0
* sethi 0, %g0 (nop)
*
* .L0 is the address of the first entry in the P.L.T.
* This one is filled in by the run-time link editor. We just
* have to leave space for it.
*/
static void
{
*raddend = 0;
/*
* PLT[0]: sethi %hi(. - .L0), %g1
*/
/* LINTED */
/*
* PLT[1]: ba,a .L0 (.L0 accessed as a PC-relative index of longwords)
*/
pltent += M_PLT_INSSIZE;
pltoff += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[2]: sethi 0, %g0 (NOP for delay slot of eventual CTI).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
/*
* PLT[3]: sethi 0, %g0 (NOP for PLT padding).
*/
pltent += M_PLT_INSSIZE;
/* LINTED */
}
#endif /* _ELF64 */
{
char *relbits;
int sectmoved = 0;
/*
* Special case, a regsiter symbol associated with symbol
* index 0 is initialized (i.e. relocated) to a constant
* in the r_addend field rather than to a symbol value.
*/
return (1);
}
/*
* If the section this relocation is against has been discarded
* (-zignore), then also discard (skip) the relocation itself.
*/
return (1);
}
/*
* If this is a relocation against a move table, or expanded move
* table, adjust the relocation entries.
*/
/*
* If this is a relocation against a section then we need to adjust the
* raddend field to compensate for the new position of the input section
* within the new output section.
*/
/*
* If the symbol is moved, adjust the value
*/
sectmoved = 1;
else
/* LINTED */
raddend +=
} else {
/* LINTED */
raddend +=
}
}
/*
* This must be a R_SPARC_COPY. For these set the roffset to
* point to the new symbols location.
*/
/*
* The raddend doesn't mean anything in an R_SPARC_COPY
* relocation. Null it out because it can confuse people.
*/
raddend = 0;
/*
* The offsets of relocations against register symbols
* identifiy the register directly - so the offset
* does not need to be adjusted.
*/
} else {
/*
* Calculate virtual offset of reference point; equals offset
* into section + vaddr of section for loadable sections, or
* offset plus section displacement for nonloadable sections.
*/
}
/*
* Verify that the output relocations offset meets the
* alignment requirements of the relocation being processed.
*/
return (S_ERROR);
}
}
/*
* Assign the symbols index for the output relocation. If the
* relocation refers to a SECTION symbol then it's index is based upon
* the output sections symbols index. Otherwise the index can be
* derived from the symbols index itself.
*/
if (sectmoved == 0) {
/*
* Check for a null input section. This can
* occur if this relocation references a symbol
* generated by sym_add_sym().
*/
else
} else
} else
/*
* Add the symbols 'value' to the addend field.
*/
/*
* The addend field for R_SPARC_TLS_DTPMOD32 and R_SPARC_TLS_DTPMOD64
* mean nothing. The addend is propagated in the corresponding
* R_SPARC_TLS_DTPOFF* relocations.
*/
raddend = 0;
/*
* Assert we haven't walked off the end of our relocation table.
*/
/*
* Determine if this relocation is against a non-writable, allocatable
* section. If so we may need to provide a text relocation diagnostic.
*/
return (1);
}
/*
* Sparc Instructions for TLS processing
*/
#if defined(_ELF64)
#else
#endif
/* synthetic: mov %g0, %g0 */
/* bits 25->29 */
/* bits 14->18 */
/* bits 0->4 */
static Fixupret
{
/*
* IE reference model
*/
switch (rtype) {
case R_SPARC_TLS_GD_HI22:
return (FIX_RELOC);
case R_SPARC_TLS_GD_LO10:
return (FIX_RELOC);
case R_SPARC_TLS_GD_ADD:
R_SPARC_NONE, arsp));
*offset = (TLS_GD_IE_LD |
return (FIX_DONE);
case R_SPARC_TLS_GD_CALL:
R_SPARC_NONE, arsp));
*offset = TLS_GD_IE_ADD;
return (FIX_DONE);
}
return (FIX_RELOC);
}
/*
* LE reference model
*/
switch (rtype) {
case R_SPARC_TLS_IE_HI22:
case R_SPARC_TLS_GD_HI22:
case R_SPARC_TLS_LDO_HIX22:
return (FIX_RELOC);
case R_SPARC_TLS_LDO_LOX10:
return (FIX_RELOC);
case R_SPARC_TLS_IE_LO10:
case R_SPARC_TLS_GD_LO10:
/*
* Current instruction is:
*
* or r1, %lo(x), r2
* or
* add r1, %lo(x), r2
*
*
* Need to udpate this to:
*
* xor r1, %lox(x), r2
*/
*offset = TLS_GD_LE_XOR |
return (FIX_RELOC);
case R_SPARC_TLS_IE_LD:
case R_SPARC_TLS_IE_LDX:
/*
* Current instruction:
* ld{x} [r1 + r2], r3
*
* Need to update this to:
*
* mov r2, r3 (or %g0, r2, r3)
*/
R_SPARC_NONE, arsp));
return (FIX_DONE);
case R_SPARC_TLS_LDO_ADD:
case R_SPARC_TLS_GD_ADD:
/*
* Current instruction is:
*
* add gptr_reg, r2, r3
*
* Need to updated this to:
*
* add %g7, r2, r3
*/
R_SPARC_NONE, arsp));
return (FIX_DONE);
case R_SPARC_TLS_LDM_CALL:
R_SPARC_NONE, arsp));
return (FIX_DONE);
case R_SPARC_TLS_LDM_HI22:
case R_SPARC_TLS_LDM_LO10:
case R_SPARC_TLS_LDM_ADD:
case R_SPARC_TLS_IE_ADD:
case R_SPARC_TLS_GD_CALL:
R_SPARC_NONE, arsp));
return (FIX_DONE);
}
return (FIX_RELOC);
}
static Fixupret
{
const char *ifl_name;
switch (rtype) {
case R_SPARC_GOTDATA_OP_HIX22:
return (FIX_RELOC);
case R_SPARC_GOTDATA_OP_LOX10:
return (FIX_RELOC);
case R_SPARC_GOTDATA_OP:
/*
* Current instruction:
* ld{x} [r1 + r2], r3
*
* Need to update this to:
*
* add r1, r2, r3
*/
R_SPARC_NONE, arsp));
return (FIX_DONE);
}
/*
* We should not get here
*/
else
assert(0);
return (FIX_ERROR);
}
{
/*
* Process active relocations.
*/
/* LINTED */
const char *ifl_name;
/*
* If the section this relocation is against has been
* discarded (-zignore), then discard (skip) the
* relocation itself.
*/
(FLG_REL_GOT | FLG_REL_BSS |
FLG_REL_PLT | FLG_REL_NOINFO)) == 0)) {
continue;
}
/*
* Perform any required TLS fixups.
*/
return (S_ERROR);
continue;
}
/*
* Perform any required GOTOP fixups.
*/
if ((ret =
return (S_ERROR);
continue;
}
/*
* If this is a relocation against the move table, or
* expanded move table, adjust the relocation entries.
*/
value = 0;
STT_SECTION) {
/*
* The value for a symbol pointing to a SECTION
* is based off of that sections position.
*/
arsp->rel_roffset))) {
/*
* If the symbol is moved,
* adjust the value
*/
} else {
}
/*
* Size relocations require the symbols size.
*/
} else {
/*
* Else the value is the symbols value.
*/
}
/*
* Relocation against the GLOBAL_OFFSET_TABLE.
*/
/*
* If loadable and not producing a relocatable object
* add the sections virtual address to the reference
* address.
*/
((flags & FLG_OF_RELOBJ) == 0))
/*
* If this entry has a PLT assigned to it, it's
* value is actually the address of the PLT (and
* not the address of the function).
*/
}
/*
* Add relocations addend to value. Add extra
* relocation addend if needed.
*/
/*
* Determine whether the value needs further adjustment.
* Filter through the attributes of the relocation to
* determine what adjustment is required. Note, many
* of the following cases are only applicable when a
* .got is present. As a .got is not generated when a
* relocatable object is being built, any adjustments
* that require a .got need to be skipped.
*/
((flags & FLG_OF_RELOBJ) == 0)) {
/*
* Clear the GOT table entry, on SPARC we clear
* the entry and the 'value' if needed is stored
* in an output relocations addend.
*
* Calculate offset into GOT at which to apply
* the relocation.
*/
else
else
/* LINTED */
/*
* Add the GOTs data's offset.
*/
/*
* And do it.
*/
else
continue;
((flags & FLG_OF_RELOBJ) == 0)) {
(-neggotoffset * M_GOT_ENTSIZE));
((flags & FLG_OF_RELOBJ) == 0)) {
((flags & FLG_OF_RELOBJ) == 0)) {
((flags & FLG_OF_RELOBJ) == 0)) {
/*
* This is the LE TLS
* reference model. Static offset
* is hard-coded, and negated so that
* it can be added to the thread pointer (%g7)
*/
}
else
/*
* Make sure we have data to relocate. Compiler and
* assembler developers have been known to generate
* relocations against invalid sections (normally .bss),
* so for their benefit give them sufficient information
* to help analyze the problem. End users should never
* see this.
*/
return (S_ERROR);
}
/*
* Get the address of the data item we need to modify.
*/
is_indata));
/*LINTED*/
int class;
else
class = ERR_WARNING;
continue;
}
}
/*
* If '-z noreloc' is specified - skip the do_reloc
* stage.
*/
if (OFL_DO_RELOC(ofl)) {
}
}
}
return (return_code);
}
{
/*
* Static executables *do not* want any relocations against them.
* Since our engine still creates relocations against a WEAK UNDEFINED
* symbol in a static executable, it's best to disable them here
* instead of through out the relocation code.
*/
(FLG_OF_STATIC | FLG_OF_EXEC))
return (1);
/*
* Certain relocations do not make sense in a 64bit shared object,
* if building a shared object do a sanity check on the output
* relocations being created.
*/
/*
* Because the R_SPARC_HIPLT22 & R_SPARC_LOPLT10 relocations
* are not relative they make no sense to create in a shared
* object - so emit the proper error message if that occurs.
*/
return (S_ERROR);
}
#if defined(_ELF64)
/*
* Each of the following relocations requires that the
* object being built be loaded in either the upper 32 or
* 44 bit range of memory. Since shared libraries traditionally
* are loaded in the lower range of memory - this isn't going
* to work.
*/
(rtype == R_SPARC_L44)) {
return (S_ERROR);
}
#endif
}
/*
* If no relocation cache structures are available allocate
* a new one and link it into the cache list.
*/
/*
* Output relocation numbers can vary considerably between
* building executables or shared objects (pic vs. non-pic),
* etc. But, they typically aren't very large, so for these
* objects use a standard bucket size. For building relocatable
* objects, typically there will be an output relocation for
* every input relocation.
*/
if (nextsize == 0) {
if (size > REL_HOIDESCNO)
else
} else
} else
return (S_ERROR);
/* LINTED */
/* LINTED */
}
/*
* If we are adding a output relocation against a section
* symbol (non-RELATIVE) then mark that section. These sections
* will be added to the .dynsym symbol table.
*/
((flags & FLG_REL_SCNNDX) ||
/*
* If this is a COMMON symbol - no output section
* exists yet - (it's created as part of sym_validate()).
* So - we mark here that when it's created it should
* be tagged with the FLG_OS_OUTREL flag.
*/
else
} else {
ofl->ofl_dynshdrcnt++;
}
}
}
ofl->ofl_outrelscnt++;
if (flags & FLG_REL_GOT)
else if (flags & FLG_REL_PLT)
else if (flags & FLG_REL_BSS)
else if (flags & FLG_REL_NOINFO)
else
ofl->ofl_relocrelcnt++;
#if defined(_ELF64)
/*
* When building a 64-bit object any R_SPARC_WDISP30 relocation is given
* a plt padding entry, unless we're building a relocatable object
* (ld -r) or -b is in effect.
*/
ofl->ofl_pltpad++;
}
#endif
/*
* We don't perform sorting on PLT relocations because
* they have already been assigned a PLT index and if we
* were to sort them we would have to re-assign the plt indexes.
*/
if (!(flags & FLG_REL_PLT))
ofl->ofl_reloccnt++;
/*
* Insure a GLOBAL_OFFSET_TABLE is generated if required.
*/
/*
* Identify and possibly warn of a displacement relocation.
*/
}
return (1);
}
/*
* Process relocation against a register symbol. Note, of -z muldefs is in
* effect there may have been multiple register definitions, which would have
* been processed as non-fatal, with the first definition winning. But, we
* will also process multiple relocations for these multiple definitions. In
* this case we must only preserve the relocation for the definition that was
* kept. The sad part is that register relocations don't typically specify
* the register symbol with which they are associated, so we might have to
* search the input files global symbols to determine if this relocation is
* appropriate.
*/
{
if (sdp == 0) {
break;
}
}
return (1);
}
}
/*
* process relocation for a LOCAL symbol
*/
{
/*
* if ((shared object) and (not pc relative relocation) and
* (not against ABS symbol))
* then
* if (rtype != R_SPARC_32)
* then
* build relocation against section
* else
* build R_SPARC_RELATIVE
* fi
* fi
*/
return (S_ERROR);
return (1);
}
/*
* If the relocation is against a 'non-allocatable' section
* and we can not resolve it now - then give a warning
* message.
*
* We can not resolve the symbol if either:
* a) it's undefined
* b) it's defined in a shared library and a
* COPY relocation hasn't moved it to the executable
*
* Note: because we process all of the relocations against the
* text segment before any others - we know whether
* or not a copy relocation will be generated before
* we get here (see reloc_init()->reloc_segments()).
*/
/*
* If the relocation is against a SHT_SUNW_ANNOTATE
* section - then silently ignore that the relocation
* can not be resolved.
*/
if (rsp->rel_osdesc &&
return (0);
return (1);
}
/*
* Perform relocation.
*/
}
/*
* Establish a relocation transition. Note, at this point of input relocation
* processing, we have no idea of the relocation value that will be used in
* the eventual relocation calculation. This value is only known after the
* initial image has been constructed. Therefore, there is a small chance
* that a value can exceed the capabilities of the transitioned relocation.
* One example might be the offset from the GOT to a symbol.
*
* The only instance of this failure discovered so far has been via the use of
* ABS symbols to represent an external memory location. This situation is
* rare, since ABS symbols aren't typically generated by the compilers.
* Therefore, our solution is to excluded ABS symbols from the transition
* relocation possibilities. As an additional safeguard, if an inappropriate
* value is passed to the final relocation engine, a verification ("V")
* relocation should trigger a fatal error condition.
*/
{
/*
* When binding to a external symbol, no fixups are required
* and the GOTDATA_OP relocation can be ignored.
*/
if (rtype == R_SPARC_GOTDATA_OP)
return (1);
}
/*
* When binding to a local symbol the relocations can be transitioned:
*
* R_*_GOTDATA_OP_HIX22 -> R_*_GOTDATA_HIX22
* R_*_GOTDATA_OP_LOX10 -> R_*_GOTDATA_LOX10
* R_*_GOTDATA_OP -> instruction fixup
*/
}
{
/*
* If we're building an executable - use either the IE or LE access
* model. If we're building a shared object process any IE model.
*/
/*
* Set the DF_STATIC_TLS flag.
*/
/*
* When processing static TLS - these relocations
* can be ignored.
*/
if ((rtype == R_SPARC_TLS_IE_LD) ||
(rtype == R_SPARC_TLS_IE_LDX) ||
(rtype == R_SPARC_TLS_IE_ADD))
return (1);
/*
* Assign a GOT entry for IE static TLS references.
*/
if (((rtype == R_SPARC_TLS_GD_HI22) ||
(rtype == R_SPARC_TLS_GD_LO10) ||
(rtype == R_SPARC_TLS_IE_HI22) ||
(rtype == R_SPARC_TLS_IE_LO10)) &&
return (S_ERROR);
}
/*
* IE access model.
*/
/*
* Fixups are required for other executable models.
*/
}
/*
* LE access model.
*/
/*
* When processing static TLS - these relocations can be
* ignored.
*/
if (rtype == R_SPARC_TLS_IE_ADD)
return (1);
}
/*
* Building a shared object.
*
* For dynamic TLS references, ADD relocations are ignored.
*/
(rtype == R_SPARC_TLS_LDO_ADD))
return (1);
/*
* Assign a GOT entry for a dynamic TLS reference.
*/
if (((rtype == R_SPARC_TLS_LDM_HI22) ||
(rtype == R_SPARC_TLS_LDM_LO10)) &&
return (S_ERROR);
} else if (((rtype == R_SPARC_TLS_GD_HI22) ||
(rtype == R_SPARC_TLS_GD_LO10)) &&
return (S_ERROR);
}
/*
* cause a call to __tls_get_addr(). Convert this relocation to that
* symbol now, and prepare for the PLT magic.
*/
return (S_ERROR);
return (S_ERROR);
return (1);
}
}
/*
* ld_allocate_got: if a GOT is to be made, after the section is built this
* function is called to allocate all the GOT slots. The allocation is
* deferred until after all GOTs have been counted and sorted according
* to their size, for only then will we know how to allocate them on
* a processor like SPARC which has different models for addressing the
* GOT. SPARC has two: small and large, small uses a signed 13-bit offset
* into the GOT, whereas large uses an unsigned 32-bit offset.
*/
{
gotents = 2;
else
gotents = 1;
case M_GOT_SMALL:
small_index += gotents;
if (small_index == 0)
break;
case M_GOT_MIXED:
mixed_index += gotents;
break;
case M_GOT_LARGE:
large_index += gotents;
break;
default:
return (S_ERROR);
}
}
return (1);
}
/*
* Search the GOT index list for a GOT entry with the proper addend.
*/
Gotndx *
{
return (ofl->ofl_tlsldgotndx);
return (gnp);
}
return ((Gotndx *)0);
}
{
else
gotndx++;
(-neggotoffset * M_GOT_ENTSIZE)));
}
{
/* Some TLS requires two relocations with two GOT entries */
gotents = 2;
else
gotents = 1;
/*
* If an entry for this addend already exists, determine if it
* has mixed mode GOT access (both PIC and pic).
*
* In order to be accessible by both large and small pic,
* a mixed mode GOT must be located in the positive index
* range above _GLOBAL_OFFSET_TABLE_, and in the range
* reachable small pic. This is necessary because the large
* PIC mode cannot use a negative offset. This implies that
* there can be no more than (M_GOT_MAXSMALL/2 - M_GOT_XNumber)
* such entries.
*/
case M_GOT_SMALL:
/*
* This one was previously identified as a small
* GOT. If this access is large, then convert
* it to mixed.
*/
}
break;
case M_GOT_LARGE:
/*
* This one was previously identified as a large
* GOT. If this access is small, convert it to mixed.
*/
}
break;
}
return (1);
}
plnp = 0;
break;
}
/*
* Allocate a new entry.
*/
return (S_ERROR);
} else {
}
if (gref == GOT_REF_TLSLD) {
return (1);
}
if (plnp == 0) {
/*
* Insert at head of list
*/
return (S_ERROR);
/*
* Insert in middle of lest
*/
return (S_ERROR);
} else {
/*
* Append to tail of list
*/
return (S_ERROR);
}
return (1);
}
void
{
}
{
/*
* Sanity check -- is this going to fit at all? There are two
* limits to be concerned about:
* 1) There is a limit on the number of small pic GOT indices,
* given by M_GOT_MAXSMALL.
* 2) If there are more than (M_GOT_MAXSMALL/2 - M_GOT_XNumber)
* small GOT indices, there will be items at negative
* offsets from _GLOBAL_OFFSET_TABLE_. Items that are
* accessed via large (PIC) code cannot reach these
* negative slots, so mixed mode items must be in the
* non-negative range. This implies a limit of
* (M_GOT_MAXSMALL/2 - M_GOT_XNumber) mixed mode indices.
*/
if (smlgotcnt > M_GOT_MAXSMALL) {
return (S_ERROR);
}
return (S_ERROR);
}
/*
* Set starting offset to be either 0, or a negative index into
* the GOT based on the number of small symbols we've got.
*/
(first_large_ndx - smlgotcnt) : 0);
/*
* Initialize the got offsets used by assign_got() to
* locate GOT items:
* small - Starting index of items referenced only
* by small offsets (-Kpic).
* mixed - Starting index of items referenced
* by both large (-KPIC) and small (-Kpic).
* large - Indexes referenced only by large (-KPIC)
*
* Small items can have negative indexes (i.e. lie below
* _GLOBAL_OFFSET_TABLE_). Mixed and large items must have
* non-negative offsets.
*/
/*
* Assign bias to GOT symbols.
*/
if (ofl->ofl_tlsldgotndx) {
large_index += 2;
}
return (1);
}
/*
* Initializes .got[0] with the _DYNAMIC symbol value.
*/
{
(-neggotoffset * M_GOT_ENTSIZE) +
(M_GOT_XDYNAMIC * M_GOT_ENTSIZE));
/* LINTED */
}
}
return (1);
}