Makefile revision 24da5b34f49324ed742a340010ed5bd3d4e06625
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# CDDL HEADER START
e999539fb3e45b2617571e0e3ecd651992291701Mark Andrews# The contents of this file are subject to the terms of the
e999539fb3e45b2617571e0e3ecd651992291701Mark Andrews# Common Development and Distribution License (the "License").
2a40fdc2d34adb8a5c72a748449699666032d461Mark Andrews# You may not use this file except in compliance with the License.
a3b428812703d22a605a9f882e71ed65f0ffdc65Mark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# See the License for the specific language governing permissions
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews# and limitations under the License.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# When distributing Covered Code, include this CDDL HEADER in each
d56e188030368b835122d759ebbf8d9613c166f4Mark Andrews# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrews# If applicable, add the following below this CDDL HEADER, with the
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# fields enclosed by brackets "[]" replaced with your own identifying
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# information: Portions Copyright [yyyy] [name of copyright owner]
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# CDDL HEADER END
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Use is subject to license terms.
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# ident "%Z%%M% %I% %E% SMI"
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# A number of dynamic executables have their own definitions of interfaces that
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# exist in system libraries. To prevent name-space pollution it is desirable
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# to demote the interfaces within these executable to locals. However, various
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# symbols defined by the compiler drivers crt/values files need to remain
26a77b80bb7ee886c6fa704348d5e80a011d8811Mark Andrews# global in any dynamic object that includes these files. These symbols
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# interpose on symbols in libc, or provide call backs for other system
6f046a065e5543f8cd7e2f24991c65d2372f4c8dMark Andrews# libraries. The various compiler drivers (cc and gcc), and the crt/values
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# files that these drivers are configured to include, differ between the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# various compilations environments (platform, 32/64-bit). Therefore, the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# only means of creating a mapfile to demote symbols is to dynamically generate
62ee2c9f460d2e2e45dcf1abc8b4b4a4a43f5618Mark Andrews# the mapfile for a specific compilation environment.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Here, template mapfiles are used to generate a number of compilation specific
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# mapfiles. These mapfiles are referenced by components of the build through
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews# the MAPFILE.NGB macro defined in Makefile.master. These dynamically created
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# mapfiles are not delivered into the $ROOT area, and therefore are not
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# delivered as packaged components of the OSNet.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson$(MACH)_cc_map.noexeglobs := LINK = $(LINK.c)
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews$(MACH64)_cc_map.noexeglobs := LINK = $(LINK64.c)
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson$(MACH)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson$(MACH64)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews$(MACH64)_gcc_map.noexeglobs := LINK = $(LINK64.c)
45eca3a5d46ed15aee14d81f6cb6c9fb6f365344Mark Andrews# This generic target creates two dynamic executables from an empty "main"
80f9a970ae6681c08529ef209eaabbe078c27ca3Mark Andrews# program. These objects are not executed, but are analyzed to determine the
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# global symbols each provides.
46e873c835bf7d9ec3e1097e0aceb8db5b1ae93aMark Andrews# The first executable demotes a family of known interfaces to local and allows
dd9ad704c3800e3ab07ede8595871eac79984871Mark Andrews# all other symbol definitions to remain global. This executables provides the
605bd686e437162b5ab65ac4e7c1be0bba1886ddMark Andrews# base for discovering all symbol definitions provided by the various
45eca3a5d46ed15aee14d81f6cb6c9fb6f365344Mark Andrews# compilation environments. The second executable demotes all symbols to
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# locals. Within both executables, some symbols remain globals (_end, _etext,
ab81f57ca0c3addfec3df3babdcea9644757cf23Mark Andrews# etc.) as the link-editor has special knowledge of these symbols and their
605bd686e437162b5ab65ac4e7c1be0bba1886ddMark Andrews# expected visibility requirements. By inspecting the deferences between the
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews# global symbols within the two executables, a mapfile can be generated to
6b5c57e52ac8c3e0af1547be3140ebbfb41a85b3Mark Andrews# ensure the symbols defined by the compilation environments files remain
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews%map.noexeglobs:main.c $(TEMPLATE1) $(TEMPLATE2)
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews $(ELFDUMP) -s -N.dynsym $(MAIN1) | $(EGREP) "WEAK|GLOB" | \
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews $(GREP) -v UNDEF | $(NAWK) '{print $$9 }' | $(SORT) > $(SYMS1)
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews $(ELFDUMP) -s -N.dynsym $(MAIN2) | $(EGREP) "WEAK|GLOB" | \
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews $(GREP) -v UNDEF | $(NAWK) '{print $$9 }' | $(SORT) > $(SYMS2)