Patchwork [SH] Error: unaligned opcodes detected in executable segment

login
register
mail settings
Submitter Christian Bruel
Date April 9, 2013, 2:34 p.m.
Message ID <51642702.5090204@st.com>
Download mbox | patch
Permalink /patch/235104/
State New
Headers show

Comments

Christian Bruel - April 9, 2013, 2:34 p.m.
Hello,

This patch fixes label alignments after a ADDR_DIFF_VEC with byte
offsets. The bug occurs with building the libgcc for a sh-elf target.

See a reduced case here. The funny thing is that the assembly error
given in Subject appears only on a debug section when compiled with -g,
thus the emitted code without -g:

         .align 2
.L4:
        .byte   .L3-.L5
        .byte   .L10-.L5
        .byte   .L7-.L5
        .byte   .L8-.L5
        .byte   .L9-.L5
.L3:
         mov.l   .L13,r1

assembles silently, although unaligned...

OK for trunk ? The failure occurs with the libgcc, so tested by allowing
the sh-elf build to complete.

Thanks,

Christian
Kaz Kojima - April 9, 2013, 11:20 p.m.
Christian Bruel <christian.bruel@st.com> wrote:
> This patch fixes label alignments after a ADDR_DIFF_VEC with byte
> offsets. The bug occurs with building the libgcc for a sh-elf target.
> 
> See a reduced case here. The funny thing is that the assembly error
> given in Subject appears only on a debug section when compiled with -g,
> thus the emitted code without -g:
> 
>          .align 2
> .L4:
>         .byte   .L3-.L5
>         .byte   .L10-.L5
>         .byte   .L7-.L5
>         .byte   .L8-.L5
>         .byte   .L9-.L5
> .L3:
>          mov.l   .L13,r1
> 
> assembles silently, although unaligned...
> 
> OK for trunk ? The failure occurs with the libgcc, so tested by allowing
> the sh-elf build to complete.

OK.

Regards,
	kaz

Patch

2013-04-09  Christian Bruel  <christian.bruel@st.com>

	* config/sh/sh.md (barrier_align): Use next/prev_active_insn instead
	of next/prev_real_insn.

Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	(revision 197633)
+++ gcc/config/sh/sh.c	(working copy)
@@ -5842,7 +5842,7 @@  fixup_addr_diff_vecs (rtx first)
 int
 barrier_align (rtx barrier_or_label)
 {
-  rtx next = next_real_insn (barrier_or_label), pat, prev;
+  rtx next = next_active_insn (barrier_or_label), pat, prev;
 
   if (! next)
     return 0;
@@ -5856,7 +5856,7 @@  barrier_align (rtx barrier_or_label)
     /* This is a barrier in front of a constant table.  */
     return 0;
 
-  prev = prev_real_insn (barrier_or_label);
+  prev = prev_active_insn (barrier_or_label);
   if (GET_CODE (PATTERN (prev)) == ADDR_DIFF_VEC)
     {
       pat = PATTERN (prev);