xref: /illumos-gate/usr/src/lib/libc/port/gen/env_data.c (revision 1da57d55)
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 /*
33  * NOTE: The environment symbol pair may also occur in crt1.o.  The definitions
34  * within crt1.o are required for the generation of ABI compliant applications
35  * (see bugid 1181124).  No other symbol definitions should be added to this
36  * file.
37  */
38 
39 /*
40  * The original SVR3 ABI states:
41  *
42  * Application Constraints
43  * As described above, libsys provides symbols for applications. In a few cases,
44  * however, an application is obliged to provide symbols for the library.
45  *
46  * extern char **environ;
47  *     Normally, this symbol is synonymous with environ, as
48  *     exec(BA_OS) describes.  This isn't always true, though, because
49  *     ANSI C does not define environ.  Thus, an ANSI C-conforming
50  *     application can define its own environ symbol, unrelated to the pro-
51  *     cess environment.  If the application defines environ and intends it
52  *     to have the System V Interface Definition, Third Edition semantics, it
53  *     must also define _environ so that the two symbols refer to the same
54  *     data object.
55  *
56  * The ABI description implies that the process environment should use
57  * _environ and that nothing in libc should make reference to the unadorned
58  * "environ" symbol.  This way, an application can define and use a symbol
59  * named "environ" for its own purposes without affecting the actual
60  * process environment.
61  */
62 
63 #pragma weak environ = _environ
64 const char **_environ = 0;
65