xref: /illumos-gate/usr/src/lib/brand/solaris10/cmd/s10_isaexec_wrapper.sh (revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9)
1#!/bin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25
26#
27# This script is invoked by isaexec-governed executable wrappers from within
28# s10-branded zones.  It circumvents the native isaexec so that native wrappers
29# will function correctly.
30#
31# All native executables must be run using the native linker.
32# By default, the kernel loads the linker at /lib/ld.so.1, which
33# in an s10 zone is the s10 linker.  Hence when we run the native
34# executable below, we explicitly specify /.SUNWnative/lib/ld.so.1 as our 32-
35# bit linker and /.SUNWnative/lib/64/ld.so.1 as our 64-bit linker.
36# For convience we define "n" to be the native path prefix.
37#
38bname=`/usr/bin/basename $0`
39dname=`/usr/bin/dirname $0`
40echo $dname | /usr/bin/grep "^/" >/dev/null || dname=`/bin/pwd`/$dname
41dname=`(cd $dname 2>/dev/null && /bin/pwd 2>/dev/null)`
42arch64=/
43LC_ALL=C /usr/bin/file /.SUNWnative/$dname/$bname | /usr/bin/grep "64-bit" \
44    >/dev/null && arch64=/64/
45n=/.SUNWnative
46
47LD_NOCONFIG=1
48LD_LIBRARY_PATH_32=$n/lib:$n/usr/lib:$n/usr/lib/mps
49LD_LIBRARY_PATH_64=$n/lib/64:$n/usr/lib/64:$n/usr/lib/mps/64
50LD_PRELOAD_32=s10_npreload.so.1
51LD_PRELOAD_64=s10_npreload.so.1
52export LD_NOCONFIG
53export LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 LD_PRELOAD_32 LD_PRELOAD_64
54exec /.SUNWnative/usr/lib/brand/solaris10/s10_native \
55    /.SUNWnative/lib${arch64}ld.so.1 /.SUNWnative$dname/$bname "$@"
56
57