Linker error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Linker error

7,385件の閲覧回数
iam
Contributor I
Hi all !
 
I am getting an error when compiling a C application with references to an assembly function. Asm functions are defined in .s file and declared as extern in .c file. The linker error is undefined reference to ASM function.
 
Here are code:
jtag.s
Code:
; ================================================; Function : JTAG_Read_Bkru ; ================================================; input parameters; r0 : address of the register to read ; ================================================; output parameters; r1 : address to store the result  ; ================================================; r4 : used by TDO, TDI, TCK, TMS ; r5 : used by TDO, TDI, TCK, TMS; r6 : address bitmask ; r7 : output bitmask ; r8 : output value; r9 : scratch register; r10 : used to clear TDIJTAG_Read_Bkru INIT_JTAG MOV r6, #1  ; init address bitMask   MOV r7, #1  ; init output bitMask   MOV r8, #0 MOV r10, #0...

 
jtag.h
Code:
...extern void JTAG_Read_Bkru(unsigned char address, unsigned int *data);...

jtag.c
Code:
...unsigned int JTAG_Read_Debug_Status(){  unsigned int value;  //* Select ICEBreaker Scan Chain JTAG_Select_Scan_Chain(ICE_BREAKER);  //* Read the Debug Status register JTAG_Read_Bkru(ICE_DBG_STS, &value); return (value & ICE_DBG_STS_MASK);}...

It seems that .s file is not passed into linker. But .s file is in project.
Could you please help me with this problem ?
 
Thanks.
ラベル(1)
0 件の賞賛
返信
11 返答(返信)

2,407件の閲覧回数
CrasyCat
Specialist III

Hello

OK I took a look at the project you have attached.
Apparently you are targeting an ARM core. Am I right?

Build tools delivered with CodeWarrior for ARM are not supported and maintained by
Freescale.
You will have to request some help from ARM. They will be able to assist you in programming with their build tools.
Sorry for the confusion, I did not check first which CPU you were targeting.

CrasyCat

0 件の賞賛
返信

2,407件の閲覧回数
iam
Contributor I
Yes, you are right.
 
Thank you. Sorry for the lost time.
0 件の賞賛
返信

2,407件の閲覧回数
J2MEJediMaster
Specialist I
I'm looking at some HC12 assembly code here, and you need to use a XDEF declaration to make the function's name visible to other files. To wit:

XDEF JTAG_Read_Bkru

Your assembler may use the same declaration or something similar.

---Tom
0 件の賞賛
返信

2,407件の閲覧回数
CrasyCat
Specialist III

Hello

I am missing a little bit of context information here.

However, did you tell the label JTAG_Read_Bkru should be visible outside of the .s file?
Just add a

  xref JTAG_Read_Bkru


in your assembly source file.
 

CrasyCat

0 件の賞賛
返信

2,407件の閲覧回数
iam
Contributor I
Yes, JTAG_Read_Bkru should be visible outside the .s file.
 
The line you proposed to add is already exist in assembly file. But with some differences. 'EXTERN' is used instead of 'xref'. (i use Metrowerks CodeWarrior)
 
Thanks,
iam
0 件の賞賛
返信

2,407件の閲覧回数
J2MEJediMaster
Specialist I
OK, if EXTERN is being used in the assembly file for JTAG_Read_Bkru, that says the symbol and code are defined somewhere *other than this file*.

What you're wanting to do is *export* the symbol of the JTAG_Read_Bkru from this file, so that the function is visible to other the files. So you either need to use the 'XDEF' or 'XREF' (Crasycat's suggestion) declaration. Replace the EXTERN in the assembly file with either of these.

---Tom
0 件の賞賛
返信

2,407件の閲覧回数
iam
Contributor I
I have tried to use XDEF and XREF instead. The result was the same (
0 件の賞賛
返信

2,407件の閲覧回数
CrasyCat
Specialist III

Hello

Please send a whole project reproducing the trouble.

We will not be able to move forward without  a real project

CrasyCat

0 件の賞賛
返信

2,407件の閲覧回数
iam
Contributor I

Hello,

here is CW project reproducing error...

Thanks,

iam

0 件の賞賛
返信

2,407件の閲覧回数
J2MEJediMaster
Specialist I
OK... Is the assembler generating an object file?

---Tom
0 件の賞賛
返信

2,407件の閲覧回数
CrasyCat
Specialist III

Hello

Oups  I had a typo in my last message. In fact you HAVE to use XDEF not XREF in your assembly source file.

Sorry about the confusion.

I am not sure EXTERN is supported.

CrasyCat

0 件の賞賛
返信