* Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks
@ 2007-07-04 10:01 Richard Sandiford
2007-07-11 2:51 ` Mark Mitchell
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Richard Sandiford @ 2007-07-04 10:01 UTC (permalink / raw)
To: gcc-patches; +Cc: paul, nathan
This patch fixes gcc.c-torture/execute/20030928-1.c for ARM VxWorks
kernels. We tried to create "symbol + big offset" constants, which
runs into the problems described in the patch.
The fix is along the same lines as that used for ColdFire uClinux.
I think it would come in useful for ARM uClinux too.
Richard
gcc/
* 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.
Index: gcc/config/arm/arm-protos.h
===================================================================
--- gcc/config/arm/arm-protos.h 2007-07-04 02:07:24.000000000 -0700
+++ gcc/config/arm/arm-protos.h 2007-07-04 02:47:40.000000000 -0700
@@ -70,6 +70,7 @@ extern int neg_const_double_rtx_ok_for_f
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);
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c 2007-07-04 02:07:24.000000000 -0700
+++ gcc/config/arm/arm.c 2007-07-04 02:47:40.000000000 -0700
@@ -377,7 +377,7 @@ #define TARGET_HAVE_TLS true
#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
@@ -4580,6 +4580,23 @@ arm_tls_referenced_p (rtx x)
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 \
Index: gcc/config/arm/arm.h
===================================================================
--- gcc/config/arm/arm.h 2007-07-04 02:07:24.000000000 -0700
+++ gcc/config/arm/arm.h 2007-07-04 02:47:40.000000000 -0700
@@ -1827,6 +1827,10 @@ #define CONSTANT_ADDRESS_P(X) \
#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.
@@ -1844,7 +1848,7 @@ #define THUMB_LEGITIMATE_CONSTANT_P(X) \
|| 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)))
Index: gcc/config/arm/arm.md
===================================================================
--- gcc/config/arm/arm.md 2007-07-04 02:07:24.000000000 -0700
+++ gcc/config/arm/arm.md 2007-07-04 02:47:40.000000000 -0700
@@ -4649,6 +4649,8 @@ (define_expand "movsi"
(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. */
@@ -4674,6 +4676,19 @@ (define_expand "movsi"
}
}
+ 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]))
Index: gcc/config/arm/vxworks.h
===================================================================
--- gcc/config/arm/vxworks.h 2007-07-04 02:32:40.000000000 -0700
+++ gcc/config/arm/vxworks.h 2007-07-04 02:53:12.000000000 -0700
@@ -106,3 +106,11 @@ #define FUNCTION_PROFILER VXWORKS_FUNCTI
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks
2007-07-04 10:01 Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks Richard Sandiford
@ 2007-07-11 2:51 ` Mark Mitchell
2007-07-14 3:43 ` Paul Brook
[not found] ` <1184921014.32244.0.camel@pc960.cambridge.arm.com>
2 siblings, 0 replies; 4+ messages in thread
From: Mark Mitchell @ 2007-07-11 2:51 UTC (permalink / raw)
To: gcc-patches, paul, nathan, richard
Richard Sandiford wrote:
> gcc/
> * 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.
Paul, would you review this, please?
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks
2007-07-04 10:01 Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks Richard Sandiford
2007-07-11 2:51 ` Mark Mitchell
@ 2007-07-14 3:43 ` Paul Brook
[not found] ` <1184921014.32244.0.camel@pc960.cambridge.arm.com>
2 siblings, 0 replies; 4+ messages in thread
From: Paul Brook @ 2007-07-14 3:43 UTC (permalink / raw)
To: gcc-patches; +Cc: Richard Sandiford, nathan
On Wednesday 04 July 2007, Richard Sandiford wrote:
> This patch fixes gcc.c-torture/execute/20030928-1.c for ARM VxWorks
> kernels. We tried to create "symbol + big offset" constants, which
> runs into the problems described in the patch.
This seems like something there should be a target independent knob for.
Apparently there isn't though, so ok.
Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks
[not found] ` <1184921014.32244.0.camel@pc960.cambridge.arm.com>
@ 2007-07-20 10:24 ` Richard Sandiford
0 siblings, 0 replies; 4+ messages in thread
From: Richard Sandiford @ 2007-07-20 10:24 UTC (permalink / raw)
To: Richard Earnshaw; +Cc: gcc-patches
Richard Earnshaw <Richard.Earnshaw@arm.com> writes:
> On Wed, 2007-07-04 at 10:55 +0100, Richard Sandiford wrote:
>> This patch fixes gcc.c-torture/execute/20030928-1.c for ARM VxWorks
>> kernels. We tried to create "symbol + big offset" constants, which
>> runs into the problems described in the patch.
>>
>> The fix is along the same lines as that used for ColdFire uClinux.
>> I think it would come in useful for ARM uClinux too.
>>
>> Richard
>>
>>
>> gcc/
> [...]
>> * config/arm/arm.md (movsi): Split out-of-section constants when
>> ARM_OFFSETS_MUST_BE_WITHIN_SECTIONS_P.
>
> This breaks the build, since it contains a reference to the now-defunct
> no_new_pseudos.
Fixed with the patch below. Tested by building cc1 on arm-eabi,
installed as obvious. FYI, I had to disable werror because
of an unrelated signed/unsigned comparison warning in
arm.c:thumb1_compute_save_reg_mask, but I've left that alone.
Richard
gcc/
* config/arm/arm.md (movsi): Use can_create_pseudo_p instead of
no_new_pseudos.
Index: gcc/config/arm/arm.md
===================================================================
--- gcc/config/arm/arm.md (revision 126797)
+++ gcc/config/arm/arm.md (working copy)
@@ -4682,7 +4682,7 @@ (define_expand "movsi"
if (GET_CODE (base) == SYMBOL_REF
&& !offset_within_block_p (base, INTVAL (offset)))
{
- tmp = no_new_pseudos ? operands[0] : gen_reg_rtx (SImode);
+ tmp = can_create_pseudo_p () ? gen_reg_rtx (SImode) : operands[0];
emit_move_insn (tmp, base);
emit_insn (gen_addsi3 (operands[0], tmp, offset));
DONE;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-07-20 9:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-04 10:01 Fix gcc.c-torture/execute/20030928-1.c for ARM VxWorks Richard Sandiford
2007-07-11 2:51 ` Mark Mitchell
2007-07-14 3:43 ` Paul Brook
[not found] ` <1184921014.32244.0.camel@pc960.cambridge.arm.com>
2007-07-20 10:24 ` Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).