vector table and the linker with M52235EVB

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

vector table and the linker with M52235EVB

1,943 次查看
vale
Contributor I
Hallo,
I experienced a behaviour of the CodeWarrior linker on my M52235EVB I can't understand.
 
I wrote down an ISR for my UART1 and I wanted to insert its identifier in the vector table at the proper entry.
Find below my first attempt in file MCF52235_vectors.s:
 
/*
 * File: vectors.s
 * Purpose: MCF52235 vector table
 */
#ifdef __GNUC__ /* { */
#define sr %sr
#define _ethernet_handler ethernet_handler
#define _irq_handler      irq_handler
#define _timer_handler    timer_handler
#endif /* } __GNUC__ */
 .global VECTOR_TABLE
 .global _VECTOR_TABLE
 .global start
 .extern ___SP_INIT
 .extern _asm_startmeup
 .extern _asm_exception_handler
 .extern _irq_handler
 .extern _ethernet_handler
 .extern _timer_handler
 .extern _ephy_handler
 .extern _irq1_handler
 .extern _irq4_handler
 .extern _irq7_handler
 .extern _irq11_handler
 .extern rd_uart1_isr
 .text
 
... etc....etc
 
vector4C: .long _irq_handler
vector4D: .long _irq_handler
/*vector4E: .long _irq_handler*/
vector4E: .long rd_uart1_isr       /* UART1 ISR */
vector4F: .long _irq_handler
vector50: .long _irq_handler
 
...etc...etc
 
When I try to compile, I get this message back:
Link Error   : Undefined : "rd_uart1_isr"
Referenced from "start" in mcf52235_vectors.s
Link failed.
 
I next tried this different solution:
 
/*
 * File: vectors.s
 * Purpose: MCF52235 vector table
 */
#ifdef __GNUC__ /* { */
#define sr %sr
#define _ethernet_handler ethernet_handler
#define _irq_handler      irq_handler
#define _timer_handler    timer_handler
#define _rd_uart1_isr   rd_uart1_isr
#endif /* } __GNUC__ */
 
 .global VECTOR_TABLE
 .global _VECTOR_TABLE
 .global start
 .extern ___SP_INIT
 .extern _asm_startmeup
 .extern _asm_exception_handler
 .extern _irq_handler
 .extern _ethernet_handler
 .extern _timer_handler
 .extern _ephy_handler
 .extern _irq1_handler
 .extern _irq4_handler
 .extern _irq7_handler
 .extern _irq11_handler
 .extern _rd_uart1_isr
 .text
 
...etc...etc
 
vector48: .long _irq_handler
vector49: .long _irq_handler
vector4A: .long _irq_handler
vector4B: .long _irq_handler
vector4C: .long _irq_handler
vector4D: .long _irq_handler
/*vector4E: .long _irq_handler*/
vector4E: .long _rd_uart1_isr /* UART1 ISR */
vector4F: .long _irq_handler
vector50: .long _irq_handler
vector51: .long _irq_handler
and it worked.
I don't understand this behaviour....the preprocessor should do his work before linking....
what happens different this time with respect to the previous time?
Thank you for any help.
 
Vale
标签 (1)
0 项奖励
回复
3 回复数

667 次查看
CrasyCat
Specialist III
Hello
 
I assume rd_uart1_isr is implemented in a C source file. Am I right?
If  this is the case, make sure the function is not static.
Then the compiler add a _ prefix to the function name internally.
 
So your assembly source file should look like:
.extern _rd_uart1_isr
 .text
 
... etc....etc
 
vector4C: .long _irq_handler
vector4D: .long _irq_handler
/*vector4E: .long _irq_handler*/
vector4E: .long _rd_uart1_isr       /* UART1 ISR */
vector4F: .long _irq_handler
vector50: .long _irq_handler
 
 
CrasyCat
0 项奖励
回复

667 次查看
vale
Contributor I
You were right,
function rd_uart1_isr is implemented in a C source file and it is not static.
Simply adding a '_' to the name of the function in the vector table and in the .extern declaration
made it work, as you told me.
 
I didn't find any reference on the fact that the compiler adds the '_' internally to the function name.
Could you indicate me where I can find appropriate documentation?
 
Thank you,
Valentina
0 项奖励
回复

667 次查看
CrasyCat
Specialist III
Hello
 
I do not think this is documented anywhere :smileyindifferent:.
Unfortunately.
 
CrasyCat
0 项奖励
回复