4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
32 #include "lddstub_msg.h"
35 originlddstub(char *buffer
, const char *orgfile
)
39 if (dlinfo(RTLD_SELF
, RTLD_DI_ORIGIN
, (void *)buffer
) == -1)
41 if (strlcat(buffer
, orgfile
, PATH_MAX
) >= PATH_MAX
)
43 if ((len
= resolvepath(buffer
, buffer
, (PATH_MAX
- 1))) == -1)
46 if (access(buffer
, X_OK
) == -1)
52 static char orgstub
[PATH_MAX
], orgstub64
[PATH_MAX
];
53 static int orgflag
, orgflag64
;
56 * Determine what lddstub to run.
59 conv_lddstub(int class)
66 if (class == ELFCLASS32
)
67 stub
= MSG_ORIG(MSG_PTH_LDDSTUB
);
69 stub
= MSG_ORIG(MSG_PTH_LDDSTUB_64
);
72 * Provided we're not secure, determine lddstub's location from our
76 if ((class == ELFCLASS32
) && (orgflag
!= -1)) {
79 if ((orgflag
= originlddstub(orgstub
,
81 MSG_ORIG(MSG_ORG_64LDD_32STUB
))) == -1)
83 MSG_ORIG(MSG_ORG_32LDD_32STUB
))) == -1)
88 stub
= (const char *)orgstub
;
90 if ((class == ELFCLASS64
) && (orgflag64
!= -1)) {
93 if ((orgflag64
= originlddstub(orgstub64
,
95 MSG_ORIG(MSG_ORG_64LDD_64STUB
))) == -1)
97 MSG_ORIG(MSG_ORG_32LDD_64STUB
))) == -1)
102 stub
= (const char *)orgstub64
;