iPhone assembly, compilation error with LDR parameters-Collection of common programming errors
I’m trying to compile some assembly code (as part of Theora library) using XCode 4.2 and Apple LLVM compiller 3.0 (no thumb), but there are some errors in ldr(ne) instructions:
.text
.set DEC_OPB, 0xC944
ldrne r2, =258014 @ ERROR: Unsupported relocation on symbol L0. ERROR: Undefined local symbol 0 (0f or 0b)
ldr r6, =0x00800080 @ ERROR: Unsupported relocation on symbol L0.
ldr r5, =DEC_OPB @ ERROR: Unsupported relocation on symbol L0. ERROR: Undefined local symbol 0 (0f or 0b)
ldr r5, DEC_OPB @ ERROR: Bad immediate value for offset (51024). ERROR: Unsupported relocation on symbol (null)
Is it possible to override those lines with some other instructions? Or to replace them with constants? Please help, because this post llvm-gcc assembler: LDR syntax didn’t help me to solve this problem.
-
.text .set DEC_OPB, 0xC944 ldrne r2,r2num ldr r6,r6num ldr r5,r5num ... r2num: .word 258014 r6num: .word 0x00800080 r5num: .word DEC_OPB
when you do the ldr r2,=0x1234, the assembler looks for a place nearby to place that number and then uses a pc relative address to load it. If the assembler cannot find a place you get an error, I dont know if that is what the complaint was about. doesnt sound like the right error. The two solutions are the above where you explicitly place the values and not rely on the assembler, or you put a .pool or other similar directive in a branch shadow or some other place that you wont execute through to encourage the assembler to use it to place these kinds of constants.
b somewhere .pool
I suspect from the error message something else may be going. post a reply or edit or question if that is the case.
-
The iOS assembler does not support the
=258014
pseudo-immediate form. You will need to either replace these with loads from a constant pool, or split them intomov
+movt
.You should also file a bug report to request that support be added.
Originally posted 2013-11-09 23:23:26.