[LLVMdev] ARM assembler's syntax in clang

Ashi ashi08104 at gmail.com
Thu Mar 7 03:39:15 PST 2013


Hi, Bernie, Thanks for your reply!
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:
ld: illegal text-relocation to _data_table in table.o from foo in
use_table.o for architecture armv7

Do you have any suggestion to solve this? Thanks!

//==begin table.c==
int data_table[] = {0xff, 0xff};
//==end table.c==

//==begin use_table.s ==
        .text
        .syntax unified
        .align   4
        .global   foo
        .thumb
        .thumb_func

foo:
        PUSH {lr}
        @LDR         r0,[PC,#2]
        .long _data_table
        POP {pc}
//==end use_table.s==

//==begin Makefile==
CC = /Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CFLAG = -arch armv7 -mcpu=cortex-a9 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPh
oneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk

all:libtest.dylib

libtest.dylib:table.o use_table.o
        $(CC) -v  -dynamiclib $(CFLAG) $^ -o $@
table.o:table.c
        $(CC) -c $(CFLAG) $^ -o $@
use_table.o:use_table.s
        $(CC) -c -integrated-as $(CFLAG) $^ -o $@
clean:
        rm *.o libtest.dylib test
//==end Makefile==


Cheers,
Ashi


On Wed, Mar 6, 2013 at 11:59 PM, Bernie Ogden <bogden at arm.com> wrote:

> Hi Ashi,****
>
> ** **
>
> 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.****
>
> ** **
>
> 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
> https://github.com/tianocore/edk2/blob/master/ArmPkg/Include/AsmMacroIoLib.h
> .****
>
> ** **
>
> Regards,****
>
> ** **
>
> Bernie****
>
> ** **
>
> ** **
>
> *From:* llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] *On
> Behalf Of *Ashi
> *Sent:* 05 March 2013 04:27
> *To:* Renato Golin
> *Cc:* LLVM List
> *Subject:* Re: [LLVMdev] ARM assembler's syntax in clang****
>
> ** **
>
> Hi, all. The previous post have a typo:
>
> problem in ARM assembly: I use LDR to load an external symbol :
>
> LDR         R7,=DataTable
>
> But clang gives error: unexpected token in operand to the '=',
> Then I change the code to:
>
> LDR         R7,DataTable
>
> 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.
>
> Thanks in advance!
>
> ****
>
> ** **
>
> On Mon, Mar 4, 2013 at 4:48 PM, Ashi <ashi08104 at gmail.com> wrote:****
>
> Hi, all. Another problem in ARM assembly: I use LDR to load an external
> symbol :
>
> LDR         R7,=DataTable
>
> But clang gives error: unexpected token in operand to the '=',
> Then I change the code to:
>
> LDR         R7,=DataTable
>
> The error becomes: unsupported relocation on symbol. How can I get around
> this in clang?
>
> Thanks in advance!****
>
> ** **
>
> On Mon, Feb 25, 2013 at 7:14 PM, Ashi <ashi08104 at gmail.com> wrote:****
>
> Hi,all,
> I've some problem when using clang compile my ARM assembly code:
>
> 1 .qn directive
> In GAS, .qn directive is used to create typed and/or indexed register
> aliases for use in Advanced SIMD Extension (Neon) instructions.(
> http://sourceware.org/binutils/docs/as/ARM-Directives.html#ARM-Directives)
> But clang's integrated-as seems have different syntax, for example, my
> code:
>
> input .qn Q6.F32
>
> Clang would give error: unexpected token in argument list
>
> 2 .unreq
> Clang doesn't recognize .unreq,  my code is as below:
>
> px .req r0
> .unreq px
> px .req r1
>
> clang give error: redefinition of 'px' does not match original.
>
> 3 .end
> clang also doesn't recognize .end directive
>
> 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/
>
> my clang version is: Apple LLVM version 4.2 (clang-425.0.24) (based on
> LLVM 3.2svn)
>
> 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.)
>
> Great Thanks!
>
> ashi****
>
> ashi****
>
> ** **
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130307/a66b2cf3/attachment.html>


More information about the llvm-dev mailing list