diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/kernel/module.c b/kernel/module.c index 9bf228052ec5..e5538d5f00ad 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1012,6 +1012,12 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs, | |||
1012 | * J. Corbet <corbet@lwn.net> | 1012 | * J. Corbet <corbet@lwn.net> |
1013 | */ | 1013 | */ |
1014 | #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) | 1014 | #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) |
1015 | |||
1016 | static inline bool sect_empty(const Elf_Shdr *sect) | ||
1017 | { | ||
1018 | return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0; | ||
1019 | } | ||
1020 | |||
1015 | struct module_sect_attr | 1021 | struct module_sect_attr |
1016 | { | 1022 | { |
1017 | struct module_attribute mattr; | 1023 | struct module_attribute mattr; |
@@ -1053,8 +1059,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, | |||
1053 | 1059 | ||
1054 | /* Count loaded sections and allocate structures */ | 1060 | /* Count loaded sections and allocate structures */ |
1055 | for (i = 0; i < nsect; i++) | 1061 | for (i = 0; i < nsect; i++) |
1056 | if (sechdrs[i].sh_flags & SHF_ALLOC | 1062 | if (!sect_empty(&sechdrs[i])) |
1057 | && sechdrs[i].sh_size) | ||
1058 | nloaded++; | 1063 | nloaded++; |
1059 | size[0] = ALIGN(sizeof(*sect_attrs) | 1064 | size[0] = ALIGN(sizeof(*sect_attrs) |
1060 | + nloaded * sizeof(sect_attrs->attrs[0]), | 1065 | + nloaded * sizeof(sect_attrs->attrs[0]), |
@@ -1072,9 +1077,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, | |||
1072 | sattr = §_attrs->attrs[0]; | 1077 | sattr = §_attrs->attrs[0]; |
1073 | gattr = §_attrs->grp.attrs[0]; | 1078 | gattr = §_attrs->grp.attrs[0]; |
1074 | for (i = 0; i < nsect; i++) { | 1079 | for (i = 0; i < nsect; i++) { |
1075 | if (! (sechdrs[i].sh_flags & SHF_ALLOC)) | 1080 | if (sect_empty(&sechdrs[i])) |
1076 | continue; | ||
1077 | if (!sechdrs[i].sh_size) | ||
1078 | continue; | 1081 | continue; |
1079 | sattr->address = sechdrs[i].sh_addr; | 1082 | sattr->address = sechdrs[i].sh_addr; |
1080 | sattr->name = kstrdup(secstrings + sechdrs[i].sh_name, | 1083 | sattr->name = kstrdup(secstrings + sechdrs[i].sh_name, |
@@ -1158,7 +1161,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, | |||
1158 | /* Count notes sections and allocate structures. */ | 1161 | /* Count notes sections and allocate structures. */ |
1159 | notes = 0; | 1162 | notes = 0; |
1160 | for (i = 0; i < nsect; i++) | 1163 | for (i = 0; i < nsect; i++) |
1161 | if ((sechdrs[i].sh_flags & SHF_ALLOC) && | 1164 | if (!sect_empty(&sechdrs[i]) && |
1162 | (sechdrs[i].sh_type == SHT_NOTE)) | 1165 | (sechdrs[i].sh_type == SHT_NOTE)) |
1163 | ++notes; | 1166 | ++notes; |
1164 | 1167 | ||
@@ -1174,7 +1177,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, | |||
1174 | notes_attrs->notes = notes; | 1177 | notes_attrs->notes = notes; |
1175 | nattr = ¬es_attrs->attrs[0]; | 1178 | nattr = ¬es_attrs->attrs[0]; |
1176 | for (loaded = i = 0; i < nsect; ++i) { | 1179 | for (loaded = i = 0; i < nsect; ++i) { |
1177 | if (!(sechdrs[i].sh_flags & SHF_ALLOC)) | 1180 | if (sect_empty(&sechdrs[i])) |
1178 | continue; | 1181 | continue; |
1179 | if (sechdrs[i].sh_type == SHT_NOTE) { | 1182 | if (sechdrs[i].sh_type == SHT_NOTE) { |
1180 | nattr->attr.name = mod->sect_attrs->attrs[loaded].name; | 1183 | nattr->attr.name = mod->sect_attrs->attrs[loaded].name; |