ARM GCC: MOVT/MOVW reloacations error

Jie Zhang jie@codesourcery.com
Tue Jul 6 05:53:00 GMT 2010


On 07/06/2010 08:50 AM, Pavel Pavlov wrote:
> I'm compiling for armv7 windows mobile (coff-pe). The problem I have is that my build of gcc tries to use MOVT/MOVW in the following case:
>
> static void test_func(){}
>
> void test(struct teststruct * ts)
> {
> 	ts->func = test_func;
> }
>
> The generated asm will be:
> 	...
> 	movw	r4, #:lower16:test_func
> 	movt	r4, #:upper16:test_func
>
> When compiling I get this error:
> GNU assembler version 2.20.51 (arm-mingw32ce) using BFD version (GNU Binutils) 2.20.51.20091016
> test.s: Assembler messages:
> ...
> test.s:10: Error: cannot represent BFD_RELOC_ARM_MOVW relocation in this object file format
> test.s:11: Error: cannot represent BFD_RELOC_ARM_MOVT relocation in this object file format
> ...
>
>
> basically, it simply fails in my case because such asm cannot work on windows, and I'm not sure if such thing can work anywhere else.

ARM ELF targets use movw/movt. But apparently binutils for ARM COFF 
targets cannot handle such relocations. So I think it might be a good to 
disable it for ARM COFF targets.

> Can somebody maybe recommend where I need to look for in gcc code to make gcc not generate movw/movt sequences for functions (or anything else that isn't a real constant at compile time)?
>
You could try this draft patch.


Regards,
-- 
Jie Zhang
CodeSourcery
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ttt-gcc-arm-coff-not-use-movt.diff
Type: text/x-patch
Size: 472 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20100706/c9dff0af/attachment.bin>


More information about the Gcc-help mailing list