aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2001-12-06 11:56:34 +0000
committerAlan Modra <amodra@gcc.gnu.org>2001-12-06 22:26:34 +1030
commit5b8c23564eb438eda9827b5341d05419afd092e4 (patch)
tree69222626b6f7d7711b74a2c97291f77e29a96569 /gcc
parent8456b95a5af348aa220ad0adc2101835f221f5d3 (diff)
downloadgcc-5b8c23564eb438eda9827b5341d05419afd092e4.zip
gcc-5b8c23564eb438eda9827b5341d05419afd092e4.tar.gz
gcc-5b8c23564eb438eda9827b5341d05419afd092e4.tar.bz2
rs6000.c (rs6000_unique_section): Simplify and correct code selecting section.
* config/rs6000/rs6000.c (rs6000_unique_section): Simplify and correct code selecting section. From-SVN: r47714
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/rs6000/rs6000.c67
2 files changed, 44 insertions, 28 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3dde901..92c1c1c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2001-12-06 Alan Modra <amodra@bigpond.net.au>
+
+ * config/rs6000/rs6000.c (rs6000_unique_section): Simplify and
+ correct code selecting section.
+
Thu Dec 6 12:45:33 CET 2001 Jan Hubicka <jh@suse.cz>
* final.c (count_basic_block, add_bb, add_bb_string):
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index fe358c0..74d23ca 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -9746,9 +9746,6 @@ rs6000_unique_section (decl, reloc)
tree decl;
int reloc;
{
- int size = int_size_in_bytes (TREE_TYPE (decl));
- int needs_sdata;
- int readonly;
int len;
int sec;
const char *name;
@@ -9757,40 +9754,54 @@ rs6000_unique_section (decl, reloc)
static const char *const prefixes[7][2] =
{
- { ".text.", ".gnu.linkonce.t." },
{ ".rodata.", ".gnu.linkonce.r." },
{ ".sdata2.", ".gnu.linkonce.s2." },
{ ".data.", ".gnu.linkonce.d." },
{ ".sdata.", ".gnu.linkonce.s." },
{ ".bss.", ".gnu.linkonce.b." },
- { ".sbss.", ".gnu.linkonce.sb." }
+ { ".sbss.", ".gnu.linkonce.sb." },
+ { ".text.", ".gnu.linkonce.t." }
};
-
- needs_sdata = (TREE_CODE (decl) != FUNCTION_DECL
- && size > 0
- && size <= g_switch_value
- && rs6000_sdata != SDATA_NONE
- && (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl)));
- if (TREE_CODE (decl) == STRING_CST)
- readonly = ! flag_writable_strings;
- else if (TREE_CODE (decl) == VAR_DECL)
- readonly = (! (flag_pic && reloc)
- && TREE_READONLY (decl)
- && ! TREE_SIDE_EFFECTS (decl)
- && DECL_INITIAL (decl)
- && DECL_INITIAL (decl) != error_mark_node
- && TREE_CONSTANT (DECL_INITIAL (decl)));
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ sec = 6;
else
- readonly = 1;
- if (needs_sdata && rs6000_sdata != SDATA_EABI)
- readonly = 0;
+ {
+ int readonly;
+ int needs_sdata;
+ int size;
+
+ readonly = 1;
+ if (TREE_CODE (decl) == STRING_CST)
+ readonly = ! flag_writable_strings;
+ else if (TREE_CODE (decl) == VAR_DECL)
+ readonly = (! (flag_pic && reloc)
+ && TREE_READONLY (decl)
+ && ! TREE_SIDE_EFFECTS (decl)
+ && TREE_CONSTANT (DECL_INITIAL (decl)));
+
+ size = int_size_in_bytes (TREE_TYPE (decl));
+ needs_sdata = (size > 0
+ && size <= g_switch_value
+ && rs6000_sdata != SDATA_NONE
+ && (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl)));
+
+ if (DECL_INITIAL (decl) == 0
+ || DECL_INITIAL (decl) == error_mark_node)
+ sec = 4;
+ else if (! readonly)
+ sec = 2;
+ else
+ sec = 0;
- sec = ((TREE_CODE (decl) == FUNCTION_DECL ? 0 : 1)
- + (readonly ? 0 : 2)
- + (needs_sdata ? 1 : 0)
- + (DECL_INITIAL (decl) == 0
- || DECL_INITIAL (decl) == error_mark_node) ? 4 : 0);
+ if (needs_sdata)
+ {
+ /* .sdata2 is only for EABI. */
+ if (sec == 0 && rs6000_sdata != SDATA_EABI)
+ sec = 2;
+ sec += 1;
+ }
+ }
STRIP_NAME_ENCODING (name, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
prefix = prefixes[sec][DECL_ONE_ONLY (decl)];