* config/arm/arm-protos.h (arm_cannot_force_const_mem): Declare.
* config/arm/arm.c (TARGET_CANNOT_FORCE_CONST_MEM): Redefine to
arm_cannot_force_const_mem.
(arm_cannot_force_const_mem): New function.
* config/arm/arm.h (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P): New macro.
(LEGITIMATE_CONSTANT_P): Test arm_cannot_force_const_mem instead
of arm_tls_referenced_p.
* config/arm/arm.md (movsi): Split out-of-section constants when
ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P.
* config/arm/vxworks.h (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P): Define.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126718
138bc75d-0d04-0410-961f-
82ee72b054a4
2007-07-18 Richard Sandiford <richard@codesourcery.com>
+ * config/arm/arm-protos.h (arm_cannot_force_const_mem): Declare.
+ * config/arm/arm.c (TARGET_CANNOT_FORCE_CONST_MEM): Redefine to
+ arm_cannot_force_const_mem.
+ (arm_cannot_force_const_mem): New function.
+ * config/arm/arm.h (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P): New macro.
+ (LEGITIMATE_CONSTANT_P): Test arm_cannot_force_const_mem instead
+ of arm_tls_referenced_p.
+ * config/arm/arm.md (movsi): Split out-of-section constants when
+ ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P.
+ * config/arm/vxworks.h (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P): Define.
+
+2007-07-18 Richard Sandiford <richard@codesourcery.com>
+
* config/mips/mips.md (clear_cache): Treat the size argument as Pmode.
2007-07-18 Richard Sandiford <richard@codesourcery.com>
extern enum reg_class coproc_secondary_reload_class (enum machine_mode, rtx,
bool);
extern bool arm_tls_referenced_p (rtx);
+extern bool arm_cannot_force_const_mem (rtx);
extern int cirrus_memory_offset (rtx);
extern int arm_coproc_mem_operand (rtx, bool);
#endif
#undef TARGET_CANNOT_FORCE_CONST_MEM
-#define TARGET_CANNOT_FORCE_CONST_MEM arm_tls_referenced_p
+#define TARGET_CANNOT_FORCE_CONST_MEM arm_cannot_force_const_mem
#ifdef HAVE_AS_TLS
#undef TARGET_ASM_OUTPUT_DWARF_DTPREL
return for_each_rtx (&x, arm_tls_operand_p_1, NULL);
}
+
+/* Implement TARGET_CANNOT_FORCE_CONST_MEM. */
+
+bool
+arm_cannot_force_const_mem (rtx x)
+{
+ rtx base, offset;
+
+ if (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
+ {
+ split_const (x, &base, &offset);
+ if (GET_CODE (base) == SYMBOL_REF
+ && !offset_within_block_p (base, INTVAL (offset)))
+ return true;
+ }
+ return arm_tls_referenced_p (x);
+}
\f
#define REG_OR_SUBREG_REG(X) \
(GET_CODE (X) == REG \
#endif /* AOF_ASSEMBLER */
+/* True if SYMBOL + OFFSET constants must refer to something within
+ SYMBOL's section. */
+#define ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P 0
+
/* Nonzero if the constant value X is a legitimate general operand.
It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
|| flag_pic)
#define LEGITIMATE_CONSTANT_P(X) \
- (!arm_tls_referenced_p (X) \
+ (!arm_cannot_force_const_mem (X) \
&& (TARGET_32BIT ? ARM_LEGITIMATE_CONSTANT_P (X) \
: THUMB_LEGITIMATE_CONSTANT_P (X)))
(match_operand:SI 1 "general_operand" ""))]
"TARGET_EITHER"
"
+ rtx base, offset, tmp;
+
if (TARGET_32BIT)
{
/* Everything except mem = const or mem = mem can be done easily. */
}
}
+ if (ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
+ {
+ split_const (operands[1], &base, &offset);
+ if (GET_CODE (base) == SYMBOL_REF
+ && !offset_within_block_p (base, INTVAL (offset)))
+ {
+ tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (SImode);
+ emit_move_insn (tmp, base);
+ emit_insn (gen_addsi3 (operands[0], tmp, offset));
+ DONE;
+ }
+ }
+
/* Recognize the case where operand[1] is a reference to thread-local
data and load its address to a register. */
if (arm_tls_referenced_p (operands[1]))
the past before this macro was changed. */
#undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
+
+/* The kernel loader does not allow relocations to overflow, so we
+ cannot allow arbitrary relocation addends in kernel modules or RTP
+ executables. Also, the dynamic loader uses the resolved relocation
+ value to distinguish references to the text and data segments, so we
+ cannot allow arbitrary offsets for shared libraries either. */
+#undef ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P
+#define ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P 1