From c2b6c324771abe0d1943ce063a0cd24505ad3d27 Mon Sep 17 00:00:00 2001 From: ohair Date: Wed, 5 Jan 2011 14:28:58 -0800 Subject: [PATCH] 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 --- make/com/sun/java/pack/Makefile | 1 + make/common/Demo.gmk | 1 + make/common/Library.gmk | 2 ++ make/common/Program.gmk | 2 ++ make/common/Release.gmk | 46 ++++++++++++++++--------- make/common/shared/Compiler-msvc.gmk | 5 +-- make/common/shared/Defs-linux.gmk | 17 ++++++++++ make/common/shared/Defs-solaris.gmk | 17 ++++++++++ make/common/shared/Defs-utils.gmk | 3 ++ make/common/shared/Defs-windows.gmk | 47 ++++++++++++++++++++++++++ make/common/shared/Sanity-Settings.gmk | 5 +++ make/common/shared/Sanity.gmk | 16 +++++++++ make/java/redist/Makefile | 12 +++++++ 13 files changed, 156 insertions(+), 18 deletions(-) diff --git a/make/com/sun/java/pack/Makefile b/make/com/sun/java/pack/Makefile index 6b5b0bfc2..e7fe8d44b 100644 --- a/make/com/sun/java/pack/Makefile +++ b/make/com/sun/java/pack/Makefile @@ -155,6 +155,7 @@ ifdef MT $(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) diff --git a/make/common/Demo.gmk b/make/common/Demo.gmk index 0ba5bc197..3824598d7 100644 --- a/make/common/Demo.gmk +++ b/make/common/Demo.gmk @@ -289,6 +289,7 @@ $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS) @$(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 diff --git a/make/common/Library.gmk b/make/common/Library.gmk index 717582756..4ed368b41 100644 --- a/make/common/Library.gmk +++ b/make/common/Library.gmk @@ -173,6 +173,7 @@ ifdef MT $(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 @@ ifeq ($(LIBRARY), fdlibm) $(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)" $@ diff --git a/make/common/Program.gmk b/make/common/Program.gmk index 005236149..77a044307 100644 --- a/make/common/Program.gmk +++ b/make/common/Program.gmk @@ -155,6 +155,7 @@ $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LC ifdef MT $(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1 endif + @$(call binary_file_verification,$@) else # PLATFORM @@ -179,6 +180,7 @@ $(ACTUAL_PROGRAM):: $(FILES_o) @$(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 diff --git a/make/common/Release.gmk b/make/common/Release.gmk index 834d33798..9d83ae748 100644 --- a/make/common/Release.gmk +++ b/make/common/Release.gmk @@ -836,11 +836,14 @@ else # PLATFORM 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 @@ endif # 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 @@ ifneq ($(POST_STRIP_PROCESS), ) 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 @@ trim-image-jdk:: $(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 @@ ifneq ($(PLATFORM), windows) 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 @@ ifneq ($(POST_STRIP_PROCESS), ) 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 diff --git a/make/common/shared/Compiler-msvc.gmk b/make/common/shared/Compiler-msvc.gmk index 49a0d5fe6..1b6d38d5f 100644 --- a/make/common/shared/Compiler-msvc.gmk +++ b/make/common/shared/Compiler-msvc.gmk @@ -35,6 +35,7 @@ ifeq ($(PLATFORM), windows) 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 @@ ifeq ($(PLATFORM), windows) _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 diff --git a/make/common/shared/Defs-linux.gmk b/make/common/shared/Defs-linux.gmk index a6be53650..db1307056 100644 --- a/make/common/shared/Defs-linux.gmk +++ b/make/common/shared/Defs-linux.gmk @@ -177,3 +177,20 @@ else 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 + diff --git a/make/common/shared/Defs-solaris.gmk b/make/common/shared/Defs-solaris.gmk index 98b054ef3..177af9748 100644 --- a/make/common/shared/Defs-solaris.gmk +++ b/make/common/shared/Defs-solaris.gmk @@ -186,3 +186,20 @@ else 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 + diff --git a/make/common/shared/Defs-utils.gmk b/make/common/shared/Defs-utils.gmk index 01bb98246..bb6aa493c 100644 --- a/make/common/shared/Defs-utils.gmk +++ b/make/common/shared/Defs-utils.gmk @@ -85,6 +85,7 @@ DATE = $(UTILS_COMMAND_PATH)date 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 @@ ID = $(UTILS_COMMAND_PATH)id 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 @@ PKGMK = $(UTILS_COMMAND_PATH)pkgmk 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 diff --git a/make/common/shared/Defs-windows.gmk b/make/common/shared/Defs-windows.gmk index 6a6fbffd3..95a47c206 100644 --- a/make/common/shared/Defs-windows.gmk +++ b/make/common/shared/Defs-windows.gmk @@ -798,3 +798,50 @@ else 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 + diff --git a/make/common/shared/Sanity-Settings.gmk b/make/common/shared/Sanity-Settings.gmk index 7e77e11ae..b4c86705e 100644 --- a/make/common/shared/Sanity-Settings.gmk +++ b/make/common/shared/Sanity-Settings.gmk @@ -117,6 +117,9 @@ ALL_SETTINGS+=$(call addRequiredVersionSetting,ZIP_VER) 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 @@ ifeq ($(PLATFORM),windows) 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) diff --git a/make/common/shared/Sanity.gmk b/make/common/shared/Sanity.gmk index b17690ca4..2ea23e2e1 100644 --- a/make/common/shared/Sanity.gmk +++ b/make/common/shared/Sanity.gmk @@ -1018,6 +1018,22 @@ ifeq ($(PLATFORM), windows) " 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 diff --git a/make/java/redist/Makefile b/make/java/redist/Makefile index 9f4d420aa..05cbb872d 100644 --- a/make/java/redist/Makefile +++ b/make/java/redist/Makefile @@ -223,12 +223,15 @@ endif # PLATFORM $(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)/$(SERVER_LOCATION)/$(LIBJSIG_NAME): $(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) -- GitLab