symbolize.py: infer PC from (E)LR

When translating a call stack address to source file and line number,
subtract 2 to try and reflect the PC at the time the call was made or
the exception occurred. This makes the calls easier to follow and
corresponds to what the GDB backtrace command (bt) does. For data or
prefetch aborts it is even more important because now we report exactly
the line that caused the abort instead of showing the next one, which
could be misleading.

As a result of this fix, the extra "nop" instruction in __ta_entry() is
not needed anymore so remove it.

Signed-off-by: Jerome Forissier <jerome@forissier.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/scripts/symbolize.py b/scripts/symbolize.py
index a00962e..91d0681 100755
--- a/scripts/symbolize.py
+++ b/scripts/symbolize.py
@@ -385,7 +385,15 @@
                 post = match.end('addr')
                 self._out.write(line[:pre])
                 self._out.write(addr)
-                res = self.resolve(addr)
+                # The call stack contains return addresses (LR/ELR values).
+                # Heuristic: subtract 2 to obtain the call site of the function
+                # or the location of the exception. This value works for A64,
+                # A32 as well as Thumb.
+                pc = 0
+                lr = int(addr, 16)
+                if lr:
+                    pc = lr - 2
+                res = self.resolve('0x{:x}'.format(pc))
                 res = self.pretty_print_path(res)
                 self._out.write(' ' + res)
                 self._out.write(line[post:])