summaryrefslogtreecommitdiff
path: root/gcc/varasm.c
diff options
context:
space:
mode:
authorDoug Evans <dje@gnu.org>1996-01-10 18:15:49 +0000
committerDoug Evans <dje@gnu.org>1996-01-10 18:15:49 +0000
commitf9da1f35792bae30bf9ba032211a973aef3c437f (patch)
tree190d88dbdc65c5c61a9aebbccac8f07786443ae2 /gcc/varasm.c
parent2995277ce3a92dd625d484e5f95f0f869c1d75f0 (diff)
downloadgcc-f9da1f35792bae30bf9ba032211a973aef3c437f.tar.gz
varasm.c (variable_section): New function.
* varasm.c (variable_section): New function. (assemble_variable): Call it. From-SVN: r10960
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r--gcc/varasm.c100
1 files changed, 41 insertions, 59 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index d725754c7e4..cad3fc400d3 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -278,6 +278,43 @@ function_section (decl)
else
text_section ();
}
+
+/* Switch to section for variable DECL.
+
+ RELOC is the `reloc' argument to SELECT_SECTION. */
+
+void
+variable_section (decl, reloc)
+ tree decl;
+ int reloc;
+{
+ if (IN_NAMED_SECTION (decl))
+ named_section (decl, NULL);
+ else
+ {
+ /* C++ can have const variables that get initialized from constructors,
+ and thus can not be in a readonly section. We prevent this by
+ verifying that the initial value is constant for objects put in a
+ readonly section.
+
+ error_mark_node is used by the C front end to indicate that the
+ initializer has not been seen yet. In this case, we assume that
+ the initializer must be constant. */
+#ifdef SELECT_SECTION
+ SELECT_SECTION (decl, reloc);
+#else
+ if (TREE_READONLY (decl)
+ && ! TREE_THIS_VOLATILE (decl)
+ && DECL_INITIAL (decl)
+ && (DECL_INITIAL (decl) == error_mark_node
+ || TREE_CONSTANT (DECL_INITIAL (decl)))
+ && ! (flag_pic && reloc))
+ readonly_data_section ();
+ else
+ data_section ();
+#endif
+ }
+}
/* Create the rtl to represent a function, for a function definition.
DECL is a FUNCTION_DECL node which describes which function.
@@ -1217,33 +1254,8 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
else if (DECL_INITIAL (decl))
reloc = output_addressed_constants (DECL_INITIAL (decl));
- /* Switch to the proper section for this data. */
- if (IN_NAMED_SECTION (decl))
- named_section (decl, NULL);
- else
- {
- /* C++ can have const variables that get initialized from constructors,
- and thus can not be in a readonly section. We prevent this by
- verifying that the initial value is constant for objects put in a
- readonly section.
-
- error_mark_node is used by the C front end to indicate that the
- initializer has not been seen yet. In this case, we assume that
- the initializer must be constant. */
-#ifdef SELECT_SECTION
- SELECT_SECTION (decl, reloc);
-#else
- if (TREE_READONLY (decl)
- && ! TREE_THIS_VOLATILE (decl)
- && DECL_INITIAL (decl)
- && (DECL_INITIAL (decl) == error_mark_node
- || TREE_CONSTANT (DECL_INITIAL (decl)))
- && ! (flag_pic && reloc))
- readonly_data_section ();
- else
- data_section ();
-#endif
- }
+ /* Switch to the appropriate section. */
+ variable_section (decl, reloc);
/* dbxout.c needs to know this. */
if (in_text_section ())
@@ -1278,22 +1290,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
/* If the debugging output changed sections, reselect the section
that's supposed to be selected. */
if (in_section != saved_in_section)
- {
- /* Switch to the proper section for this data. */
-#ifdef SELECT_SECTION
- SELECT_SECTION (decl, reloc);
-#else
- if (TREE_READONLY (decl)
- && ! TREE_THIS_VOLATILE (decl)
- && DECL_INITIAL (decl)
- && (DECL_INITIAL (decl) == error_mark_node
- || TREE_CONSTANT (DECL_INITIAL (decl)))
- && ! (flag_pic && reloc))
- readonly_data_section ();
- else
- data_section ();
-#endif
- }
+ variable_section (decl, reloc);
/* Compute and output the alignment of this data. */
@@ -1375,22 +1372,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
dbxout_symbol (decl, 0);
if (in_section != saved_in_section)
- {
- /* Switch to the proper section for this data. */
-#ifdef SELECT_SECTION
- SELECT_SECTION (decl, reloc);
-#else
- if (TREE_READONLY (decl)
- && ! TREE_THIS_VOLATILE (decl)
- && DECL_INITIAL (decl)
- && (DECL_INITIAL (decl) == error_mark_node
- || TREE_CONSTANT (DECL_INITIAL (decl)))
- && ! (flag_pic && reloc))
- readonly_data_section ();
- else
- data_section ();
-#endif
- }
+ variable_section (decl, reloc);
}
#else
/* There must be a statement after a label. */