scripts/gdb: fix debugging modules on s390
Subsystems (2)
PATCH v2 1/1 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().
---
v1 -> v2: print the adjusted address.
scripts/gdb/linux/symbols.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
scripts/gdb/linux/symbols.py +7 -1
@@ -15,7 +15,7 @@ import gdb import os import re -from linux import modules +from linux import modules, utils if hasattr(gdb, 'Breakpoint'):
@@ -111,6 +111,12 @@ lx-symbols command.""" 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(
Signature · 1 line
2.23.0
Quoted 42 lines · Ilya Leoshkevich
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_sizetomodule_addrinload_module_symbols().Signed-off-by Ilya Leoshkevich <[email protected]>---
v1 -> v2: print the adjusted address.
scripts/gdb/linux/symbols.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)scripts/gdb/linux/symbols.py +1
-1@@ -15,7 +15,7 @@ import gdb import os import re -from linux import modules +from linux import modules, utils if hasattr(gdb, 'Breakpoint'):@@ -111,6 +111,12 @@ lx-symbols command.""" module_file = self._get_module_file(module_name)
scripts/gdb/linux/symbols.py lx-symbols command.""" · line 122
Quoted 10 lines
scripts/gdb/linux/symbols.py +6
-0if 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(
Thanks,
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Jan Kiszka
maintainerQuoted 56 lines · Jan Kiszka
Quoted 42 lines · Ilya Leoshkevich
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_sizetomodule_addrinload_module_symbols().Signed-off-by Ilya Leoshkevich <[email protected]>---
v1 -> v2: print the adjusted address.
scripts/gdb/linux/symbols.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)scripts/gdb/linux/symbols.py +1
-1@@ -15,7 +15,7 @@ import gdb import os import re -from linux import modules +from linux import modules, utils if hasattr(gdb, 'Breakpoint'):@@ -111,6 +111,12 @@ lx-symbols command.""" module_file = self._get_module_file(module_name)scripts/gdb/linux/symbols.py lx-symbols command.""" · line 122
Quoted 10 lines
scripts/gdb/linux/symbols.py +6
-0if 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(Reviewed-by Jan Kiszka <[email protected]>
Quoted 3 lines
Thanks,
Jan
Sorry, forgot to CC Andrew for pickup.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux