+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.
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. */
return compute_frame_size (get_frame_size ()) == 0;
}
\f
+/* 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. */
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 ();
}