make/common/Program.gmk

Print this page

        

@@ -228,10 +228,17 @@
   endif
 
   #
   # This rule only applies on unix.  It supports quantify and its ilk.
   #
+
+  ifeq ($(PLATFORM), solaris)
+    ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+  $(ACTUAL_PROGRAM):: $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
+    endif
+  endif
+
   $(ACTUAL_PROGRAM):: $(FILES_o)
         @$(prep-target)
         @set -- $?; \
         $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
         @$(MKDIR) -p $(TEMPDIR)

@@ -242,15 +249,33 @@
   endif
         @$(call binary_file_verification,$@)
   ifneq ($(PLATFORM), macosx)
     ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
       ifeq ($(PROGRAM_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) ; \
+         $(FIX_EMPTY_SEC_HDR_FLAGS) $(@F) ; \
          $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
+         $(ADD_GNU_DEBUGLINK) $(@F).debuginfo $(@F) ; \
+        )
+        else # PLATFORM != solaris
+        (set -e ; \
+         $(CD) $(@D) ; \
+         $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
          $(OBJCOPY) --add-gnu-debuglink=$(@F).debuginfo $(@F) ; \
         )
+        endif # PLATFORM == solaris
         ifeq ($(STRIP_POLICY),all_strip)
           $(STRIP) $@
         else
           ifeq ($(STRIP_POLICY),min_strip)
             ifeq ($(PLATFORM), solaris)