Skip to content

Commit 585d730

Browse files
iii-itorvalds
authored andcommitted
scripts/gdb: fix debugging modules on s390
Currently lx-symbols assumes that module text is always located at module->core_layout->base, but s390 uses the following layout: +------+ <- module->core_layout->base | GOT | +------+ <- module->core_layout->base + module->arch->plt_offset | PLT | +------+ <- module->core_layout->base + module->arch->plt_offset + | TEXT | module->arch->plt_size +------+ Therefore, when trying to debug modules on s390, all the symbol addresses are skewed by plt_offset + plt_size. Fix by adding plt_offset + plt_size to module_addr in load_module_symbols(). Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ilya Leoshkevich <[email protected]> Reviewed-by: Jan Kiszka <[email protected]> Cc: Kieran Bingham <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Vasily Gorbik <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent aa5de30 commit 585d730

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

scripts/gdb/linux/symbols.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import os
1616
import re
1717

18-
from linux import modules
18+
from linux import modules, utils
1919

2020

2121
if hasattr(gdb, 'Breakpoint'):
@@ -116,6 +116,12 @@ def load_module_symbols(self, module):
116116
module_file = self._get_module_file(module_name)
117117

118118
if module_file:
119+
if utils.is_target_arch('s390'):
120+
# Module text is preceded by PLT stubs on s390.
121+
module_arch = module['arch']
122+
plt_offset = int(module_arch['plt_offset'])
123+
plt_size = int(module_arch['plt_size'])
124+
module_addr = hex(int(module_addr, 0) + plt_offset + plt_size)
119125
gdb.write("loading @{addr}: {filename}\n".format(
120126
addr=module_addr, filename=module_file))
121127
cmdline = "add-symbol-file {filename} {addr}{sections}".format(

0 commit comments

Comments
 (0)