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