hotspot/makefiles/lib/JvmMapfile.gmk
changeset 37437 f824aabc7af8
equal deleted inserted replaced
37436:1d902bc02bc2 37437:f824aabc7af8
       
     1 #
       
     2 # Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4 #
       
     5 # This code is free software; you can redistribute it and/or modify it
       
     6 # under the terms of the GNU General Public License version 2 only, as
       
     7 # published by the Free Software Foundation.  Oracle designates this
       
     8 # particular file as subject to the "Classpath" exception as provided
       
     9 # by Oracle in the LICENSE file that accompanied this code.
       
    10 #
       
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14 # version 2 for more details (a copy is included in the LICENSE file that
       
    15 # accompanied this code).
       
    16 #
       
    17 # You should have received a copy of the GNU General Public License version
       
    18 # 2 along with this work; if not, write to the Free Software Foundation,
       
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20 #
       
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22 # or visit www.oracle.com if you need additional information or have any
       
    23 # questions.
       
    24 #
       
    25 
       
    26 $(eval $(call IncludeCustomExtension, hotspot, lib/JvmMapfile.gmk))
       
    27 
       
    28 ################################################################################
       
    29 # Combine a list of static symbols
       
    30 
       
    31 ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86_64)
       
    32   # On Windows x86_64, we should not have any symbols at all, since that
       
    33   # results in duplicate warnings from the linker (JDK-8043491).
       
    34   SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-shared
       
    35 endif
       
    36 
       
    37 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
       
    38   SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-unix
       
    39 endif
       
    40 
       
    41 ifneq ($(wildcard $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)), )
       
    42   SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)
       
    43 endif
       
    44 
       
    45 ifneq ($(findstring debug, $(DEBUG_LEVEL)), )
       
    46   ifneq ($(wildcard $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)-debug), )
       
    47     SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)-debug
       
    48   endif
       
    49 endif
       
    50 
       
    51 ifeq ($(OPENJDK_TARGET_OS), solaris)
       
    52   ifeq ($(call check-jvm-feature, dtrace), true)
       
    53     # Additional mapfiles that are only used when dtrace is enabled
       
    54     ifeq ($(call check-jvm-feature, compiler2), true)
       
    55       # This also covers the case of compiler1+compiler2.
       
    56       SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-solaris-dtrace-compiler2
       
    57     else ifeq ($(call check-jvm-feature, compiler1), true)
       
    58       SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-solaris-dtrace-compiler1
       
    59     endif
       
    60   endif
       
    61 endif
       
    62 
       
    63 ################################################################################
       
    64 # Create a dynamic list of symbols from the built object files. This is highly
       
    65 # platform dependent.
       
    66 
       
    67 ifeq ($(OPENJDK_TARGET_OS), linux)
       
    68   DUMP_SYMBOLS_CMD := $(NM) --defined-only *.o
       
    69   ifneq ($(FILTER_SYMBOLS_PATTERN), )
       
    70     FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|
       
    71   endif
       
    72   FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)^_ZTV|^gHotSpotVM|^UseSharedSpaces$$
       
    73   FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|^_ZN9Arguments17SharedArchivePathE$$
       
    74   FILTER_SYMBOLS_AWK_SCRIPT := \
       
    75       '{ \
       
    76         if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \
       
    77       }'
       
    78 
       
    79 else ifeq ($(OPENJDK_TARGET_OS), solaris)
       
    80   DUMP_SYMBOLS_CMD := $(NM) -p *.o
       
    81   ifneq ($(FILTER_SYMBOLS_PATTERN), )
       
    82     FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|
       
    83   endif
       
    84   FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)^__1c.*__vtbl_$$|^gHotSpotVM
       
    85   FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|^UseSharedSpaces$$
       
    86   FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|^__1cJArgumentsRSharedArchivePath_$$
       
    87   FILTER_SYMBOLS_AWK_SCRIPT := \
       
    88       '{ \
       
    89         if ($$2 == "U") next; \
       
    90         if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \
       
    91       }'
       
    92 
       
    93 else ifeq ($(OPENJDK_TARGET_OS), macosx)
       
    94   # nm on macosx prints out "warning: nm: no name list" to stderr for
       
    95   # files without symbols. Hide this, even at the expense of hiding real errors.
       
    96   DUMP_SYMBOLS_CMD := $(NM) -Uj *.o 2> /dev/null
       
    97   ifneq ($(FILTER_SYMBOLS_PATTERN), )
       
    98     FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)|
       
    99   endif
       
   100   FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)^_ZTV|^gHotSpotVM
       
   101   FILTER_SYMBOLS_AWK_SCRIPT := \
       
   102       '{ \
       
   103         if ($$3 ~ /$(FILTER_SYMBOLS_PATTERN)/) print $$3; \
       
   104       }'
       
   105 
       
   106 # NOTE: The script is from the old build. It is broken and finds no symbols.
       
   107 # The script below might be what was intended, but it failes to link with tons
       
   108 # of 'cannot export hidden symbol vtable for X'.
       
   109 #  '{ if ($$1 ~ /^__ZTV/ || $$1 ~ /^_gHotSpotVM/) print substr($$1, 2) }'
       
   110 else ifeq ($(OPENJDK_TARGET_OS), aix)
       
   111   # NOTE: The old build had the solution below. This should to be fixed in
       
   112   # configure instead.
       
   113 
       
   114   # On AIX we have to prevent that we pick up the 'nm' version from the GNU binutils
       
   115   # which may be installed under /opt/freeware/bin. So better use an absolute path here!
       
   116   # NM=/usr/bin/nm
       
   117 
       
   118   DUMP_SYMBOLS_CMD := $(NM) -X64 -B -C *.o
       
   119   FILTER_SYMBOLS_AWK_SCRIPT := \
       
   120       '{ \
       
   121         if (($$2="d" || $$2="D") && ($$3 ~ /^__vft/ || $$3 ~ /^gHotSpotVM/)) print $$3; \
       
   122         if ($$3 ~ /^UseSharedSpaces$$/) print $$3; \
       
   123         if ($$3 ~ /^SharedArchivePath__9Arguments$$/) print $$3; \
       
   124        }'
       
   125 
       
   126 else ifeq ($(OPENJDK_TARGET_OS), windows)
       
   127   DUMP_SYMBOLS_CMD := $(DUMPBIN) -symbols *.obj
       
   128   FILTER_SYMBOLS_AWK_SCRIPT := \
       
   129       '{ \
       
   130         if ($$7 ~ /??_7.*@@6B@/ && $$7 !~ /type_info/) print $$7; \
       
   131       }'
       
   132 
       
   133 else
       
   134   $(error Unknown target OS $(OPENJDK_TARGET_OS) in JvmMapfile.gmk)
       
   135 endif
       
   136 
       
   137 # A more correct solution would be to send BUILD_LIBJVM_ALL_OBJS instead of
       
   138 # cd && *.o, but this will result in very long command lines, which is
       
   139 # problematic on some platforms.
       
   140 $(JVM_OUTPUTDIR)/symbols-objects: $(BUILD_LIBJVM_ALL_OBJS)
       
   141 	$(call LogInfo, Generating symbol list from object files)
       
   142 	$(CD) $(JVM_OUTPUTDIR)/objs && \
       
   143 	  $(DUMP_SYMBOLS_CMD) | $(NAWK) $(FILTER_SYMBOLS_AWK_SCRIPT) | $(SORT) -u > $@
       
   144 
       
   145 SYMBOLS_SRC += $(JVM_OUTPUTDIR)/symbols-objects
       
   146 
       
   147 ################################################################################
       
   148 # Now concatenate all symbol lists into a single file and remove comments.
       
   149 
       
   150 $(JVM_OUTPUTDIR)/symbols: $(SYMBOLS_SRC)
       
   151 	$(SED) -e '/^#/d' $^ > $@
       
   152 
       
   153 ################################################################################
       
   154 # Finally convert the symbol list into a platform-specific mapfile
       
   155 
       
   156 $(JVM_MAPFILE): $(JVM_OUTPUTDIR)/symbols
       
   157 	$(call LogInfo, Creating mapfile)
       
   158 	$(RM) $@
       
   159         ifeq ($(OPENJDK_TARGET_OS), macosx)
       
   160           # On macosx, we need to add a leading underscore
       
   161 	  $(AWK) '{ if ($$0 ~ ".") { print "  _" $$0 } }'  < $^ > $@.tmp
       
   162         else ifeq ($(OPENJDK_TARGET_OS), windows)
       
   163           # On windows, add an 'EXPORTS' header
       
   164 	  $(ECHO) "EXPORTS" > $@.tmp
       
   165 	  $(AWK) '{ if ($$0 ~ ".") { print "  " $$0 } }'  < $^ >> $@.tmp
       
   166         else
       
   167           # Assume standard linker script
       
   168 	  $(PRINTF) "SUNWprivate_1.1 { \n  global: \n" > $@.tmp
       
   169 	  $(AWK) '{ if ($$0 ~ ".") { print "    " $$0 ";" } }' < $^ >> $@.tmp
       
   170 	  $(PRINTF) "  local: \n    *; \n }; \n" >> $@.tmp
       
   171         endif
       
   172 	$(MV) $@.tmp $@