From 208182add858ae66560fa8b238a161c2977a1279 Mon Sep 17 00:00:00 2001
From: wadesong <wadesong@codeaurora.org>
Date: Fri, 10 Aug 2018 18:05:17 +0800
Subject: [PATCH] lrdp-v2: Fix some symbol loading issues on ARM-32 platforms

1) When lrdp-v2 is parsing RAM dumps generated on ARM-32 platforms,
   the Trace32 startup script will not contain any instructions
   to enable MMU support, which causes Linux kernel symbol loading
   failure on some newer Trace32 simulators.

   Add Trace32 startup instruction to set bit 0 of P15:0x1 if
   lrdp-v2 detects MMU support within the RAM dump.

2) Use task.symbol.loadmod instead of data.load.elf to load all
   the kernel moduels' symbols to avoid symbol loading failures.

Change-Id: Ibae79e3c80279788d7cccd28080d2cecd5432a4b
---
 linux-ramdump-parser-v2/ramdump.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/linux-ramdump-parser-v2/ramdump.py b/linux-ramdump-parser-v2/ramdump.py
index cd78d9e..1af0295 100644
--- a/linux-ramdump-parser-v2/ramdump.py
+++ b/linux-ramdump-parser-v2/ramdump.py
@@ -1003,6 +1003,12 @@ class RamDump():
                 startup_script.write('mmu.on\n'.encode('ascii', 'ignore'))
                 startup_script.write('mmu.pt.list 0xffffff8000000000\n'.encode('ascii', 'ignore'))
             else:
+                # ARM-32: MMU is enabled by default on most platforms.
+                mmu_enabled = 1
+                if self.mmu is None:
+                    mmu_enabled = 0
+                startup_script.write(
+                    'PER.S.F C15:0x1 %L 0x{0:x}\n'.format(mmu_enabled).encode('ascii', 'ignore'))
                 startup_script.write(
                     'PER.S.F C15:0x2 %L 0x{0:x}\n'.format(self.mmu.ttbr).encode('ascii', 'ignore'))
                 if isinstance(self.mmu, Armv7LPAEMMU):
@@ -1062,9 +1068,8 @@ class RamDump():
             mod_sym_path = mod_tbl_ent.get_sym_path()
             if mod_sym_path != '':
                 where = os.path.abspath(mod_sym_path)
-                where += ' 0x{0:x}'.format(mod_tbl_ent.module_offset)
-                dloadelf = 'data.load.elf {} /nocode /noclear\n'.format(where)
-                startup_script.write(dloadelf.encode('ascii', 'ignore'))
+                ld_mod_sym = 'task.symbol.loadmod "{}"\n'.format(where)
+                startup_script.write(ld_mod_sym.encode('ascii', 'ignore'))
 
         if not self.minidump:
             startup_script.write('task.dtask\n'.encode('ascii', 'ignore'))
-- 
GitLab