aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatherine Moore <clm@cygnus.com>1998-09-28 06:24:06 +0000
committerCatherine Moore <clm@gcc.gnu.org>1998-09-28 02:24:06 -0400
commit7d0756fbf15a0b02e566ce3a2193cb51772e3c0c (patch)
tree94a5b1127023dfb6300c924e2c3d5cf44307f9df
parent52464fd6e7c701672ba8826d2831ea8f5e38fa15 (diff)
downloadgcc-7d0756fbf15a0b02e566ce3a2193cb51772e3c0c.zip
gcc-7d0756fbf15a0b02e566ce3a2193cb51772e3c0c.tar.gz
gcc-7d0756fbf15a0b02e566ce3a2193cb51772e3c0c.tar.bz2
flags.h: Add flag_data_sections.
* flags.h: Add flag_data_sections. * toplev.c: Add option -fdata-sections. Add flag_data_sections. (compile_file): Error if flag_data_sections not supported. * varasm.c (assemble_variable): Handle flag_data_sections. * config/svr4.h: Modify prefixes for UNIQUE_SECTION_NAME. * config/mips/elf.h: Likewise. * config/mips/elf64.h: Likewise. * invoke.texi: Describe -fdata-sections. From-SVN: r22619
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/mips/elf.h61
-rw-r--r--gcc/config/mips/elf64.h61
-rw-r--r--gcc/config/svr4.h11
-rw-r--r--gcc/flags.h4
-rw-r--r--gcc/invoke.texi20
-rw-r--r--gcc/toplev.c12
-rw-r--r--gcc/varasm.c4
8 files changed, 172 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ef0e468..5a01f5a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+Mon Sep 28 07:54:03 1998 Catherine Moore <clm@cygnus.com>
+
+ * flags.h: Add flag_data_sections.
+ * toplev.c: Add option -fdata-sections. Add flag_data_sections.
+ (compile_file): Error if flag_data_sections not supported.
+ * varasm.c (assemble_variable): Handle flag_data_sections.
+ * config/svr4.h: Modify prefixes for UNIQUE_SECTION_NAME.
+ * config/mips/elf.h: Likewise.
+ * config/mips/elf64.h: Likewise.
+ * invoke.texi: Describe -fdata-sections.
+
Mon Sep 28 04:15:44 1998 Craig Burley <burley@melange.gnu.org>
* invoke.texi (-ffloat-store): Clarify that this option
diff --git a/gcc/config/mips/elf.h b/gcc/config/mips/elf.h
index cfaa9d1..a5401f8 100644
--- a/gcc/config/mips/elf.h
+++ b/gcc/config/mips/elf.h
@@ -169,3 +169,64 @@ do { \
fputc ('\n', FILE); \
} while (0)
+#define UNIQUE_SECTION(DECL,RELOC) \
+do { \
+ int len, size, sec; \
+ char *name, *string, *prefix; \
+ static char *prefixes[4][2] = { \
+ { ".text.", ".gnu.linkonce.t." }, \
+ { ".rodata.", ".gnu.linkonce.r." }, \
+ { ".data.", ".gnu.linkonce.d." }, \
+ { ".sdata.", ".gnu.linkonce.s." } \
+ }; \
+ \
+ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
+ size = int_size_in_bytes (TREE_TYPE (decl)); \
+ \
+ /* Determine the base section we are interested in: \
+ 0=text, 1=rodata, 2=data, 3=sdata. */ \
+ if (TREE_CODE (DECL) == FUNCTION_DECL) \
+ sec = 0; \
+ else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
+ && TREE_CODE (decl) == STRING_CST \
+ && !flag_writable_strings) \
+ { \
+ /* For embedded position independent code, put constant strings \
+ in the text section, because the data section is limited to \
+ 64K in size. For mips16 code, put strings in the text \
+ section so that a PC relative load instruction can be used to \
+ get their address. */ \
+ sec = 0; \
+ } \
+ else if (TARGET_EMBEDDED_DATA) \
+ { \
+ /* For embedded applications, always put an object in read-only data \
+ if possible, in order to reduce RAM usage. */ \
+ \
+ if (DECL_READONLY_SECTION (DECL, RELOC)) \
+ sec = 1; \
+ else if (size > 0 && size <= mips_section_threshold) \
+ sec = 3; \
+ else \
+ sec = 2; \
+ } \
+ else \
+ { \
+ /* For hosted applications, always put an object in small data if \
+ possible, as this gives the best performance. */ \
+ \
+ if (size > 0 && size <= mips_section_threshold) \
+ sec = 3; \
+ else if (DECL_READONLY_SECTION (DECL, RELOC)) \
+ sec = 1; \
+ else \
+ sec = 2; \
+ } \
+ \
+ prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
+ len = strlen (name) + strlen (prefix); \
+ string = alloca (len + 1); \
+ sprintf (string, "%s%s", prefix, name); \
+ \
+ DECL_SECTION_NAME (DECL) = build_string (len, string); \
+} while (0)
diff --git a/gcc/config/mips/elf64.h b/gcc/config/mips/elf64.h
index 503eb87..b6cf372 100644
--- a/gcc/config/mips/elf64.h
+++ b/gcc/config/mips/elf64.h
@@ -195,3 +195,64 @@ do { \
fputc ('\n', FILE); \
} while (0)
+#define UNIQUE_SECTION(DECL,RELOC) \
+do { \
+ int len, size, sec; \
+ char *name, *string, *prefix; \
+ static char *prefixes[4][2] = { \
+ { ".text.", ".gnu.linkonce.t." }, \
+ { ".rodata.", ".gnu.linkonce.r." }, \
+ { ".data.", ".gnu.linkonce.d." }, \
+ { ".sdata.", ".gnu.linkonce.s." } \
+ }; \
+ \
+ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
+ size = int_size_in_bytes (TREE_TYPE (decl)); \
+ \
+ /* Determine the base section we are interested in: \
+ 0=text, 1=rodata, 2=data, 3=sdata. */ \
+ if (TREE_CODE (DECL) == FUNCTION_DECL) \
+ sec = 0; \
+ else if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) \
+ && TREE_CODE (decl) == STRING_CST \
+ && !flag_writable_strings) \
+ { \
+ /* For embedded position independent code, put constant strings \
+ in the text section, because the data section is limited to \
+ 64K in size. For mips16 code, put strings in the text \
+ section so that a PC relative load instruction can be used to \
+ get their address. */ \
+ sec = 0; \
+ } \
+ else if (TARGET_EMBEDDED_DATA) \
+ { \
+ /* For embedded applications, always put an object in read-only data \
+ if possible, in order to reduce RAM usage. */ \
+ \
+ if (DECL_READONLY_SECTION (DECL, RELOC)) \
+ sec = 1; \
+ else if (size > 0 && size <= mips_section_threshold) \
+ sec = 3; \
+ else \
+ sec = 2; \
+ } \
+ else \
+ { \
+ /* For hosted applications, always put an object in small data if \
+ possible, as this gives the best performance. */ \
+ \
+ if (size > 0 && size <= mips_section_threshold) \
+ sec = 3; \
+ else if (DECL_READONLY_SECTION (DECL, RELOC)) \
+ sec = 1; \
+ else \
+ sec = 2; \
+ } \
+ \
+ prefix = prefixes[sec][DECL_ONE_ONLY (DECL)]; \
+ len = strlen (name) + strlen (prefix); \
+ string = alloca (len + 1); \
+ sprintf (string, "%s%s", prefix, name); \
+ \
+ DECL_SECTION_NAME (DECL) = build_string (len, string); \
+} while (0)
diff --git a/gcc/config/svr4.h b/gcc/config/svr4.h
index 4737697..ef7a1d9 100644
--- a/gcc/config/svr4.h
+++ b/gcc/config/svr4.h
@@ -655,7 +655,15 @@ do { \
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)); \
\
if (! DECL_ONE_ONLY (DECL)) \
- prefix = "."; \
+ { \
+ prefix = "."; \
+ if (TREE_CODE (DECL) == FUNCTION_DECL) \
+ prefix = ".text."; \
+ else if (DECL_READONLY_SECTION (DECL, RELOC)) \
+ prefix = ".rodata."; \
+ else \
+ prefix = ".data."; \
+ } \
else if (TREE_CODE (DECL) == FUNCTION_DECL) \
prefix = ".gnu.linkonce.t."; \
else if (DECL_READONLY_SECTION (DECL, RELOC)) \
@@ -669,7 +677,6 @@ do { \
\
DECL_SECTION_NAME (DECL) = build_string (len, string); \
} while (0)
-
/* A C statement (sans semicolon) to output an element in the table of
global constructors. */
#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
diff --git a/gcc/flags.h b/gcc/flags.h
index cfb4ee6..a403750 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -398,6 +398,10 @@ extern int flag_inhibit_size_directive;
extern int flag_function_sections;
+/* ... and similar for data. */
+
+extern int flag_data_sections;
+
/* -fverbose-asm causes extra commentary information to be produced in
the generated assembly code (to make it more readable). This option
is generally only of use to those who actually need to read the
diff --git a/gcc/invoke.texi b/gcc/invoke.texi
index e60cfd1..5c6d845 100644
--- a/gcc/invoke.texi
+++ b/gcc/invoke.texi
@@ -151,9 +151,9 @@ in the following sections.
-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks
-fdelayed-branch -fexpensive-optimizations
-ffast-math -ffloat-store -fforce-addr -fforce-mem
--ffunction-sections -fgcse -finline-functions
--fkeep-inline-functions -fno-default-inline
--fno-defer-pop -fno-function-cse
+-fdata-sections -ffunction-sections -fgcse
+-finline-functions -fkeep-inline-functions
+-fno-default-inline -fno-defer-pop -fno-function-cse
-fno-inline -fno-peephole -fomit-frame-pointer -fregmove
-frerun-cse-after-loop -frerun-loop-opt -fschedule-insns
-fschedule-insns2 -fstrength-reduce -fthread-jumps
@@ -2340,18 +2340,20 @@ especially useful on machines with a relatively small number of
registers and where memory load instructions take more than one cycle.
@item -ffunction-sections
-Place each function into its own section in the output file if the
-target supports arbitrary sections. The function's name determines
-the section's name in the output file.
+@item -fdata-sections
+Place each function or data item into its own section in the output
+file if the target supports arbitrary sections. The name of the
+function or the name of the data item determines the section's name
+in the output file.
-Use this option on systems where the linker can perform optimizations
+Use these options on systems where the linker can perform optimizations
to improve locality of reference in the instruction space. HPPA
processors running HP-UX and Sparc processors running Solaris 2 have
linkers with such optimizations. Other systems using the ELF object format
as well as AIX may have these optimizations in the future.
-Only use this option when there are significant benefits from doing
-so. When you specify this option, the assembler and linker will
+Only use these options when there are significant benefits from doing
+so. When you specify these options, the assembler and linker will
create larger object and executable files and will also be slower.
You will not be able to use @code{gprof} on all systems if you
specify this option and you may have problems with debugging if
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 6da9b49..96956bf 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -528,6 +528,10 @@ int flag_no_peephole = 0;
/* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math
operations in the interest of optimization. For example it allows
+/* ... and similar for data. */
+
+int flag_data_sections = 0;
+
GCC to assume arguments to sqrt are nonnegative numbers, allowing
faster code for sqrt to be generated. */
@@ -932,6 +936,8 @@ documented_lang_options[] =
enabled by default. */
{ "-ansi", "Compile just for ANSI C" },
+ {"data-sections", &flag_data_sections, 1,
+ "place data items into their own section" },
{ "-fallow-single-precision",
"Do not promote floats to double if using -traditional" },
@@ -2809,6 +2815,12 @@ compile_file (name)
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
vec[len - i - 1] = decl;
+ if (flag_data_sections)
+ {
+ warning ("-fdata-sections not supported for this target.");
+ flag_data_sections = 0;
+ }
+
for (i = 0; i < len; i++)
{
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 495a860..d3e12b9 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1464,7 +1464,9 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
reloc = output_addressed_constants (DECL_INITIAL (decl));
#ifdef ASM_OUTPUT_SECTION_NAME
- if (UNIQUE_SECTION_P (decl))
+ if ((flag_data_sections != 0
+ && DECL_SECTION_NAME (decl) == NULL_TREE)
+ || UNIQUE_SECTION_P (decl))
UNIQUE_SECTION (decl, reloc);
#endif