b71d513a362009e7000b3cb6cb82318dfd6c83a0edp/*
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * CDDL HEADER START
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp *
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * The contents of this file are subject to the terms of the
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * Common Development and Distribution License (the "License").
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * You may not use this file except in compliance with the License.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp *
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * or http://www.opensolaris.org/os/licensing.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * See the License for the specific language governing permissions
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * and limitations under the License.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp *
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * When distributing Covered Code, include this CDDL HEADER in each
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * If applicable, add the following below this CDDL HEADER, with the
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * fields enclosed by brackets "[]" replaced with your own identifying
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * information: Portions Copyright [yyyy] [name of copyright owner]
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp *
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * CDDL HEADER END
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp */
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp/*
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * Use is subject to license terms.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp */
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp#pragma ident "%Z%%M% %I% %E% SMI"
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp#include <sys/auxv.h>
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp#include <sys/types.h>
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp
b71d513a362009e7000b3cb6cb82318dfd6c83a0edpvoid
b71d513a362009e7000b3cb6cb82318dfd6c83a0edpsbcp_init(int argc, char *argv[], char *envp[])
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp{
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp auxv_t *ap;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp uintptr_t *p;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp int err;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp /*
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * Find the aux vector on the stack.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp */
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp p = (uintptr_t *)envp;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp while (*p != NULL)
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp p++;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp /*
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * p is now pointing at the 0 word after the environ pointers.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * After that is the aux vectors.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp *
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * We need to clear the AF_SUN_NOPLM flag from the AT_SUN_AUXFLAGS
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * aux vector. This flag told our linker that we don't have a
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * primary link map. Now that our linker is done initializing, we
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * want to clear this flag before we transfer control to the
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * applications copy of the linker, since we want that linker to have
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * a primary link map which will be the link map for the application
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp * we're running.
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp */
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp p++;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp for (ap = (auxv_t *)p; ap->a_type != AT_NULL; ap++) {
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp switch (ap->a_type) {
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp case AT_SUN_AUXFLAGS:
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp ap->a_un.a_val &= ~AF_SUN_NOPLM;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp break;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp default:
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp break;
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp }
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp }
b71d513a362009e7000b3cb6cb82318dfd6c83a0edp}