0

I want to get the label's address of C language in armcc[rvct 3.1] build enviroment.

such as:

void func()
{
    int * aptr;
LABEL:
    ....
    goto LABEL;
}

if in VC env,get it like this(use assembly ins :offset):

void func()
{
    void * aptr;
    __asm{ mov [aptr],offset LABEL };

LABEL:
    ....
    __asm{ jmp aptr};
}

and if in GCC env,get it like this(use &&):

void func()
{
    void * ptr = &&LABEL;

LABEL:
    ....
    goto *aptr;
}

but in armcc env,who can tell me how to get? I am not familiar with ARMCC assembly.thks

nix
  • 1
  • 1

2 Answers2

0

This is not necessarily possible at all. Depending on the compiler there will be no way to do this.

Why don't you compile to assembler and look at the assembler output?

Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38
  • because msg is too long, pls refer to the second answer which is answered by myself.thks for your help – nix Nov 22 '13 at 07:05
0

looking up the "rvct compiler user guide" it mentions using ldr /adr /adrl instructions to get the label's address,and I try these instructions in __asm{....} way one by one ,all compile failed. such as:

__asm
{
    ldr r0,LABEL  //Error: #20 identifier "LABEL" is undefined
    //ldr r0,LABEL  //Error: #20 identifier "LABEL" is undefined
                    //Error: #1097:Expected [ or ]
    //ldr r0,=LABEL //Error: #20 identifier "LABEL" is undefined
                    //Error: #1097:Expected [ or ]                    
LABEL:      //LABEL is here!
}

.....blablabla

adr/adrl instructions give errors,too. i'm stranger to compiler and assembly language.i have no idea

nix
  • 1
  • 1