0

I have a project which is already built for ARM cortex M4 using Atollic arm-atollic-eabi tool chain. Now I am trying to build the same project for Windows. I am using Atollic PC tools, which I think uses GCC and G++ internally.

I have removed all the dependency of hardware which was there in the code by stubbing almost all such calls. Now there is no any compilation error but one i.e. no such instruction: ldr r13,[r1]. My source is not using any such instruction explicitly.

This is the compiler log.

C:\Users\...\AppData\Local\Temp\ccFTr3cX.s: Assembler messages:
C:\Users\...\AppData\Local\Temp\ccFTr3cX.s:3773: Error: no such instruction: `ldr r13,[r1]'
  • I have removed all the external libraries and hardware dependency of my target controller i.e. FYI Kinetis K61FX512VMJ150
  • I have not yet tried with other compiler tool-chain as I am dependent on this Atollic IDE and it's provided tool chain.

  • There is no as such code to show.

  • But as an extra info, the software on the target is a multi-threaded application and I have also removed all the RTOS dependency.

  • I expect my code to be built on PC which is Intel core I5 currently, but I am not restricted to that either.

Aksen P
  • 4,564
  • 3
  • 14
  • 27
  • 1
    the compiler seems to compile the assembly file "ccFTr3cX.s". Is this intentionally? can you please dump the content of this file? – nivpeled Jul 11 '19 at 07:02
  • I would search all codebase for `asm` keyword. Because it is not necessarily `ldr r13,[r1]` string in source code which can be converted to this asm instruction. – sklott Jul 11 '19 at 07:39
  • 1
    Is the Atollic PC tools IDE configured to compile C into ARM binaries instead of Intel? – Gerhardh Jul 11 '19 at 07:53
  • @sklott: There's no way that x86 GCC could have substituted `r1` into an asm template. That's not an x86-64 register name. (`r13` is, though.) But sure it might be the result of preprocessor tricks. – Peter Cordes Jul 11 '19 at 08:14
  • @Gerhardh: if the problem was a C -> arm asm compiler but an x86 assembler, the first error message would have happened *much* sooner. Unless there were 3770 lines of non-code data directives before it got to that LDR. But that LDR wouldn't be the first instruction of a function. R13 is the stack pointer so the compiler is never going to reload the stack pointer from a pointer function arg. – Peter Cordes Jul 11 '19 at 08:18
  • @nivpeled the file goes into temp directory. So I am not able to get that file. – Preet Mehta Jul 11 '19 at 10:02
  • @sklott already done. There is none such __asm or asm instruction such. I have kept some intention __asm("cpsie d") and opposite under undefined macro. – Preet Mehta Jul 11 '19 at 10:03
  • @Gerhardh Atollic PC tools IDE is configured to use it's internal GCC for C and is not supposed to generate ARM binaries. I have taken measured actions related to it. – Preet Mehta Jul 11 '19 at 10:05
  • @sklott still I will recheck. – Preet Mehta Jul 11 '19 at 10:10

1 Answers1

2

Do your project use any ARM inline asm? Obviously that won't work when targeting x86-64.

GCC does compile C/C++ source to a temp .s file and then assemble that separately, so an error like this (including the ...\Temp\ccFTr3cX.s path) is exactly what you'd expect if you missed an asm statement somewhere.

It's probably not an Extended asm statement with input/output constraints, otherwise the compiler probably would have substituted in ldr eax, [rcx] or something. But either way you're looking for an asm or __asm__ token in the C++ source file that Temp\ccFTr3cX.s was built from.

Look in the build logs to see, or use gcc -save-temps so you can more easily look at that .s and see which source file it was built from.


R13 is the ARM32 stack pointer, so this code is likely part of a context-switch function. It's very rare that you'd ever load a new stack pointer value from memory otherwise.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847