我正在尝试使用堆栈 PSP 从用户模式调用 SVC。我在调试 LPC 1769(cortex m3) 上的代码时观察到以下错误------- No source available for "g_pfnVectors() at 0x0" 我使用的 IDE 是来自 Embedded 的带有 LPC 1769 的 CODE RED LPC Xpresso艺术家。
这是汇编代码
.syntax unified
.cpu cortex-m3
.thumb
.align 2
.global Start
.thumb
.thumb_func
Start:
// LDR r0,=0xf00d //initial value of r0 which has to be changed in svc handler
PUSH {lr}
MOV r0,#0x2 // set stack to PSP now. Set CONTROL[1]=1
MSR CONTROL,r0
ISB // Instruction memory barrier – ensures that the above is executed
MOV r0,#0x3 //change to user level
MSR CONTROL, r0
ISB
MOV r0,#0x2
MOV r2,#0x2
exp:
MUL r0,r0
SUBS r2,#1
BNE exp
SVC 1 //print in hex
MOV r0,#0x4 //print in decimal
SVC 2
MOV r0,#'A'
SVC 3 //print character
MOV r1,0x0
MSR CONTROL,r1
ISB
POP {lr}
BX lr
在 SVC 中,我进行堆栈检查并调用相应的函数以在控制台上打印。这是 SVC 代码:
__attribute__ ((section(".after_vectors")))
void SVCall_Handler(void)
{
while(1)
{
__asm(
"TST lr, #4 \n"
"ITE eq \n"
"MRSEQ r0, MSP \n"
"MRSNE r0, PSP \n"
"LDR r0,[r0,#0] \n"
"LDR r1, [r0, #24] \n"
"LDRB r1, [r1, #-2] \n"
//immediate data in r1 and input parameter in r0
//"PUSH {LR} \n"
"CBNZ r1,svc_hex \n"
"B svc_end \n"
"svc_hex: \n"
"CMP r1,#1 \n"
"BNE svc_decimal \n"
" BL printhex \n"
"B svc_end \n"
"svc_decimal: \n"
"CMP r1,#2 \n"
"BNE svc_character \n"
"BL printdecimal \n"
"B svc_end \n"
"svc_character: \n"
"CMP r1,#3 \n"
"BL printcharacter \n"
"B svc_end \n"
"svc_end: \n"
"MOV r0,#0x0 \n"
"MSR CONTROL,r0 \n"
"ISB \n"
"BX LR \n"
);
}
}
printhex/printcaharacter/printdecimal 是用于在控制台上打印相应值的函数。
在调试、单步模式期间,在 SVC 指令之后,出现错误 No source available for "g_pfnVectors() at 0x0" 。
错误的原因和到来是非常出乎意料的。gdb 调试器有什么问题,还是我解释代码的方式有误?