Since for arm64 we can load the unit tests at different addresses, then let's make it easier to debug by calculating the PC offset for the user. The offset can then be directly used when looking at the disassembly of the test's elf file. Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> --- arm/flat.lds | 1 + lib/arm64/processor.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/arm/flat.lds b/arm/flat.lds index 4d43cdfeab41..6ed377c0eaa0 100644 --- a/arm/flat.lds +++ b/arm/flat.lds @@ -1,6 +1,7 @@ SECTIONS { + PROVIDE(_text = .); .text : { *(.init) *(.text) *(.text.*) } . = ALIGN(64K); PROVIDE(etext = .); diff --git a/lib/arm64/processor.c b/lib/arm64/processor.c index ef558625e284..831207c16587 100644 --- a/lib/arm64/processor.c +++ b/lib/arm64/processor.c @@ -99,12 +99,19 @@ bool get_far(unsigned int esr, unsigned long *far) return false; } +extern unsigned long _text; + static void bad_exception(enum vector v, struct pt_regs *regs, unsigned int esr, bool esr_valid, bool bad_vector) { unsigned long far; bool far_valid = get_far(esr, &far); unsigned int ec = esr >> ESR_EL1_EC_SHIFT; + uintptr_t text = (uintptr_t)&_text; + + printf("Load address: %" PRIxPTR "\n", text); + printf("PC: %" PRIxPTR " PC offset: %" PRIxPTR "\n", + (uintptr_t)regs->pc, (uintptr_t)regs->pc - text); if (bad_vector) { if (v < VECTOR_MAX) -- 2.26.3