|
1 # 1. Enable the linker map files provided by clang/llvm for symbol |
|
2 # scope and visibility in shared libraries. |
|
3 # 2. We must use our own linker map file for compatibility with |
|
4 # the GNU linkers and GNU Binutils (libbfd). |
|
5 # Solaris autoconf-based build. |
|
6 # https://llvm.org/bugs/show_bug.cgi?id=24641 |
|
7 --- Makefile.rules 2015-07-17 19:12:32.515872699 -0700 |
|
8 +++ Makefile.rules 2015-07-17 19:17:40.294355307 -0700 |
|
9 @@ -643,6 +643,7 @@ |
|
10 endif |
|
11 ifeq ($(HOST_OS), $(filter $(HOST_OS), SunOS)) |
|
12 LD.Flags += -Wl,-z -Wl,discard-unused=sections |
|
13 + LD.Flags += -Wl,-M -Wl,$(PROJ_SRC_ROOT)/mapfiles/map.gnu-sections |
|
14 endif |
|
15 endif |
|
16 endif |
|
17 @@ -655,6 +656,10 @@ |
|
18 ifneq ($(HOST_OS), Darwin) |
|
19 ifdef TOOLNAME |
|
20 LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib' |
|
21 + ifeq ($(HOST_OS), $(filter $(HOST_OS), SunOS)) |
|
22 + LD.Flags += -Wl,-z -Wl,discard-unused=sections |
|
23 + LD.Flags += -Wl,-M -Wl,$(PROJ_SRC_ROOT)/mapfiles/map.gnu-sections |
|
24 + endif |
|
25 endif |
|
26 else |
|
27 ifneq ($(DARWIN_MAJVERS),4) |
|
28 @@ -1122,11 +1127,26 @@ |
|
29 clean-local:: |
|
30 -$(Verb) $(RM) -f $(NativeExportsFile) |
|
31 else |
|
32 +ifeq ($(HOST_OS), $(filter $(HOST_OS), SunOS)) |
|
33 +# Solaris ld requires a version script rather than a plain list. |
|
34 +NativeExportsFile := $(ObjDir)/$(notdir $(EXPORTED_SYMBOL_FILE)).map |
|
35 +$(NativeExportsFile): $(EXPORTED_SYMBOL_FILE) $(ObjDir)/.dir |
|
36 + $(Verb) echo "{" > $@ |
|
37 + $(Verb) grep -q '[[:alnum:]_]' $< && echo " global:" >> $@ || : |
|
38 + $(Verb) sed -e 's/$$/;/' -e 's/^/ /' < $< >> $@ |
|
39 +ifneq ($(HOST_OS),OpenBSD) |
|
40 + $(Verb) echo " local: *;" >> $@ |
|
41 +endif |
|
42 + $(Verb) echo "};" >> $@ |
|
43 +clean-local:: |
|
44 + -$(Verb) $(RM) -f $(NativeExportsFile) |
|
45 +else |
|
46 # Default behavior: just use the exports file verbatim. |
|
47 NativeExportsFile := $(EXPORTED_SYMBOL_FILE) |
|
48 endif |
|
49 endif |
|
50 endif |
|
51 +endif |
|
52 |
|
53 # Now add the linker command-line options to use the native export file. |
|
54 |
|
55 @@ -1146,6 +1166,11 @@ |
|
56 SharedLinkOptions += $(NativeExportsFile) |
|
57 endif |
|
58 |
|
59 +# Solaris |
|
60 +ifeq ($(HOST_OS), $(filter $(HOST_OS), SunOS)) |
|
61 +LLVMLibsOptions += -Wl,-M -Wl,$(NativeExportsFile) |
|
62 +endif |
|
63 + |
|
64 endif |
|
65 |
|
66 ############################################################################### |
|
67 --- /dev/null 2015-07-08 19:15:05.000000000 -0700 |
|
68 +++ mapfiles/map.gnu-sections 2015-07-08 19:13:41.905920797 -0700 |
|
69 @@ -0,0 +1,61 @@ |
|
70 +$mapfile_version 2 |
|
71 + |
|
72 +# Emulate the rules used by the GNU ld and gold linkers for merging input |
|
73 +# sections into output sections in executables and shared objects. From |
|
74 +# Ian Lance Taylor and Cary Coutant. |
|
75 + |
|
76 +# gcc 4.3 generates the following sorts of section names when it |
|
77 +# needs a section name specific to a function: |
|
78 +# .text.FN |
|
79 +# .rodata.FN |
|
80 +# .sdata2.FN |
|
81 +# .data.FN |
|
82 +# .data.rel.FN |
|
83 +# .data.rel.local.FN |
|
84 +# .data.rel.ro.FN |
|
85 +# .data.rel.ro.local.FN |
|
86 +# .sdata.FN |
|
87 +# .bss.FN |
|
88 +# .sbss.FN |
|
89 +# .tdata.FN |
|
90 +# .tbss.FN |
|
91 +# |
|
92 +# The GNU linker maps all of those to the part before the .FN, |
|
93 +# except that .data.rel.local.FN is mapped to .data, and |
|
94 +# .data.rel.ro.local.FN is mapped to .data.rel.ro. The sections |
|
95 +# beginning with .data.rel.ro.local are grouped together. |
|
96 +# |
|
97 +# For an anonymous namespace, the string FN can contain a '.'. |
|
98 +# |
|
99 +# Also of interest: .rodata.strN.N, .rodata.cstN, both of which the |
|
100 +# GNU linker maps to .rodata. |
|
101 + |
|
102 +$if _ET_DYN || _ET_EXEC |
|
103 + |
|
104 +LOAD_SEGMENT text { |
|
105 + ASSIGN_SECTION { |
|
106 + IS_NAME = MATCH(g/.data.rel.local.*/); |
|
107 + FLAGS = ALLOC !WRITE; |
|
108 + OUTPUT_SECTION { NAME = .data }; |
|
109 + }; |
|
110 + ASSIGN_SECTION { |
|
111 + IS_NAME = MATCH(r/^\.(text|rodata|sdata2|data\.rel\.ro|data\.rel|data|sdata|bss|sbss|tdata|tbss)\./); |
|
112 + FLAGS = ALLOC !WRITE; |
|
113 + OUTPUT_SECTION { NAME = MATCHREF(/.${n1}/) }; |
|
114 + }; |
|
115 +}; |
|
116 + |
|
117 +LOAD_SEGMENT data { |
|
118 + ASSIGN_SECTION { |
|
119 + IS_NAME = MATCH(g/.data.rel.local.*/); |
|
120 + FLAGS = ALLOC WRITE; |
|
121 + OUTPUT_SECTION { NAME = .data }; |
|
122 + }; |
|
123 + ASSIGN_SECTION { |
|
124 + IS_NAME = MATCH(r/^\.(text|rodata|sdata2|data\.rel\.ro|data\.rel|data|sdata|bss|sbss|tdata|tbss)\./); |
|
125 + FLAGS = ALLOC WRITE; |
|
126 + OUTPUT_SECTION { NAME = MATCHREF(/.${n1}/) }; |
|
127 + }; |
|
128 +}; |
|
129 + |
|
130 +$endif |