<div dir="ltr">Hi, Bernie, Thanks for your reply!<br>However, I still have problem by following edk2's code, my test code is attached, what I want to do is build it as a dynamic lib. But I get error from ld:<br>ld: illegal text-relocation to _data_table in table.o from foo in use_table.o for architecture armv7<br>
<br>Do you have any suggestion to solve this? Thanks!<br><br>//==begin table.c==<br>int data_table[] = {0xff, 0xff};<br>//==end table.c==<br><br>//==begin use_table.s ==<br>        .text<br>        .syntax unified<br>        .align   4<br>
        .global   foo<br>        .thumb<br>        .thumb_func<br><br>foo:<br>        PUSH {lr}<br>        @LDR         r0,[PC,#2]<br>        .long _data_table<br>        POP {pc}<br>//==end use_table.s==<br><br>//==begin Makefile==<br>
CC = /Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang<br>CFLAG = -arch armv7 -mcpu=cortex-a9 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPh<br>oneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk <br>
<br>all:libtest.dylib <br><br>libtest.dylib:table.o use_table.o<br>        $(CC) -v  -dynamiclib $(CFLAG) $^ -o $@<br>table.o:table.c<br>        $(CC) -c $(CFLAG) $^ -o $@<br>use_table.o:use_table.s<br>        $(CC) -c -integrated-as $(CFLAG) $^ -o $@<br>
clean:<br>        rm *.o libtest.dylib test<br>//==end Makefile==<br><br><br>Cheers,<br>Ashi<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 6, 2013 at 11:59 PM, Bernie Ogden <span dir="ltr"><<a href="mailto:bogden@arm.com" target="_blank">bogden@arm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-GB"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Ashi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Your first LDR is a pseudoinstruction that is supported by some tools (gas and armasm, at least), but not by LLVM. Roughly speaking, it turns into a PC-relative load from a literal pool.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">To do what you're trying to achieve you can write your own literal pool in your assembly. You can see some examples of this sort of thing at <a href="https://github.com/tianocore/edk2/blob/master/ArmPkg/Include/AsmMacroIoLib.h" target="_blank">https://github.com/tianocore/edk2/blob/master/ArmPkg/Include/AsmMacroIoLib.h</a>.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Bernie<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:llvmdev-bounces@cs.uiuc.edu" target="_blank">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu" target="_blank">llvmdev-bounces@cs.uiuc.edu</a>] <b>On Behalf Of </b>Ashi<br>
<b>Sent:</b> 05 March 2013 04:27<br><b>To:</b> Renato Golin<br><b>Cc:</b> LLVM List<br><b>Subject:</b> Re: [LLVMdev] ARM assembler's syntax in clang<u></u><u></u></span></p></div></div><div><div class="h5"><p class="MsoNormal">
<u></u> <u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt">Hi, all. The previous post have a typo:<br><br>problem in ARM assembly: I use LDR to load an external symbol :<br><br>LDR         R7,=DataTable<br>
<br>But clang gives error: unexpected token in operand to the '=', <br>Then I change the code to:<br><br>LDR         R7,DataTable<br><br>The error becomes: unsupported relocation on symbol. How can I get around this in clang? My problem is actually how to load external symbol in Clang's integrated-as? I've tried to learn some trivial c code's assembly output, but find there are many linker related symbol and really confusing.<br>
<br>Thanks in advance!<br><br><u></u><u></u></p></div><div><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p><div><p class="MsoNormal">On Mon, Mar 4, 2013 at 4:48 PM, Ashi <<a href="mailto:ashi08104@gmail.com" target="_blank">ashi08104@gmail.com</a>> wrote:<u></u><u></u></p>
<div><p class="MsoNormal">Hi, all. Another problem in ARM assembly: I use LDR to load an external symbol :<br><br>LDR         R7,=DataTable<br><br>But clang gives error: unexpected token in operand to the '=', <br>
Then I change the code to:<br><br>LDR         R7,=DataTable<br><br>The error becomes: unsupported relocation on symbol. How can I get around this in clang? <br><br>Thanks in advance!<u></u><u></u></p><div><div><div><p class="MsoNormal">
<u></u> <u></u></p><div><p class="MsoNormal">On Mon, Feb 25, 2013 at 7:14 PM, Ashi <<a href="mailto:ashi08104@gmail.com" target="_blank">ashi08104@gmail.com</a>> wrote:<u></u><u></u></p><div><p class="MsoNormal">Hi,all,<br>
I've some problem when using clang compile my ARM assembly code:<br><br>1 .qn directive<br>In GAS, .qn directive is used to create typed and/or indexed register aliases for use in Advanced SIMD Extension (Neon) instructions.(<a href="http://sourceware.org/binutils/docs/as/ARM-Directives.html#ARM-Directives" target="_blank">http://sourceware.org/binutils/docs/as/ARM-Directives.html#ARM-Directives</a>)<br>
But clang's integrated-as seems have different syntax, for example, my code:<br><br>input .qn Q6.F32 <br><br>Clang would give error: unexpected token in argument list<br><br>2 .unreq<br>Clang doesn't recognize .unreq,  my code is as below:<br>
<br>px .req r0<br>.unreq px<br>px .req r1<br><br>clang give error: redefinition of 'px' does not match original.<br><br>3 .end<br>clang also doesn't recognize .end directive<br><br>all my code is compiled by: clang -arch armv7 -v -integrated-as -g -mcpu=cortex-a9 -mfpu=neon -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/<br>
<br>my clang version is: Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)<br><br>BTW, could any tell me which files implement integrated-as in clang source code, I think it may also help me by looking the source code(I've tried 'grep', but with no success.)<br>
<br>Great Thanks!<span style="color:#888888"><br><br>ashi</span><u></u><u></u></p></div></div></div></div><p class="MsoNormal"><span><span style="color:#888888">ashi</span></span><u></u><u></u></p></div></div></div><p class="MsoNormal">
<u></u> <u></u></p></div></div></div></div></div></div></blockquote></div><br></div>