{"id":1098,"date":"2022-08-30T15:12:21","date_gmt":"2022-08-30T15:12:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/iphone-assembly-compilation-error-with-ldr-parameters-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:12:21","modified_gmt":"2022-08-30T15:12:21","slug":"iphone-assembly-compilation-error-with-ldr-parameters-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/iphone-assembly-compilation-error-with-ldr-parameters-collection-of-common-programming-errors\/","title":{"rendered":"iPhone assembly, compilation error with LDR parameters-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;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:<\/p>\n<pre><code>.text\n.set DEC_OPB, 0xC944\nldrne   r2, =258014     @ ERROR: Unsupported relocation on symbol L0. ERROR: Undefined local symbol 0 (0f or 0b)\nldr r6, =0x00800080     @ ERROR: Unsupported relocation on symbol L0.\nldr r5, =DEC_OPB        @ ERROR: Unsupported relocation on symbol L0. ERROR: Undefined local symbol 0 (0f or 0b)\nldr r5, DEC_OPB         @ ERROR: Bad immediate value for offset (51024). ERROR: Unsupported relocation on symbol (null)\n<\/code><\/pre>\n<p>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&#8217;t help me to solve this problem.<\/p>\n<ol>\n<li>\n<pre><code>.text \n.set DEC_OPB, 0xC944 \nldrne r2,r2num \nldr r6,r6num \nldr r5,r5num \n...\n\nr2num: .word 258014\nr6num: .word 0x00800080\nr5num: .word DEC_OPB\n<\/code><\/pre>\n<p>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.<\/p>\n<pre><code>b somewhere\n.pool\n<\/code><\/pre>\n<p>I suspect from the error message something else may be going. post a reply or edit or question if that is the case.<\/p>\n<\/li>\n<li>\n<p>The iOS assembler does not support the <code>=258014<\/code> pseudo-immediate form. You will need to either replace these with loads from a constant pool, or split them into <code>mov<\/code> + <code>movt<\/code>.<\/p>\n<p>You should also file a bug report to request that support be added.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:23:26. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1098","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1098"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1098\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}