From 9861b0c9d63ef866cf7e5b99ffc528f978ca66e2 Mon Sep 17 00:00:00 2001
From: David Edelsohn <dje@gcc.gnu.org>
Date: Tue, 22 Aug 2000 15:27:31 -0400
Subject: [PATCH] aix.h (ASM_DECLARE_FUNCTION_NAME): Call named_section() or
 text_section() as appropriate instead of emitting text...

	* aix.h (ASM_DECLARE_FUNCTION_NAME): Call named_section() or
        text_section() as appropriate instead of emitting text csect
	pseudo-op directly.
	(TEXT_SECTION_ASM_OP): Only require default 32-bit alignment.
	(UNIQUE_SECTION): Define macro.
	(ASM_OUTPUT_SECTION_NAME): Define macro.
	* rs6000.c (rs6000_override_options): Disable -ffunction-sections
        on AIX if debugging and -fdata-sections always.

From-SVN: r35886
---
 gcc/ChangeLog              | 15 ++++++++++++--
 gcc/config/rs6000/aix.h    | 40 ++++++++++++++++++++++++++++++--------
 gcc/config/rs6000/rs6000.c | 13 +++++++++++++
 3 files changed, 58 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c441170dd1a8..fe8bbb4b9042 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,15 @@
-2000-08-22 Steven King <sxking@uswest.net>
+2000-08-22  David Edelsohn  <edelsohn@gnu.org>
+
+	* aix.h (ASM_DECLARE_FUNCTION_NAME): Call named_section() or
+        text_section() as appropriate instead of emitting text csect
+	pseudo-op directly.
+	(TEXT_SECTION_ASM_OP): Only require default 32-bit alignment.
+	(UNIQUE_SECTION): Define macro.
+	(ASM_OUTPUT_SECTION_NAME): Define macro.
+	* rs6000.c (rs6000_override_options): Disable -ffunction-sections
+        on AIX if debugging and -fdata-sections always.
+
+2000-08-22  Steven King  <sxking@uswest.net>
 
 	* config/float-i386.h (LDBL_EPSILON): Remove __convert_long_double
 	machinery.
@@ -214,7 +225,7 @@ Mon Aug 21 07:41:12 2000  Jeffrey A Law  (law@cygnus.com)
 	* cppinit.c (cpp_init): Set global flag when called.
 	(cpp_reader_init): Bomb out if cpp_init hasn't been called.
 
-Sun Aug 20 01:41:35 MSD 2000 Dennis Chernoivanov <cdi@sparc.spb.su>
+Sun Aug 20 01:41:35 2000  Dennis Chernoivanov  <cdi@sparc.spb.su>
 
         * cpplex.c (cpp_scan_buffer): Move `output_line_command' just
         before `process_directive' so that newlines won't be missed
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
index b863b5e65433..3487efff195a 100644
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -408,8 +408,12 @@ toc_section ()						\
   fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE);	\
   RS6000_OUTPUT_BASENAME (FILE, NAME);				\
   fputs (", TOC[tc0], 0\n", FILE);				\
-  fputs (TARGET_32BIT						\
-	 ? "\t.csect .text[PR]\n." : "\t.csect .text[PR],3\n.", FILE); \
+  in_section = no_section;					\
+  if (flag_function_sections)					\
+    named_section ((DECL), (char *) 0, 0);			\
+  else								\
+    text_section();						\
+  putc ('.', FILE);						\
   RS6000_OUTPUT_BASENAME (FILE, NAME);				\
   fputs (":\n", FILE);						\
   if (write_symbols == XCOFF_DEBUG)				\
@@ -525,23 +529,43 @@ toc_section ()						\
   fprintf ((FILE), "\t.vbyte\t2,0x%x", (unsigned) (VALUE))
 
 #define ASM_OUTPUT_DWARF_OFFSET4(FILE, LABEL)	\
- ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, 4)
+  ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, 4)
 
 #define ASM_OUTPUT_DWARF_OFFSET(FILE, LABEL)			\
- ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, DWARF_OFFSET_SIZE)
+  ASM_OUTPUT_DWARF_ADDR_VAR (FILE, LABEL, DWARF_OFFSET_SIZE)
 
 /* dwarf2out keys off this, but we don't have to have a real definition.  */
 #define UNALIGNED_INT_ASM_OP bite_me
 
-/* Output before instructions.
-   Text section for 64-bit target may contain 64-bit address jump table.  */
-#define TEXT_SECTION_ASM_OP (TARGET_32BIT \
-                             ? "\t.csect .text[PR]" : "\t.csect .text[PR],3")
+/* Output before instructions.  */
+#define TEXT_SECTION_ASM_OP "\t.csect .text[PR]"
 
 /* Output before writable data.
    Align entire section to BIGGEST_ALIGNMENT.  */
 #define DATA_SECTION_ASM_OP "\t.csect .data[RW],3"
 
+/* Define unique section name -- functions only.  */
+#define UNIQUE_SECTION(DECL,RELOC)			\
+  do {							\
+    int len;						\
+    const char *name;					\
+    char *string;					\
+							\
+    if (TREE_CODE (DECL) == FUNCTION_DECL) {		\
+      name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
+      len = strlen (name) + 5;				\
+      string = alloca (len) + 1;			\
+      sprintf (string, ".%s[PR]", name);		\
+      DECL_SECTION_NAME (DECL) = build_string (len, string); \
+    }							\
+  } while (0)
+
+#define ASM_OUTPUT_SECTION_NAME(ASM_OUT_FILE,DECL,NAME,RELOC)	\
+  do { fputs ("\t.csect ", ASM_OUT_FILE);			\
+       fputs (TREE_STRING_POINTER (DECL_SECTION_NAME (DECL)), ASM_OUT_FILE); \
+       putc ('\n', ASM_OUT_FILE);				\
+  } while (0)
+
 /* __throw will restore its own return address to be the same as the
    return address of the function that the throw is being made to.
    This is unfortunate, because we want to check the original
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d4b4889875a3..9e4c11f23e3b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -361,6 +361,19 @@ rs6000_override_options (default_cpu)
       flag_pic = 0;
     }
 
+  if (flag_function_sections && (write_symbols != NO_DEBUG)
+      && (DEFAULT_ABI == ABI_AIX))
+    {
+      warning ("-ffunction-sections disabled on AIX when debugging");
+      flag_function_sections = 0;
+    }
+
+  if (flag_data_sections && (DEFAULT_ABI == ABI_AIX))
+    {
+      warning ("-fdata-sections not supported on AIX");
+      flag_data_sections = 0;
+    }
+
   /* Set debug flags */
   if (rs6000_debug_name)
     {
-- 
GitLab