Makefile revision 24da5b34f49324ed742a340010ed5bd3d4e06625
1117N/A#
1117N/A# CDDL HEADER START
1117N/A#
1117N/A# The contents of this file are subject to the terms of the
1466N/A# Common Development and Distribution License (the "License").
1117N/A# You may not use this file except in compliance with the License.
1117N/A#
1117N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1117N/A# or http://www.opensolaris.org/os/licensing.
1117N/A# See the License for the specific language governing permissions
1117N/A# and limitations under the License.
1117N/A#
1117N/A# When distributing Covered Code, include this CDDL HEADER in each
1117N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1117N/A# If applicable, add the following below this CDDL HEADER, with the
1117N/A# fields enclosed by brackets "[]" replaced with your own identifying
1117N/A# information: Portions Copyright [yyyy] [name of copyright owner]
1117N/A#
1117N/A# CDDL HEADER END
1117N/A#
1117N/A
1117N/A#
1117N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
1117N/A# Use is subject to license terms.
1117N/A#
1117N/A# ident "%Z%%M% %I% %E% SMI"
1117N/A#
1117N/A
1117N/Ainclude $(SRC)/Makefile.master
1117N/A
1117N/AFILES= \
1117N/A $(MACH)_cc_map.noexeglobs \
1117N/A $(MACH)_gcc_map.noexeglobs
1117N/A
1392N/A$(BUILD64)FILES += \
1392N/A $(MACH64)_cc_map.noexeglobs \
1392N/A $(MACH64)_gcc_map.noexeglobs
1392N/A
1392N/ASYMS1= syms.1
1392N/ASYMS2= syms.2
1392N/AMAIN1= main.1
1392N/AMAIN2= main.2
1117N/A
1117N/ATEMPLATE1= map.noexeglobs.1.template
1117N/ATEMPLATE2= map.noexeglobs.2.template
1117N/A
1117N/Aall install: $(FILES)
1117N/A
1117N/Alint:
1117N/A
1117N/Aclean:
1117N/A $(RM) $(SYMS1) $(SYMS2) $(MAIN1) $(MAIN2)
1466N/A
1466N/Aclobber: clean
1466N/A $(RM) $(FILES)
1466N/A
1117N/A# A number of dynamic executables have their own definitions of interfaces that
1117N/A# exist in system libraries. To prevent name-space pollution it is desirable
1117N/A# to demote the interfaces within these executable to locals. However, various
1117N/A# symbols defined by the compiler drivers crt/values files need to remain
1466N/A# global in any dynamic object that includes these files. These symbols
1466N/A# interpose on symbols in libc, or provide call backs for other system
1117N/A# libraries. The various compiler drivers (cc and gcc), and the crt/values
1117N/A# files that these drivers are configured to include, differ between the
1117N/A# various compilations environments (platform, 32/64-bit). Therefore, the
1466N/A# only means of creating a mapfile to demote symbols is to dynamically generate
1476N/A# the mapfile for a specific compilation environment.
1117N/A#
1425N/A# Here, template mapfiles are used to generate a number of compilation specific
1425N/A# mapfiles. These mapfiles are referenced by components of the build through
1425N/A# the MAPFILE.NGB macro defined in Makefile.master. These dynamically created
1117N/A# mapfiles are not delivered into the $ROOT area, and therefore are not
1117N/A# delivered as packaged components of the OSNet.
1117N/A
1269N/A$(MACH)_cc_map.noexeglobs := LINK = $(LINK.c)
1117N/A$(MACH64)_cc_map.noexeglobs := LINK = $(LINK64.c)
1117N/A
1117N/A$(MACH)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
1117N/A$(MACH)_gcc_map.noexeglobs := LINK = $(LINK.c)
1117N/A$(MACH64)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
1117N/A$(MACH64)_gcc_map.noexeglobs := LINK = $(LINK64.c)
1117N/A
1117N/A# This generic target creates two dynamic executables from an empty "main"
1117N/A# program. These objects are not executed, but are analyzed to determine the
1117N/A# global symbols each provides.
1117N/A#
1117N/A# The first executable demotes a family of known interfaces to local and allows
1117N/A# all other symbol definitions to remain global. This executables provides the
1117N/A# base for discovering all symbol definitions provided by the various
1117N/A# compilation environments. The second executable demotes all symbols to
1117N/A# locals. Within both executables, some symbols remain globals (_end, _etext,
1117N/A# etc.) as the link-editor has special knowledge of these symbols and their
1117N/A# expected visibility requirements. By inspecting the deferences between the
1117N/A# global symbols within the two executables, a mapfile can be generated to
1269N/A# ensure the symbols defined by the compilation environments files remain
1117N/A# global.
1392N/A
1392N/A%map.noexeglobs:main.c $(TEMPLATE1) $(TEMPLATE2)
1392N/A $(LINK) -o $(MAIN1) -M$(TEMPLATE1) main.c
1117N/A $(ELFDUMP) -s -N.dynsym $(MAIN1) | $(EGREP) "WEAK|GLOB" | \
1394N/A $(GREP) -v UNDEF | $(NAWK) '{print $$9 }' | $(SORT) > $(SYMS1)
1394N/A $(LINK) -o $(MAIN2) -M$(TEMPLATE2) main.c
1394N/A $(ELFDUMP) -s -N.dynsym $(MAIN2) | $(EGREP) "WEAK|GLOB" | \
1392N/A $(GREP) -v UNDEF | $(NAWK) '{print $$9 }' | $(SORT) > $(SYMS2)
1392N/A $(ECHO) "# GENERATED FILE - DO NOT EDIT" > $@
1392N/A $(GREP) MAP-HEAD $(TEMPLATE2) | \
1392N/A $(SED) -e "s/ *# MAP-HEAD//" >> $@
1392N/A $(DIFF) $(SYMS1) $(SYMS2) | $(GREP) "^<" | \
1392N/A $(SED) -e "s/^< \(.*\)/ \1;/" >> $@
1392N/A $(GREP) MAP-TAIL $(TEMPLATE2) | \
$(SED) -e "s/ *# MAP-TAIL//" >> $@
$(RM) $(SYMS1) $(SYMS2) $(MAIN1) $(MAIN2)