Makefile revision 7b07063d906859b2be1e88791f801b3c96e432f6
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# CDDL HEADER START
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# The contents of this file are subject to the terms of the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# Common Development and Distribution License (the "License").
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# You may not use this file except in compliance with the License.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# See the License for the specific language governing permissions
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# and limitations under the License.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# When distributing Covered Code, include this CDDL HEADER in each
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# If applicable, add the following below this CDDL HEADER, with the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# fields enclosed by brackets "[]" replaced with your own identifying
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# CDDL HEADER END
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# Use is subject to license terms.
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# A number of dynamic executables have their own definitions of interfaces that
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# exist in system libraries. To prevent name-space pollution it is desirable
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# to demote the interfaces within these executable to locals. However, various
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# symbols defined by the compiler drivers crt/values files need to remain
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# global in any dynamic object that includes these files. These symbols
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# interpose on symbols in libc, or provide call backs for other system
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# libraries. The various compiler drivers (cc and gcc), and the crt/values
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# files that these drivers are configured to include, differ between the
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# various compilations environments (platform, 32/64-bit). Therefore, the
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# only means of creating a mapfile to demote symbols is to dynamically generate
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# the mapfile for a specific compilation environment.
c8ef03d2caac857c97f629d0ddd6eba0b8eb209dvboxsync# Here, template mapfiles are used to generate a number of compilation specific
c8ef03d2caac857c97f629d0ddd6eba0b8eb209dvboxsync# mapfiles. These mapfiles are referenced by components of the build through
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# the MAPFILE.NGB macro defined in Makefile.master. These dynamically created
278468209e139ff71297898e2e5d65ea0fdf75a6vboxsync# mapfiles are not delivered into the $ROOT area, and therefore are not
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# delivered as packaged components of the OSNet.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync$(MACH64)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# This generic target creates two dynamic executables from an empty "main"
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# program. These objects are not executed, but are analyzed to determine the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# global symbols each provides.
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# The first executable demotes a family of known interfaces to local and allows
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# all other symbol definitions to remain global. This executables provides the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# base for discovering all symbol definitions provided by the various
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# compilation environments. The second executable demotes all symbols to
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# locals. Within both executables, some symbols remain globals (_end, _etext,
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# etc.) as the link-editor has special knowledge of these symbols and their
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# expected visibility requirements. By inspecting the deferences between the
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# global symbols within the two executables, a mapfile can be generated to
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync# ensure the symbols defined by the compilation environments files remain
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(ELFDUMP) -s -N.dynsym $(MAIN1) | $(EGREP) "WEAK|GLOB" | \
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(GREP) -v UNDEF | $(AWK) '{print $$9 }' | $(SORT) > $(SYMS1)
18b1f1bb3429f8bfc1a52cfaeb2445e9fb1f55cdvboxsync $(ELFDUMP) -s -N.dynsym $(MAIN2) | $(EGREP) "WEAK|GLOB" | \