* [PATCH v2] scripts/gdb: fix debugging modules on s390
@ 2019-10-17 8:59 Ilya Leoshkevich
2019-10-17 14:11 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Ilya Leoshkevich @ 2019-10-17 8:59 UTC (permalink / raw)
To: Jan Kiszka, Kieran Bingham, linux-kernel, linux-s390
Cc: Heiko Carstens, Vasily Gorbik, 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_size to module_addr in
load_module_symbols().
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
v1 -> v2: print the adjusted address.
scripts/gdb/linux/symbols.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
index f0d8f2ecfde7..df4c810de663 100644
--- a/scripts/gdb/linux/symbols.py
+++ b/scripts/gdb/linux/symbols.py
@@ -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(
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] scripts/gdb: fix debugging modules on s390
2019-10-17 8:59 [PATCH v2] scripts/gdb: fix debugging modules on s390 Ilya Leoshkevich
@ 2019-10-17 14:11 ` Jan Kiszka
2019-10-17 14:12 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2019-10-17 14:11 UTC (permalink / raw)
To: Ilya Leoshkevich, Kieran Bingham, linux-kernel, linux-s390
Cc: Heiko Carstens, Vasily Gorbik
On 17.10.19 10:59, Ilya Leoshkevich wrote:
> 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().
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>
> v1 -> v2: print the adjusted address.
>
> scripts/gdb/linux/symbols.py | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
> index f0d8f2ecfde7..df4c810de663 100644
> --- a/scripts/gdb/linux/symbols.py
> +++ b/scripts/gdb/linux/symbols.py
> @@ -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(
>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Thanks,
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] scripts/gdb: fix debugging modules on s390
2019-10-17 14:11 ` Jan Kiszka
@ 2019-10-17 14:12 ` Jan Kiszka
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2019-10-17 14:12 UTC (permalink / raw)
To: Ilya Leoshkevich, Kieran Bingham, linux-kernel, linux-s390,
Andrew Morton
Cc: Heiko Carstens, Vasily Gorbik
On 17.10.19 16:11, Jan Kiszka wrote:
> On 17.10.19 10:59, Ilya Leoshkevich wrote:
>> 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().
>>
>> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
>> ---
>>
>> v1 -> v2: print the adjusted address.
>>
>> scripts/gdb/linux/symbols.py | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py
>> index f0d8f2ecfde7..df4c810de663 100644
>> --- a/scripts/gdb/linux/symbols.py
>> +++ b/scripts/gdb/linux/symbols.py
>> @@ -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(
>>
>
> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
>
> Thanks,
> Jan
>
Sorry, forgot to CC Andrew for pickup.
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-17 14:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 8:59 [PATCH v2] scripts/gdb: fix debugging modules on s390 Ilya Leoshkevich
2019-10-17 14:11 ` Jan Kiszka
2019-10-17 14:12 ` Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).