Environment: $ arm-elf-gcc -v Using built-in specs. COLLECT_GCC=arm-elf-gcc COLLECT_LTO_WRAPPER=/cygdrive/c/usr/local/cross/libexec/gcc/arm-elf/4.5.0/lto-wrapper.exe Target: arm-elf Configured with: ../configure --prefix=/cygdrive/c/usr/local/cross --target=arm-elf --with-float=soft --enable-languages=c,c++ --enable-lto --with-libelf=/usr/local Thread model: single gcc version 4.5.0 (GCC) Error: $ arm-elf-gcc -c -Os -mthumb test.i /cygdrive/c/Users/exceed/AppData/Local/Temp/cc6UR3zm.s: Assembler messages: /cygdrive/c/Users/exceed/AppData/Local/Temp/cc6UR3zm.s:32816: Error: branch out of range Problem: I think that the length of jump table does not contains a align code. When jump table mode is SImode, ASM_OUTPUT_CASE_LABEL generates a align code. But length does not contains this align code. (And ADDR_VEC_ALIGN is defined to 0) Quick hack (for 4.5 branch): Please see attached file.
Created attachment 20532 [details] test source for reproduce the bug $ arm-elf-gcc -c -Os -mthumb test.i
Created attachment 20533 [details] patch (quick hack ;-) From gcc-4_5-branch (svn r158961)
Also breaks on armv5tel-unknown-linux-gnueabi with gcc-4.5-20100429 and gcc-4.6-20100501. It works with gcc-4.4-20100427 and gcc-4.3-20100103.
Confirmed - marking as a target bug .
It's caused by r148770, which is when Richard Earnshaw added compressed switch table support for Thumb-1. See also: http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01698.html
Created attachment 20979 [details] proposed fix for PR43961 Update ARM's ADDR_VEC_ALIGN to correctly describe that its ASM_OUTPUT_CASE_LABEL will add a 2-byte alignment directive for Thumb-1 compressed switch tables. This fixes the test cases (both the PR43961 and the PR44603 one) for me. Untested beyond that, will include in full bootstraps and regtests shortly.
*** Bug 44603 has been marked as a duplicate of this bug. ***
Mikael, ping on this patch from June 2010 ... what happened in testing? And shouldn't this bug be marked as a regression, given the identification of the responsible revision?
(In reply to comment #8) > Mikael, ping on this patch from June 2010 ... what happened in testing? I've included this patch in my local 4.6-based branch since June 2010, and it's tested w/o regressions on armv5te ever since (configured w/o --disable-multilib, so I assume the test suite will also test Thumb-1 not just ARM mode). The patch apparently didn't work in a 4.5-based compiler, but I don't have any notes explaining what the issue was. 4.5 is EOL anyway. Somehow I forgot to forward-port it to 4.7 so I haven't tested it yet in my 4.7-based branch. Will do that asap.
If the patch works for mainline, please do send it to gcc-patches as usual.
Created attachment 29133 [details] More complicated fix for 4.6 The previous proposed patch breaks Thumb-2, because alignments for labels get set based on ADDR_VEC_ALIGN before jump tables get shortened from SImode to a narrower mode, and not updated afterwards so there is spurious alignment between a tbb instruction and a jump table. This patch adds code to shorten_branches to allow for this issue. 4.6-based; I'll test for mainline.
Author: jsm28 Date: Tue Jan 15 16:17:28 2013 New Revision: 195208 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195208 Log: 2013-01-15 Joseph Myers <joseph@codesourcery.com> Mikael Pettersson <mikpe@it.uu.se> PR target/43961 * config/arm/arm.h (ADDR_VEC_ALIGN): Align SImode jump tables for Thumb. (ASM_OUTPUT_CASE_LABEL): Remove. (ASM_OUTPUT_BEFORE_CASE_LABEL): Define to empty. * final.c (shorten_branches): Update alignment of labels before jump tables if CASE_VECTOR_SHORTEN_MODE. Modified: trunk/gcc/ChangeLog trunk/gcc/config/arm/arm.h trunk/gcc/final.c
Fixed for 4.8.
GCC 4.6.4 has been released and the branch has been closed.
Fixed for 4.8.0