[PR91749,arm] FDPIC: Handle -mflip-thumb

Message ID CAKdteOZi-T-krNjfmCLtt2S61=KqDGLhYB3PJ61ozjtr4xgM3Q@mail.gmail.com
State New
Headers show
Series
  • [PR91749,arm] FDPIC: Handle -mflip-thumb
Related show

Commit Message

Christophe Lyon Sept. 16, 2019, 1:39 p.m.
[Re-sending in plain text-mode, sorry for the duplicates]

Hi,

In PR91749, we have ICEs because -mflip-thumb switches to Thumb-1 (the
default target cpu does not support Thumb-2).

Although we already filter this in arm_configure_build_target, we
forgot to handle cases when the mode is changed via attributes (either
in the source code, or via -mflip-thumb).

This patch adds the same error message when trying to apply the
"thumb" attribute and the target does not support Thumb-2 (only if we
are in FDPIC mode, of course).

OK?

Thanks,

Christophe
gcc/ChangeLog:

2019-09-16  Christophe Lyon  <christophe.lyon@linaro.org>

	PR target/91749
	* config/arm/arm.c (arm_valid_target_attribute_rec): Make sure the
	mode attributed is supported by FDPIC.

Comments

Ramana Radhakrishnan Sept. 16, 2019, 4:42 p.m. | #1
On Mon, Sep 16, 2019 at 2:40 PM Christophe Lyon
<christophe.lyon@linaro.org> wrote:
>

> [Re-sending in plain text-mode, sorry for the duplicates]

>

> Hi,

>

> In PR91749, we have ICEs because -mflip-thumb switches to Thumb-1 (the

> default target cpu does not support Thumb-2).

>

> Although we already filter this in arm_configure_build_target, we

> forgot to handle cases when the mode is changed via attributes (either

> in the source code, or via -mflip-thumb).

>

> This patch adds the same error message when trying to apply the

> "thumb" attribute and the target does not support Thumb-2 (only if we

> are in FDPIC mode, of course).

>

> OK?


OK.

Ramana
>

> Thanks,

>

> Christophe

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index c452771..ceabe0a 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -31175,7 +31175,11 @@  arm_valid_target_attribute_rec (tree args, struct gcc_options *opts)
     {
       argstr = NULL;
       if (!strcmp (q, "thumb"))
-	opts->x_target_flags |= MASK_THUMB;
+	{
+	  opts->x_target_flags |= MASK_THUMB;
+	  if (TARGET_FDPIC && !arm_arch_thumb2)
+	    sorry ("FDPIC mode is not supported in Thumb-1 mode");
+	}
 
       else if (!strcmp (q, "arm"))
 	opts->x_target_flags &= ~MASK_THUMB;