diff options
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/arch/armv7/exception.c | 31 | ||||
-rw-r--r-- | payloads/libpayload/arch/armv7/exception_asm.S | 3 |
2 files changed, 27 insertions, 7 deletions
diff --git a/payloads/libpayload/arch/armv7/exception.c b/payloads/libpayload/arch/armv7/exception.c index 9efc312833..8d8b50b175 100644 --- a/payloads/libpayload/arch/armv7/exception.c +++ b/payloads/libpayload/arch/armv7/exception.c @@ -43,20 +43,32 @@ void exception_not_used(uint32_t *); void exception_irq(uint32_t *); void exception_fiq(uint32_t *); +static void dump_stack(uintptr_t addr, size_t bytes) +{ + int i, j; + const int line = 8; + uint32_t *ptr = (uint32_t *)(addr & ~(line * sizeof(*ptr) - 1)); + + printf("Dumping stack:\n"); + for (i = bytes / sizeof(*ptr); i >= 0; i -= line) { + printf("%p: ", ptr + i); + for (j = i; j < i + line; j++) + printf("%08x ", *(ptr + j)); + printf("\n"); + } +} + static void print_regs(uint32_t *regs) { int i; - /* Don't print the link register and stack pointer since we don't have their - * actual value. They are hidden by the 'shadow' registers provided - * by the trap hardware. - */ + for (i = 0; i < 16; i++) { if (i == 15) printf("PC"); else if (i == 14) - continue; /* LR */ + printf("LR"); else if (i == 13) - continue; /* SP */ + printf("SP"); else if (i == 12) printf("IP"); else @@ -69,6 +81,7 @@ void exception_undefined_instruction(uint32_t *regs) { printf("exception _undefined_instruction\n"); print_regs(regs); + dump_stack(regs[13], 512); halt(); } @@ -76,6 +89,7 @@ void exception_software_interrupt(uint32_t *regs) { printf("exception _software_interrupt\n"); print_regs(regs); + dump_stack(regs[13], 512); halt(); } @@ -83,6 +97,7 @@ void exception_prefetch_abort(uint32_t *regs) { printf("exception _prefetch_abort\n"); print_regs(regs); + dump_stack(regs[13], 512); halt(); } @@ -94,6 +109,7 @@ void exception_data_abort(uint32_t *regs) } else { printf("exception _data_abort\n"); print_regs(regs); + dump_stack(regs[13], 512); } halt(); } @@ -102,6 +118,7 @@ void exception_not_used(uint32_t *regs) { printf("exception _not_used\n"); print_regs(regs); + dump_stack(regs[13], 512); halt(); } @@ -109,6 +126,7 @@ void exception_irq(uint32_t *regs) { printf("exception _irq\n"); print_regs(regs); + dump_stack(regs[13], 512); halt(); } @@ -116,6 +134,7 @@ void exception_fiq(uint32_t *regs) { printf("exception _fiq\n"); print_regs(regs); + dump_stack(regs[13], 512); halt(); } diff --git a/payloads/libpayload/arch/armv7/exception_asm.S b/payloads/libpayload/arch/armv7/exception_asm.S index e46f4bcf6b..163fdbd52a 100644 --- a/payloads/libpayload/arch/armv7/exception_asm.S +++ b/payloads/libpayload/arch/armv7/exception_asm.S @@ -79,6 +79,7 @@ exception_common: str sp, exception_handler ldr sp, exception_stack_end push { lr } + stmfd sp, { sp, lr }^ sub sp, sp, $8 push { r0 - r12 } mov r0, sp @@ -86,7 +87,7 @@ exception_common: ldr pc, exception_handler pop { r0 - r12 } add sp, sp, $8 - ldm sp!, { pc }^ + ldmfd sp!, { pc }^ _undefined_instruction: .word exception_undefined_instruction |