arm: remove thumb instruction "bx lr" from EABI binary
Today I had a strange error using the GCC version 4.4.1 with EABI support on a non thumb-ARMv4. Everytime I compiled something, with and w/o the -mno-thumb-interwork parameter it also contained the bx lr instruction which is only for later ARM processors with thumb support.
The only solution seemed to be to patch the GCC. Urgs… not really a nice solution, because recompiling GCC takes 3 stages and much time. After lots of googling I finally found the solution in the Debian Wiki.
GCC will always compile the new bx lr instruction and its the assemblers and linkers part to replace it with a normal call on normal ARMs. The problem is… GCC doesn’t tell the assembler/linker that it needs to do it. So we have to do it:
CFLAGS += -Xlinker --fix-v4bx -Xassembler --fix-v4bx
Later on… It seemed that a lot of apps in OpenWrt didn’t respect my compiler flags, so I needed to patch GCC. You can find the result here: gcc 4.4.1: ARM - save fix-v4bx flag in linker spec (patch is agains OpenWrt). The plain patch against GCC 4.4.1 is here: gcc-save-fix-v4bx-for-linker.patch. If it turns out that this is the correct kind to do it, I’ll send it to the GCC list.