xref: /illumos-gate/usr/src/lib/libc/port/gen/env_data.c (revision e86372a01d2d16a5dd4a64e144ed978ba17fe7dd)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  *	Copyright (c) 1988 AT&T
29  *	All Rights Reserved.
30  */
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 /*
35  * NOTE: The environment symbol pair may also occur in crt1.o.  The definitions
36  * within crt1.o are required for the generation of ABI compliant applications
37  * (see bugid 1181124).  No other symbol definitions should be added to this
38  * file.
39  */
40 
41 /*
42  * The original SVR3 ABI states:
43  *
44  * Application Constraints
45  * As described above, libsys provides symbols for applications. In a few cases,
46  * however, an application is obliged to provide symbols for the library.
47  *
48  * extern char **environ;
49  *     Normally, this symbol is synonymous with environ, as
50  *     exec(BA_OS) describes.  This isn't always true, though, because
51  *     ANSI C does not define environ.  Thus, an ANSI C-conforming
52  *     application can define its own environ symbol, unrelated to the pro-
53  *     cess environment.  If the application defines environ and intends it
54  *     to have the System V Interface Definition, Third Edition semantics, it
55  *     must also define _environ so that the two symbols refer to the same
56  *     data object.
57  *
58  * The ABI description implies that the process environment should use
59  * _environ and that nothing in libc should make reference to the unadorned
60  * "environ" symbol.  This way, an application can define and use a symbol
61  * named "environ" for its own purposes without affecting the actual
62  * process environment.
63  */
64 
65 #pragma weak environ = _environ
66 const char **_environ = 0;
67