diff --git a/dont-add-unnecessary-debug-links.patch b/dont-add-unnecessary-debug-links.patch new file mode 100644 index 0000000..9c29e6b --- /dev/null +++ b/dont-add-unnecessary-debug-links.patch @@ -0,0 +1,77 @@ +--- openjdk/make/common/NativeCompilation.gmk ++++ openjdk/make/common/NativeCompilation.gmk +@@ -437,29 +437,6 @@ + + ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X + ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows +- ifeq ($(OPENJDK_TARGET_OS), solaris) +- # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. +- # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from +- # empty section headers until a fixed $(OBJCOPY) is available. +- # An empty section header has sh_addr == 0 and sh_size == 0. +- # This problem has only been seen on Solaris X64, but we call this tool +- # on all Solaris builds just in case. +- # +- # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. +- # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. +- $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ +- $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) +- $(RM) $$@ +- $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< +- $(OBJCOPY) --only-keep-debug $$< $$@ +- $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< +- else # not solaris +- $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) +- $(RM) $$@ +- $(OBJCOPY) --only-keep-debug $$< $$@ +- $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< +- endif # Touch to not retrigger rule on rebuild +- $(TOUCH) $$@ + endif # !windows + endif # !macosx + +@@ -483,7 +460,6 @@ + $1 += $$($1_OUTPUT_DIR)/$$($1_LIBRARY).map \ + $$($1_OUTPUT_DIR)/$$($1_LIBRARY).pdb + else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files +- $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo + endif + endif + endif +@@ -522,28 +498,8 @@ + ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X + ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows + ifeq ($(OPENJDK_TARGET_OS), solaris) +- # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. +- # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from +- # empty section headers until a fixed $(OBJCOPY) is available. +- # An empty section header has sh_addr == 0 and sh_size == 0. +- # This problem has only been seen on Solaris X64, but we call this tool +- # on all Solaris builds just in case. +- # +- # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. +- # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. +- $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ +- $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) +- $(RM) $$@ +- $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< +- $(OBJCOPY) --only-keep-debug $$< $$@ +- $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< + else # not solaris +- $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) +- $(RM) $$@ +- $(OBJCOPY) --only-keep-debug $$< $$@ +- $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< + endif +- $(TOUCH) $$@ + endif # !windows + endif # !macosx + +@@ -567,7 +523,6 @@ + $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).map \ + $$($1_OUTPUT_DIR)/$$($1_PROGRAM).pdb + else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files +- $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo + endif + endif + endif diff --git a/hotspot-assembler-debuginfo.patch b/hotspot-assembler-debuginfo.patch new file mode 100644 index 0000000..61f493d --- /dev/null +++ b/hotspot-assembler-debuginfo.patch @@ -0,0 +1,27 @@ +Make the assembler generate whatever debuginfo it can +--- openjdk/hotspot/make/linux/makefiles/rules.make ++++ openjdk/hotspot/make/linux/makefiles/rules.make +@@ -34,7 +34,7 @@ + CC_COMPILE = $(CC) $(CXXFLAGS) $(CFLAGS) + CXX_COMPILE = $(CXX) $(CXXFLAGS) $(CFLAGS) + +-AS.S = $(AS) $(ASFLAGS) ++AS.S = $(AS) -g $(ASFLAGS) + + COMPILE.CC = $(CC_COMPILE) -c + GENASM.CC = $(CC_COMPILE) -S +@@ -161,12 +161,12 @@ + %.o: %.s + @echo Assembling $< + $(QUIETLY) $(REMOVE_TARGET) +- $(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) ++ $(QUIETLY) $(AS.S) -g $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) + + %.o: %.S + @echo Assembling $< + $(QUIETLY) $(REMOVE_TARGET) +- $(COMPILE.CC) -o $@ $< $(COMPILE_DONE) ++ $(COMPILE.CC) -g -o $@ $< $(COMPILE_DONE) + + %.s: %.cpp + @echo Generating assembly for $< diff --git a/java-1.8.0-openjdk.spec b/java-1.8.0-openjdk.spec index a74760b..ddb85f5 100644 --- a/java-1.8.0-openjdk.spec +++ b/java-1.8.0-openjdk.spec @@ -795,7 +795,7 @@ Obsoletes: java-1.7.0-openjdk-accessibility%1 Name: java-%{javaver}-%{origin} Version: %{javaver}.%{updatever} -Release: 1.%{buildver}%{?dist} +Release: 2.%{buildver}%{?dist} # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons, # and this change was brought into RHEL-4. java-1.5.0-ibm packages # also included the epoch in their virtual provides. This created a @@ -940,6 +940,10 @@ Patch524: 8158260-pr2991-rh1341258.patch # Patches ineligible for 8u # 8043805: Allow using a system-installed libjpeg Patch201: system-libjpeg.patch +# Pathces 204-206 are serving for better check of debug symbols in native liraries +Patch204: hotspot-remove-debuglink.patch +Patch205: dont-add-unnecessary-debug-links.patch +Patch206: hotspot-assembler-debuginfo.patch # Local fixes # PR1834, RH1022017: Reduce curves reported by SSL to those in NSS @@ -957,10 +961,12 @@ BuildRequires: alsa-lib-devel BuildRequires: binutils BuildRequires: cups-devel BuildRequires: desktop-file-utils +BuildRequires: elfutils BuildRequires: fontconfig BuildRequires: freetype-devel BuildRequires: giflib-devel BuildRequires: gcc-c++ +BuildRequires: gdb BuildRequires: gtk2-devel BuildRequires: lcms2-devel BuildRequires: libjpeg-devel @@ -1235,6 +1241,9 @@ sh %{SOURCE12} %patch201 %patch202 %patch203 +%patch204 +%patch205 +%patch206 %patch1 %patch3 @@ -1459,18 +1468,61 @@ $JAVA_HOME/bin/javac -d . %{SOURCE14} $JAVA_HOME/bin/java $(echo $(basename %{SOURCE14})|sed "s|\.java||") # Check debug symbols are present and can identify code -SERVER_JVM="$JAVA_HOME/jre/lib/%{archinstall}/server/libjvm.so" -if [ -f "$SERVER_JVM" ] ; then - nm -aCl "$SERVER_JVM" | grep javaCalls.cpp -fi -CLIENT_JVM="$JAVA_HOME/jre/lib/%{archinstall}/client/libjvm.so" -if [ -f "$CLIENT_JVM" ] ; then - nm -aCl "$CLIENT_JVM" | grep javaCalls.cpp -fi -ZERO_JVM="$JAVA_HOME/jre/lib/%{archinstall}/zero/libjvm.so" -if [ -f "$ZERO_JVM" ] ; then - nm -aCl "$ZERO_JVM" | grep javaCalls.cpp -fi +find "$JAVA_HOME" -iname '*.so' -print0 | while read -d $'\0' lib +do + if [ -f "$lib" ] ; then + echo "Testing $lib for debug symbols" + # All these tests rely on RPM failing the build if the exit code of any set + # of piped commands is non-zero. + + # Test for .debug_* sections in the shared object. This is the main test. + # Stripped objects will not contain these. + eu-readelf -S "$lib" | grep "] .debug_" + test $(eu-readelf -S "$lib" | egrep "\]\ .debug_(info|abbrev)" | wc --lines) == 2 + + # Test FILE symbols. These will most likely be removed by anyting that + # manipulates symbol tables because it's generally useless. So a nice test + # that nothing has messed with symbols. + old_IFS="$IFS" + IFS=$'\n' + for line in $(eu-readelf -s "$lib" | grep "00000000 0 FILE LOCAL DEFAULT") + do + # We expect to see .cpp files, except for architectures like aarch64 and + # s390 where we expect .o and .oS files + echo "$line" | egrep "ABS ((.*/)?[-_a-zA-Z0-9]+\.(c|cc|cpp|cxx|o|oS))?$" + done + IFS="$old_IFS" + + # If this is the JVM, look for javaCalls.(cpp|o) in FILEs, for extra sanity checking. + if [ "`basename $lib`" = "libjvm.so" ]; then + eu-readelf -s "$lib" | \ + egrep "00000000 0 FILE LOCAL DEFAULT ABS javaCalls.(cpp|o)$" + fi + + # Test that there are no .gnu_debuglink sections pointing to another + # debuginfo file. There shouldn't be any debuginfo files, so the link makes + # no sense either. + eu-readelf -S "$lib" | grep 'gnu' + if eu-readelf -S "$lib" | grep '] .gnu_debuglink' | grep PROGBITS; then + echo "bad .gnu_debuglink section." + eu-readelf -x .gnu_debuglink "$lib" + false + fi + fi +done + +# Make sure gdb can do a backtrace based on line numbers on libjvm.so +gdb -q "$JAVA_HOME/bin/java" < - 1:1.8.0.111-2.b16 +- added dont-add-unnecessary-debug-links.patch +- added hotspot-assembler-debuginfo.patch +- returned accidentally removed hotspot-remove-debuglink.patch +- eu-readelfs on libraries improved, added gdb call + * Wed Oct 19 2016 jvanek - 1:1.8.0.111-1.b16 - updated to aarch64-jdk8u111-b16 (from aarch64-port/jdk8u) - updated to aarch64-shenandoah-jdk8u111-b16 (from aarch64-port/jdk8u-shenandoah) of hotspot