Skip to content

Commit e0349c4

Browse files
ordexakpm00
authored andcommitted
scripts/gdb/linux/symbols.py: address changes to module_sect_attrs
When loading symbols from kernel modules we used to iterate from 0 to module_sect_attrs::nsections, in order to retrieve their name and address. However module_sect_attrs::nsections has been removed from the struct by a previous commit. Re-arrange the iteration by accessing all items in module_sect_attrs::grp::bin_attrs[] until NULL is found (it's a NULL terminated array). At the same time the symbol address cannot be extracted from module_sect_attrs::attrs[]::address anymore because it has also been deleted. Fetch it from module_sect_attrs::grp::bin_attrs[]::private as described in 4b2c11e. Link: https://lkml.kernel.org/r/20250221204034.4430-1-antonio@mandelbit.com Fixes: d8959b9 ("module: sysfs: Drop member 'module_sect_attrs::nsections'") Fixes: 4b2c11e ("module: sysfs: Drop member 'module_sect_attr::address'") Signed-off-by: Antonio Quartulli <antonio@mandelbit.com> Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com> Cc: Thomas Weißschuh <linux@weissschuh.net> Cc: Kieran Bingham <kbingham@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent f873136 commit e0349c4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

scripts/gdb/linux/symbols.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import re
1717

18+
from itertools import count
1819
from linux import modules, utils, constants
1920

2021

@@ -95,10 +96,14 @@ def _section_arguments(self, module, module_addr):
9596
except gdb.error:
9697
return str(module_addr)
9798

98-
attrs = sect_attrs['attrs']
99-
section_name_to_address = {
100-
attrs[n]['battr']['attr']['name'].string(): attrs[n]['address']
101-
for n in range(int(sect_attrs['nsections']))}
99+
section_name_to_address = {}
100+
for i in count():
101+
# this is a NULL terminated array
102+
if sect_attrs['grp']['bin_attrs'][i] == 0x0:
103+
break
104+
105+
attr = sect_attrs['grp']['bin_attrs'][i].dereference()
106+
section_name_to_address[attr['attr']['name'].string()] = attr['private']
102107

103108
textaddr = section_name_to_address.get(".text", module_addr)
104109
args = []

0 commit comments

Comments
 (0)