make/common/Library.gmk

Print this page

        

@@ -243,10 +243,16 @@
 
 ifneq ($(PLATFORM), macosx)
   ARFLAGS = -r
 endif
 
+ifeq ($(PLATFORM), solaris)
+  ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+$(ACTUAL_LIBRARY):: $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
+  endif
+endif
+
 $(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
         @$(prep-target)
         @$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
         @$(ECHO) "Rebuilding $@ because of $?"
 ifeq ($(LIBRARY), fdlibm)

@@ -258,15 +264,33 @@
         $(MCS) -d -a "$(FULL_VERSION)" $@
 endif # WRITE_LIBVERSION
   ifneq ($(PLATFORM), macosx)
     ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
       ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+        ifeq ($(PLATFORM), 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.
         (set -e ; \
          $(CD) $(@D) ; \
-         $(OBJCOPY) --only-keep-debug $(@F) $(LIBRARY).debuginfo ; \
-         $(OBJCOPY) --add-gnu-debuglink=$(LIBRARY).debuginfo $(@F) ; \
+         $(FIX_EMPTY_SEC_HDR_FLAGS) $(@F) ; \
+         $(OBJCOPY) --only-keep-debug $(@F) $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
+         $(ADD_GNU_DEBUGLINK) $(LIB_PREFIX)$(LIBRARY).debuginfo $(@F) ; \
         )
+        else # PLATFORM != solaris
+        (set -e ; \
+         $(CD) $(@D) ; \
+         $(OBJCOPY) --only-keep-debug $(@F) $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
+         $(OBJCOPY) --add-gnu-debuglink=$(LIB_PREFIX)$(LIBRARY).debuginfo $(@F) ; \
+        )
+        endif # PLATFORM == solaris
         ifeq ($(STRIP_POLICY),all_strip)
           $(STRIP) $@
         else
           ifeq ($(STRIP_POLICY),min_strip)
             ifeq ($(PLATFORM), solaris)

@@ -279,12 +303,12 @@
           endif
         endif
         ifeq ($(ZIP_DEBUGINFO_FILES),1)
           (set -e ; \
            $(CD) $(@D) ; \
-           $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).debuginfo ; \
-           $(RM) $(LIBRARY).debuginfo ; \
+           $(ZIPEXE) -q $(LIB_PREFIX)$(LIBRARY).diz $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
+           $(RM) $(LIB_PREFIX)$(LIBRARY).debuginfo ; \
           )
         endif
       endif # LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
     endif # ENABLE_FULL_DEBUG_SYMBOLS
   endif # PLATFORM-!macosx