1*b71d513aSedp /*
2*b71d513aSedp * CDDL HEADER START
3*b71d513aSedp *
4*b71d513aSedp * The contents of this file are subject to the terms of the
5*b71d513aSedp * Common Development and Distribution License (the "License").
6*b71d513aSedp * You may not use this file except in compliance with the License.
7*b71d513aSedp *
8*b71d513aSedp * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*b71d513aSedp * or http://www.opensolaris.org/os/licensing.
10*b71d513aSedp * See the License for the specific language governing permissions
11*b71d513aSedp * and limitations under the License.
12*b71d513aSedp *
13*b71d513aSedp * When distributing Covered Code, include this CDDL HEADER in each
14*b71d513aSedp * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*b71d513aSedp * If applicable, add the following below this CDDL HEADER, with the
16*b71d513aSedp * fields enclosed by brackets "[]" replaced with your own identifying
17*b71d513aSedp * information: Portions Copyright [yyyy] [name of copyright owner]
18*b71d513aSedp *
19*b71d513aSedp * CDDL HEADER END
20*b71d513aSedp */
21*b71d513aSedp
22*b71d513aSedp /*
23*b71d513aSedp * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24*b71d513aSedp * Use is subject to license terms.
25*b71d513aSedp */
26*b71d513aSedp
27*b71d513aSedp #pragma ident "%Z%%M% %I% %E% SMI"
28*b71d513aSedp
29*b71d513aSedp #include <sys/auxv.h>
30*b71d513aSedp #include <sys/types.h>
31*b71d513aSedp
32*b71d513aSedp void
sbcp_init(int argc,char * argv[],char * envp[])33*b71d513aSedp sbcp_init(int argc, char *argv[], char *envp[])
34*b71d513aSedp {
35*b71d513aSedp auxv_t *ap;
36*b71d513aSedp uintptr_t *p;
37*b71d513aSedp int err;
38*b71d513aSedp
39*b71d513aSedp /*
40*b71d513aSedp * Find the aux vector on the stack.
41*b71d513aSedp */
42*b71d513aSedp p = (uintptr_t *)envp;
43*b71d513aSedp while (*p != NULL)
44*b71d513aSedp p++;
45*b71d513aSedp
46*b71d513aSedp /*
47*b71d513aSedp * p is now pointing at the 0 word after the environ pointers.
48*b71d513aSedp * After that is the aux vectors.
49*b71d513aSedp *
50*b71d513aSedp * We need to clear the AF_SUN_NOPLM flag from the AT_SUN_AUXFLAGS
51*b71d513aSedp * aux vector. This flag told our linker that we don't have a
52*b71d513aSedp * primary link map. Now that our linker is done initializing, we
53*b71d513aSedp * want to clear this flag before we transfer control to the
54*b71d513aSedp * applications copy of the linker, since we want that linker to have
55*b71d513aSedp * a primary link map which will be the link map for the application
56*b71d513aSedp * we're running.
57*b71d513aSedp */
58*b71d513aSedp p++;
59*b71d513aSedp for (ap = (auxv_t *)p; ap->a_type != AT_NULL; ap++) {
60*b71d513aSedp switch (ap->a_type) {
61*b71d513aSedp case AT_SUN_AUXFLAGS:
62*b71d513aSedp ap->a_un.a_val &= ~AF_SUN_NOPLM;
63*b71d513aSedp break;
64*b71d513aSedp default:
65*b71d513aSedp break;
66*b71d513aSedp }
67*b71d513aSedp }
68*b71d513aSedp }
69