Re: arm inline assembly 4.8 vs. 4.9 [solved]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/10/2015 6:40 PM, Gene Smith wrote:
The following inline assembly works as I want with gcc 4.8.3 and
produces the result shown:

__asm (
   "ldr r0, =%[addrOfIoPorts]\n"
   :                                /* no output */
   : [addrOfIoPorts] "g" (&ioPorts) /* input */
   : "r0");                         /* clobber */

  801b9e2:    4822          ldr    r0, [pc, #136]

But when compiled with 4.9.3 the linker says "undefined reference to
`r3'. This is because the produced assembly becomes such that r3 looks
like a constant:

ldr r0, =r3

I have been unable to find a modification to the original code that
works with 4.9.3. Any ideas or suggestions?


A helpful reply via emailed suggested the use of other constraints:

"Using "g" allows "Any register, memory or immediate integer operand." Such being the case, have you tried replacing it with each of "m", "r" and "i"? I would expect "m" to work for you."

I replied:

I think I had tried all of these. But tried again.
"m" causes "error: memory input 0 is not directly addressable"

"r" is same as "g": undefined reference to `r3'

"i" worked! Obviously I didn't try this. I should have looked closer in the latest gcc manual under "constraints" -- "i": An immediate integer operand (one with constant value) is allowed. This includes
symbolic constants whose values will be known only at assembly time or
later. (So maybe it was a bug that 4.8.3 worked with "g" in this context?)

No build errors and now see these again in obj dump under 4.9.3:
 801b4c8:    486c          ldr    r0, [pc, #432]    ; (801b67c ...

Thanks!






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux