Skip to content

Commit

Permalink
scripts/gdb: fix debugging modules on s390
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
iii-i authored and torvalds committed Oct 19, 2019
1 parent aa5de30 commit 585d730
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/gdb/linux/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
import re

from linux import modules
from linux import modules, utils


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

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

0 comments on commit 585d730

Please sign in to comment.