Print this page
9852 enable ld(1) guidance and deflib assertions for the illumos build
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/common/mapfiles/gen/Makefile
+++ new/usr/src/common/mapfiles/gen/Makefile
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 # If applicable, add the following below this CDDL HEADER, with the
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21
22 22 #
23 23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
24 24 # Use is subject to license terms.
25 25 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
26 26 #
27 27
28 28 include $(SRC)/Makefile.master
29 29
30 30 FILES= \
31 31 $(MACH)_cc_map.noexeglobs \
32 32 $(MACH)_gcc_map.noexeglobs
33 33
34 +NATIVE_LIBS = libc.so
35 +LDFLAGS += -B direct
36 +
34 37 $(BUILD64)FILES += \
35 38 $(MACH64)_cc_map.noexeglobs \
36 39 $(MACH64)_gcc_map.noexeglobs
37 40
38 41 SYMS1= syms.1
39 42 SYMS2= syms.2
40 43 MAIN1= main.1
41 44 MAIN2= main.2
42 45
43 46 TEMPLATE1= map.noexeglobs.1.template
44 47 TEMPLATE2= map.noexeglobs.2.template
45 48
46 49 all install: $(FILES)
47 50
48 51 lint:
49 52
50 53 clean:
51 54 $(RM) $(SYMS1) $(SYMS2) $(MAIN1) $(MAIN2)
52 55
53 56 clobber: clean
54 57 $(RM) $(FILES)
55 58
56 59 # A number of dynamic executables have their own definitions of interfaces that
57 60 # exist in system libraries. To prevent name-space pollution it is desirable
58 61 # to demote the interfaces within these executable to locals. However, various
59 62 # symbols defined by the compiler drivers crt/values files need to remain
60 63 # global in any dynamic object that includes these files. These symbols
61 64 # interpose on symbols in libc, or provide call backs for other system
62 65 # libraries. The various compiler drivers (cc and gcc), and the crt/values
63 66 # files that these drivers are configured to include, differ between the
64 67 # various compilations environments (platform, 32/64-bit). Therefore, the
65 68 # only means of creating a mapfile to demote symbols is to dynamically generate
66 69 # the mapfile for a specific compilation environment.
67 70 #
68 71 # Here, template mapfiles are used to generate a number of compilation specific
69 72 # mapfiles. These mapfiles are referenced by components of the build through
70 73 # the MAPFILE.NGB macro defined in Makefile.master. These dynamically created
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
71 74 # mapfiles are not delivered into the $ROOT area, and therefore are not
72 75 # delivered as packaged components of the OSNet.
73 76
74 77 $(MACH)_cc_map.noexeglobs := LINK = $(LINK.c)
75 78 $(MACH64)_cc_map.noexeglobs := LINK = $(LINK64.c)
76 79
77 80 $(MACH)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
78 81 $(MACH)_gcc_map.noexeglobs := LINK = $(LINK.c)
79 82 $(MACH64)_gcc_map.noexeglobs := CC = $(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
80 83 $(MACH64)_gcc_map.noexeglobs := LINK = $(LINK64.c)
81 -
84 +
82 85 # This generic target creates two dynamic executables from an empty "main"
83 86 # program. These objects are not executed, but are analyzed to determine the
84 87 # global symbols each provides.
85 88 #
86 89 # The first executable demotes a family of known interfaces to local and allows
87 90 # all other symbol definitions to remain global. This executables provides the
88 91 # base for discovering all symbol definitions provided by the various
89 92 # compilation environments. The second executable demotes all symbols to
90 93 # locals. Within both executables, some symbols remain globals (_end, _etext,
91 94 # etc.) as the link-editor has special knowledge of these symbols and their
92 95 # expected visibility requirements. By inspecting the deferences between the
93 96 # global symbols within the two executables, a mapfile can be generated to
94 97 # ensure the symbols defined by the compilation environments files remain
95 98 # global.
96 99
97 100 %map.noexeglobs:main.c $(TEMPLATE1) $(TEMPLATE2)
98 101 $(LINK) -o $(MAIN1) -M$(TEMPLATE1) main.c
99 102 $(ELFDUMP) -s -N.dynsym $(MAIN1) | $(EGREP) "WEAK|GLOB" | \
100 103 $(GREP) -v UNDEF | $(AWK) '{print $$9 }' | $(SORT) > $(SYMS1)
101 104 $(LINK) -o $(MAIN2) -M$(TEMPLATE2) main.c
102 105 $(ELFDUMP) -s -N.dynsym $(MAIN2) | $(EGREP) "WEAK|GLOB" | \
103 106 $(GREP) -v UNDEF | $(AWK) '{print $$9 }' | $(SORT) > $(SYMS2)
104 107 $(ECHO) "# GENERATED FILE - DO NOT EDIT" > $@
105 108 $(GREP) MAP-HEAD $(TEMPLATE2) | \
106 109 $(SED) -e "s/ *# MAP-HEAD//" >> $@
107 110 $(DIFF) $(SYMS1) $(SYMS2) | $(GREP) "^<" | \
108 111 $(SED) -e "s/^< \(.*\)/ \1;/" >> $@
109 112 $(GREP) MAP-TAIL $(TEMPLATE2) | \
110 113 $(SED) -e "s/ *# MAP-TAIL//" >> $@
111 114 $(RM) $(SYMS1) $(SYMS2) $(MAIN1) $(MAIN2)
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX