6975326: Problem in install/make/rebase/Makefile, grep on empty pattern
authorohair
Wed, 05 Jan 2011 14:28:58 -0800
changeset 8008 753c38f4af83
parent 7683 aa894c225b1a
child 8009 faa3179b2b38
child 8011 90caa43175fd
6975326: Problem in install/make/rebase/Makefile, grep on empty pattern 6413588: Add 'ldd -r' and 'dump -Lv' checks to all .so files delivered in the JDK 7000995: Add check in makefiles to verify that msvcp100.dll is NOT used Reviewed-by: mduigou
jdk/make/com/sun/java/pack/Makefile
jdk/make/common/Demo.gmk
jdk/make/common/Library.gmk
jdk/make/common/Program.gmk
jdk/make/common/Release.gmk
jdk/make/common/shared/Compiler-msvc.gmk
jdk/make/common/shared/Defs-linux.gmk
jdk/make/common/shared/Defs-solaris.gmk
jdk/make/common/shared/Defs-utils.gmk
jdk/make/common/shared/Defs-windows.gmk
jdk/make/common/shared/Sanity-Settings.gmk
jdk/make/common/shared/Sanity.gmk
jdk/make/java/redist/Makefile
--- a/jdk/make/com/sun/java/pack/Makefile	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/com/sun/java/pack/Makefile	Wed Jan 05 14:28:58 2011 -0800
@@ -155,6 +155,7 @@
 	$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
 endif
 	$(CP) $(TEMPDIR)/unpack200$(EXE_SUFFIX) $(UNPACK_EXE)
+	@$(call binary_file_verification,$@)
 	$(install-module-file)
 
 ifeq ($(PLATFORM), windows) 
--- a/jdk/make/common/Demo.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/Demo.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -289,6 +289,7 @@
 	@$(prep-target)
 	$(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \
 	    $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
+	@$(call binary_file_verification,$@)
 
   # Generation of any javah include file, make sure objects are dependent on it
   ifdef DEMO_NATIVECLASS
--- a/jdk/make/common/Library.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/Library.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -173,6 +173,7 @@
 	$(MT) /manifest $(OBJDIR)/$(@F).manifest /outputresource:$(OBJDIR)/$(@F);#2
 endif
 	$(CP) $(OBJDIR)/$(@F) $@
+	@$(call binary_file_verification,$@)
 	$(install-module-file)
 	$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
 	$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
@@ -239,6 +240,7 @@
 	$(AR) -r $@ $(FILES_o)
 else # LIBRARY
 	$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
+	@$(call binary_file_verification,$@)
 	$(install-module-file)
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
--- a/jdk/make/common/Program.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/Program.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -155,6 +155,7 @@
 ifdef MT
 	$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
 endif
+	@$(call binary_file_verification,$@)
 
 else # PLATFORM
 
@@ -179,6 +180,7 @@
 	@$(MKDIR) -p $(TEMPDIR)
 	$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
 	    $(FILES_o) $(THREADLIBS) $(LDLIBS)
+	@$(call binary_file_verification,$@)
 	$(install-module-file)
 
 endif # PLATFORM
--- a/jdk/make/common/Release.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/Release.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -836,11 +836,14 @@
   endif
 endif # PLATFORM
 
-# Get list of all Elf files in the jre
-JRE_ELF_LIST=$(TEMPDIR)/jre-elf-files.list
-$(JRE_ELF_LIST):
-ifneq ($(PLATFORM), windows)
+# Get list of all binary (COFF or Elf) files in the jre
+JRE_BIN_LIST=$(TEMPDIR)/jre-bin-files.list
+$(JRE_BIN_LIST):
 	$(RM) $@
+ifeq ($(PLATFORM), windows)
+	$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*.exe \
+	   -o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
+else
 	$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
 	$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
@@ -848,9 +851,9 @@
 
 # Post process the image (strips and mcs on Elf files we are shipping)
 #   (Note the jdk WILL want the jre image before this processing)
-process-image-jre:: $(JRE_ELF_LIST)
+process-image-jre:: $(JRE_BIN_LIST)
 ifneq ($(POST_STRIP_PROCESS), )
-	for f in `$(CAT) $(JRE_ELF_LIST)`; do \
+	@for f in `$(CAT) $(JRE_BIN_LIST)`; do \
 	  $(CHMOD) u+w $${f}; \
 	  $(ECHO) $(POST_STRIP_PROCESS) $${f}; \
 	  $(POST_STRIP_PROCESS) $${f}; \
@@ -858,14 +861,17 @@
 	done
 endif
 ifneq ($(POST_MCS_PROCESS), )
-	for f in `$(CAT) $(JRE_ELF_LIST)`; do \
+	@for f in `$(CAT) $(JRE_BIN_LIST)`; do \
 	  $(CHMOD) u+w $${f}; \
 	  $(ECHO) $(POST_MCS_PROCESS) $${f}; \
 	  $(POST_MCS_PROCESS) $${f}; \
 	  $(CHMOD) go-w $${f}; \
 	done
 endif
-	$(RM) $(JRE_ELF_LIST)
+	@for f in `$(CAT) $(JRE_BIN_LIST)`; do \
+	  $(call binary_file_verification,$${f}); \
+	done
+	$(RM) $(JRE_BIN_LIST)
 
 ######################################################
 # JDK Image
@@ -1093,10 +1099,15 @@
 		  $(JDK_IMAGE_DIR)/bin/*/native_threads/$${t}$(EXE_SUFFIX); \
 	done
 
-# Get list of Elf files in the jdk
-JDK_ELF_LIST=$(TEMPDIR)/jdk-elf-files.list
-$(JDK_ELF_LIST):
-ifneq ($(PLATFORM), windows)
+# Get list of binary (COFF or Elf) files in the jdk
+JDK_BIN_LIST=$(TEMPDIR)/jdk-bin-files.list
+$(JDK_BIN_LIST):
+ifeq ($(PLATFORM), windows)
+	$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*.exe \
+	   -o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
+	$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*.exe \
+	   -o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" >> $@
+else
 	$(RM) $@
 	$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
 	$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
@@ -1106,9 +1117,9 @@
 endif
 
 # Post process the image (strips and mcs on files we are shipping)
-process-image-jdk:: $(JDK_ELF_LIST)
+process-image-jdk:: $(JDK_BIN_LIST)
 ifneq ($(POST_STRIP_PROCESS), )
-	for f in `$(CAT) $(JDK_ELF_LIST)`; do \
+	@for f in `$(CAT) $(JDK_BIN_LIST)`; do \
 	  $(CHMOD) u+w $${f}; \
 	  $(ECHO) $(POST_STRIP_PROCESS) $${f}; \
 	  $(POST_STRIP_PROCESS) $${f}; \
@@ -1116,14 +1127,17 @@
 	done
 endif
 ifneq ($(POST_MCS_PROCESS), )
-	for f in `$(CAT) $(JDK_ELF_LIST)`; do \
+	@for f in `$(CAT) $(JDK_BIN_LIST)`; do \
 	  $(CHMOD) u+w $${f}; \
 	  $(ECHO) $(POST_MCS_PROCESS) $${f}; \
 	  $(POST_MCS_PROCESS) $${f}; \
 	  $(CHMOD) go-w $${f}; \
 	done
 endif
-	$(RM) $(JDK_ELF_LIST)
+	@for f in `$(CAT) $(JDK_BIN_LIST)`; do \
+	  $(call binary_file_verification,$${f}); \
+	done
+	$(RM) $(JDK_BIN_LIST)
 
 ###################################################################
 # What do we compare against
--- a/jdk/make/common/shared/Compiler-msvc.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Compiler-msvc.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -35,6 +35,7 @@
   LIBEXE       = $(COMPILER_PATH)lib
   LINK         = $(COMPILER_PATH)link
   LINK32       = $(LINK)
+  DUMPBIN      = $(COMPILER_PATH)dumpbin.exe
  
   # Fill in unknown values
   COMPILER_NAME=Unknown MSVC Compiler
@@ -139,8 +140,8 @@
         _OTHER_TOOLS_BIN = $(WINDOWSSDKDIR)/Bin/x64
       endif
     endif
-    RC     = $(_OTHER_TOOLS_BIN)/rc.exe
-    REBASE = $(_OTHER_TOOLS_BIN)/rebase.exe
+    RC     = $(_OTHER_TOOLS_BIN)/RC.Exe
+    REBASE = $(_OTHER_TOOLS_BIN)/ReBase.Exe
     MT     = $(_OTHER_TOOLS_BIN)/mt.exe
     MTL    = $(_OTHER_TOOLS_BIN)/midl.exe
   endif
--- a/jdk/make/common/shared/Defs-linux.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Defs-linux.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -177,3 +177,20 @@
 endif
 HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)
 
+# Special define for checking the binaries
+
+# Macro to check it's input file for banned dependencies and verify the
+#   binary built properly. Relies on process exit code.
+define binary_file_verification # binary_file
+( \
+  $(ECHO) "Checking for mapfile use in: $1" && \
+  if [ "`$(NM) -D -g --defined-only $1 | $(EGREP) 'SUNWprivate'`" = "" ] ; then \
+    $(ECHO) "WARNING: File was not built with a mapfile: $1"; \
+  fi && \
+  $(ECHO) "Library loads for: $1" && \
+  $(LDD) $1 && \
+  $(ECHO) "RUNPATH for: $1" && \
+  ( $(READELF) -d $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
+)
+endef
+
--- a/jdk/make/common/shared/Defs-solaris.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Defs-solaris.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -186,3 +186,20 @@
 endif
 HOTSPOT_SERVER_PATH:=$(call AltCheckValue,HOTSPOT_SERVER_PATH)
 
+# Special define for checking the binaries
+
+# Macro to check it's input file for banned dependencies and verify the
+#   binary built properly. Relies on process exit code.
+define binary_file_verification # binary_file
+( \
+  $(ECHO) "Checking for mapfile use in: $1" && \
+  if [ "`$(NM) -g -D $1 | $(EGREP) -v 'UNDEF' | $(EGREP) 'SUNWprivate'`" = "" ] ; then \
+    $(ECHO) "WARNING: File was not built with a mapfile: $1"; \
+  fi && \
+  $(ECHO) "Library loads for: $1" && \
+  $(LDD) $1 && \
+  $(ECHO) "RUNPATH for: $1" && \
+  ( $(DUMP) -L -v $1 | $(EGREP) 'NEEDED|RUNPATH|RPATH' ) \
+)
+endef
+
--- a/jdk/make/common/shared/Defs-utils.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Defs-utils.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -85,6 +85,7 @@
 DF             = $(UTILS_COMMAND_PATH)df
 DIFF           = $(UTILS_USR_BIN_PATH)diff
 DIRNAME        = $(UTILS_USR_BIN_PATH)dirname
+DUMP           = $(UTILS_CCS_BIN_PATH)dump
 ECHO           = $(UTILS_COMMAND_PATH)echo
 EGREP          = $(UTILS_COMMAND_PATH)egrep
 EXPR           = $(UTILS_USR_BIN_PATH)expr
@@ -99,6 +100,7 @@
 ISAINFO        = $(UTILS_COMMAND_PATH)isainfo
 KSH            = $(UTILS_COMMAND_PATH)ksh
 LD             = $(UTILS_CCS_BIN_PATH)ld
+LDD            = $(UTILS_USR_BIN_PATH)ldd
 LEX            = $(UTILS_CCS_BIN_PATH)lex
 LN             = $(UTILS_COMMAND_PATH)ln
 LS             = $(UTILS_COMMAND_PATH)ls
@@ -114,6 +116,7 @@
 PRINTF         = $(UTILS_USR_BIN_PATH)printf
 PWD            = $(UTILS_COMMAND_PATH)pwd
 RC             = $(UTILS_COMMAND_PATH)rc
+READELF        = $(UTILS_USR_BIN_PATH)readelf
 RMDIR          = $(UTILS_COMMAND_PATH)rmdir
 RPM            = $(UTILS_COMMAND_PATH)rpm
 RPMBUILD       = $(UTILS_COMMAND_PATH)rpmbuild
--- a/jdk/make/common/shared/Defs-windows.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Defs-windows.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -798,3 +798,50 @@
 endif
 HOTSPOT_LIB_PATH:=$(call AltCheckSpaces,HOTSPOT_LIB_PATH)
 HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
+
+# Special define for checking the binaries
+
+ifeq ($(VS2010_EXISTS),true)
+
+# All windows dll and exe files should have been built with /NXCOMPAT
+#   and be setup for dynamic base addresses.
+#   In addition, we should not be dependent on certain dll files that
+#   we do not or cannot redistribute.
+
+# List of filenames we should NOT be dependent on
+BANNED_DLLS=msvcp100[.]dll|msvcr100d[.]dll|msvcrtd[.]dll
+
+# Macro to check it's input file for banned dependencies and verify the
+#   binary was built properly. Relies on process exit code.
+define binary_file_verification # binary_file
+( \
+  $(ECHO) "Checking for /NXCOMPAT usage in: $1" && \
+  if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'NX compatible'`" = "" ] ; then \
+    $(ECHO) "ERROR: Did not find 'NX compatible' in headers: $1" ; \
+    $(DUMPBIN) /headers $1 ; \
+    exit 7 ; \
+  fi ; \
+  $(ECHO) "Checking for /DYNAMICBASE usage in: $1" && \
+  if [ "`$(DUMPBIN) /headers $1 | $(EGREP) -i 'Dynamic base'`" = "" ] ; then \
+    $(ECHO) "ERROR: Did not find 'Dynamic base' in headers: $1" ; \
+    $(DUMPBIN) /headers $1 ; \
+    exit 8 ; \
+  fi ; \
+  $(ECHO) "Checking for banned dependencies in: $1" && \
+  if [ "`$(DUMPBIN) /dependents $1 | $(EGREP) -i '$(BANNED_DLLS)'`" != "" ] ; then \
+    $(ECHO) "ERROR: Found us of $(BANNED_DLLS)"; \
+    $(DUMPBIN) /dependents $1 ; \
+    exit 9 ; \
+  fi ; \
+)
+endef
+
+else
+
+# Macro to check it's input file for banned dependencies and verify the
+#   binary was built properly. Relies on process exit code.
+define binary_file_verification # binary_file
+endef
+
+endif
+
--- a/jdk/make/common/shared/Sanity-Settings.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Sanity-Settings.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -117,6 +117,9 @@
 ALL_SETTINGS+=$(call addRequiredVersionSetting,UNZIP_VER)
 ifeq ($(PLATFORM),windows)
   ALL_SETTINGS+=$(call addRequiredVersionSetting,LINK_VER)
+  ALL_SETTINGS+=$(call addRequiredSetting,CC)
+  ALL_SETTINGS+=$(call addRequiredSetting,LINK)
+  ALL_SETTINGS+=$(call addRequiredSetting,DUMPBIN)
 endif
 ALL_SETTINGS+=$(call addRequiredVersionSetting,ANT_VER)
 ALL_SETTINGS+=$(call addRequiredSetting,TEMPDIR)
@@ -226,6 +229,8 @@
   ALL_SETTINGS+=$(call addAltSetting,DXSDK_INCLUDE_PATH)
   ALL_SETTINGS+=$(call addAltSetting,DXSDK_LIB_PATH)
   ALL_SETTINGS+=$(call addAltSetting,WINDOWSSDKDIR)
+  ALL_SETTINGS+=$(call addRequiredSetting,RC)
+  ALL_SETTINGS+=$(call addRequiredSetting,REBASE)
   ifndef OPENJDK
     ALL_SETTINGS+=$(call addAltSetting,DEPLOY_MSSDK)
     ALL_SETTINGS+=$(call addAltSetting,INSTALL_MSSDK)
--- a/jdk/make/common/shared/Sanity.gmk	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/common/shared/Sanity.gmk	Wed Jan 05 14:28:58 2011 -0800
@@ -1018,6 +1018,22 @@
 	    "      and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \
 	    "" >> $(ERROR_FILE) ; \
 	fi
+  else
+    ifeq ($(wildcard $(REBASE)),)
+	@$(ECHO) "ERROR: Cannot find the REBASE utility from path: $(REBASE)\n" \
+	    "      This is normally obtained from the WINDOWSSDKDIR." \
+	    "" >> $(ERROR_FILE)
+    endif
+    ifeq ($(wildcard $(RC)),)
+	@$(ECHO) "ERROR: Cannot find the RC utility from path: $(RC)\n" \
+	    "      This is normally obtained from the WINDOWSSDKDIR." \
+	    "" >> $(ERROR_FILE)
+    endif
+    ifeq ($(wildcard $(DUMPBIN)),)
+	@$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \
+	    "      This is normally obtained from the WINDOWSSDKDIR." \
+	    "" >> $(ERROR_FILE)
+    endif
   endif
 endif
 
--- a/jdk/make/java/redist/Makefile	Wed Jul 05 17:31:10 2017 +0200
+++ b/jdk/make/java/redist/Makefile	Wed Jan 05 14:28:58 2011 -0800
@@ -223,12 +223,15 @@
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVM_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVM_NAME): $(HOTSPOT_KERNEL_PATH)/$(JVM_NAME)
 	$(install-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(LIBJSIG_NAME): $(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/$(LIBJSIG_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) \
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(LIBJSIG_NAME):
@@ -237,30 +240,39 @@
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDB_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDB_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDTRACE_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAME)
 	$(install-import-file)
+	@$(call binary_file_verification,$@)
 
 $(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt : $(HOTSPOT_SERVER_PATH)/Xusage.txt
 	$(install-import-file)