To start with, I used to put exception vectors in the C source file, in the following way:
/* Vector Table */
unsigned int *vectors[12]
__attribute__ ((section(".vectors")))= {
(unsigned int *) START_STACK_TOP,
(unsigned int *) boot_rtos,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) 0x00000000,
(unsigned int *) CM3_SVC
};
That way, I tell gcc to put the array of vectors in the .vectors section. As I use OpenOCD to communicate with the board, using the ARM-USB-OCD, I can download the executable directly from gdb, using the "load" command.
However, I would like to have the vectors defined in an assembly language source file, together with a few of my Cortex M3 specific routines (such as system call handling etc). Therefore I tried to put the vectors in the .s file:
.section .vectors,"aw"
.global CM3_vectors
.extern boot_rtos
CM3_vectors:
.word START_STACK_TOP
.word boot_rtos
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word CM3_handler_svc
.word 0
.word 0
.word CM3_handler_pendsv
However, I initially did not use the "aw" attribute to the .section operator. This resulted in the vectors area being considered a debug symbol when using nm. Therefore, gdb did not download it to the board.
Using the -S flag to gcc, I could examine the assembly output from gcc and that way find out that I should use the "aw" attribute. Apparently GNU as does not apply any default attributes on a section called .vectors.
No comments:
Post a Comment