aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-06-21 22:47:29 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-06-21 22:47:29 +0000
commitd660677de96946d48de5c2627d6beccdac054567 (patch)
treeac8e7756d4a0b9ea3436c05c6406cbef089f6cb4 /gcc
parentc3bef29f4874b91fa1a053d77244637230b3a9c6 (diff)
downloadgcc-d660677de96946d48de5c2627d6beccdac054567.zip
gcc-d660677de96946d48de5c2627d6beccdac054567.tar.gz
gcc-d660677de96946d48de5c2627d6beccdac054567.tar.bz2
mips.c (symbolic_expression_p): New function.
* config/mips/mips.c (symbolic_expression_p): New function. (mips_select_rtx_section): Put symbolic expressions in the data section, not the read-only data section. From-SVN: r27688
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/mips/mips.c33
2 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 445581b..d4089ba 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+Mon Jun 21 12:47:39 1999 Mark Mitchell <mark@codesourcery.com>
+
+ * config/mips/mips.c (symbolic_expression_p): New function.
+ (mips_select_rtx_section): Put symbolic expressions in the
+ data section, not the read-only data section.
+
Mon Jun 21 22:13:06 1999 Jeffrey A Law (law@cygnus.com)
* rs6000.md (find_addr_reg): Handle LO_SUM addresses.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 3135aff..ba5a564 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -108,7 +108,7 @@ static void dump_constants PROTO ((struct constant *,
static rtx mips_find_symbol PROTO ((rtx));
static void abort_with_insn PROTO ((rtx, const char *))
ATTRIBUTE_NORETURN;
-
+static int symbolic_expression_p PROTO ((rtx));
/* Global variables for machine-dependent things. */
@@ -6894,6 +6894,29 @@ mips_can_use_return_insn ()
return compute_frame_size (get_frame_size ()) == 0;
}
+/* Returns non-zero if X contains a SYMBOL_REF. */
+
+static int
+symbolic_expression_p (x)
+ rtx x;
+{
+ if (GET_CODE (x) == SYMBOL_REF)
+ return 1;
+
+ if (GET_CODE (x) == CONST)
+ return symbolic_expression_p (XEXP (x, 0));
+
+ if (GET_RTX_CLASS (GET_CODE (x)) == '1')
+ return symbolic_expression_p (XEXP (x, 0));
+
+ if (GET_RTX_CLASS (GET_CODE (x)) == 'c'
+ || GET_RTX_CLASS (GET_CODE (x)) == '2')
+ return (symbolic_expression_p (XEXP (x, 0))
+ || symbolic_expression_p (XEXP (x, 1)));
+
+ return 0;
+}
+
/* Choose the section to use for the constant rtx expression X that has
mode MODE. */
@@ -6923,6 +6946,14 @@ mips_select_rtx_section (mode, x)
if (GET_MODE_SIZE (mode) <= mips_section_threshold
&& mips_section_threshold > 0)
SMALL_DATA_SECTION ();
+ else if (flag_pic && symbolic_expression_p (x))
+ /* Any expression involving a SYMBOL_REF might need a run-time
+ relocation. (The symbol might be defined in a shared
+ library loaded at an unexpected base address.) So, we must
+ put such expressions in the data segment (which is
+ writable), rather than the text segment (which is
+ read-only). */
+ data_section ();
else
READONLY_DATA_SECTION ();
}