/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* to redirect aliases for ld.so to the real one.
*/
/*
* Import data structures
*/
#include "lint.h"
#include <sys/sysconfig.h>
#include <elf.h>
#include <link.h>
#include <string.h>
#include "alias_boot.h"
/*
* Local manifest constants and macros.
*/
/*
* Alias ld.so entry point -- receives a bootstrap structure and a vector
* of strings. The vector is "well-known" to us, and consists of pointers
* to string constants. This aliasing bootstrap requires no relocation in
* order to run, save for the pointers of constant strings. This second
* parameter provides this. Note that this program is carefully coded in
* order to maintain the "no bootstrapping" requirement -- it calls only
* local functions, uses no intrinsics, etc.
*/
void *
{
int i, p; /* working */
long j; /* working */
/*
* Discover things about our environment: auxiliary vector (if
* any), arguments, program name, and the like.
*/
case EB_ARGV:
break;
case EB_AUXV:
break;
}
break;
}
ebp++;
}
/*
* If we didn't get a page size from looking in the auxiliary
* vector, we need to get one now.
*/
if (page_size == 0) {
}
/*
* Map in the real ld.so. Note that we're mapping it as
* an ELF database, not as a program -- we just want to walk it's
* data structures. Further mappings will actually establish the
* program in the address space.
*/
MAP_SHARED, ldfd, 0);
/*
* Validate the file we're looking at, ensure it has the correct
* ELF structures, such as: ELF magic numbers, coded for SPARC,
* is a ".so", etc.
*/
/*
* Point at program headers and start figuring out what to load.
*/
if (fph == 0) {
}
/*
* We'd better have at least one loadable segment.
*/
if (fph == 0)
/*
* Map enough address space to hold the program (as opposed to the
* file) represented by ld.so. The amount to be assigned is the
* range between the end of the last loadable segment and the
* beginning of the first PLUS the alignment of the first segment.
* mmap() can assign us any page-aligned address, but the relocations
* assume the alignments included in the program header. As an
* optimization, however, let's assume that mmap() will actually
* give us an aligned address -- since if it does, we can save
* an munmap() later on. If it doesn't -- then go try it again.
*/
MAP_SHARED, ldfd, 0);
/*
* Check to see whether alignment skew was really needed.
*/
MAP_SHARED, ldfd, 0);
}
/*
* We have the address space reserved, so map each loadable segment.
*/
/*
* Skip non-loadable segments or segments that don't occupy
* any memory.
*/
continue;
/*
* Determine the file offset to which the mapping will
* directed (must be aligned) and how much to map (might
* be more than the file in the case of .bss.)
*/
/*
* Set address of this segment relative to our base.
*/
/*
* If this is the first program header, record our base
* address for later use.
*/
}
/*
* Unmap anything from the last mapping address to this
* one.
*/
}
/*
* Determine the mapping protection from the section
* attributes.
*/
i = 0;
i |= PROT_READ;
i |= PROT_WRITE;
i |= PROT_EXEC;
/*
* If the memory occupancy of the segment overflows the
* definition in the file, we need to "zero out" the
* end of the mapping we've established, and if necessary,
*/
*((char *)foff + j) = 0;
if (j > 0) {
if (dzfd == 0) {
if (dzfd == -1)
}
0) == (caddr_t)-1)
}
}
/*
* Update the mapping claim pointer.
*/
}
/*
* Unmap any final reservation.
*/
if (mlen != 0)
/*
* Clean up file descriptor space we've consumed. Pass along
*/
if (dzfd != 0)
/*
* The call itself. Note that we start 1 instruction word in.
* The ELF ld.so contains an "entry vector" of branch instructions,
* which, for our interest are:
* +0: ba, a <normal startup>
* +4: ba, a <compatibility startup>
* +8: ba, a <alias startup>
* By starting at the alias startup, the ELF ld.so knows
* that a pointer to "eb" is available to it and further knows
* how to calculate the offset to the program's arguments and
* other structures. We do the "call" by returning to our
* bootstrap and then jumping to the address that we return.
*/
}