Skip to content

Commit

Permalink
modpost: Get proper section index by get_secindex() instead of st_shndx
Browse files Browse the repository at this point in the history
(uint16_t) st_shndx is limited to 65535(i.e. SHN_XINDEX) so sym_get_data() gets
wrong section index by st_shndx if requested symbol contains extended section
index that is more than 65535.  In this case, we need to get proper section index
by .symtab_shndx section.

Module.symvers generated by building kernel with "-ffunction-sections -fdata-sections"
shows the issue.

Fixes: 5606781 ("kbuild: modversions: add infrastructure for emitting relative CRCs")
Fixes: e84f9fb ("modpost: refactor namespace_from_kstrtabns() to not hard-code section name")
Signed-off-by: Xiao Yang <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
yangx-jy authored and masahir0y committed Mar 18, 2020
1 parent 785d74e commit 4b8a5cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ static const char *sec_name(struct elf_info *elf, int secindex)

static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym)
{
Elf_Shdr *sechdr = &info->sechdrs[sym->st_shndx];
unsigned int secindex = get_secindex(info, sym);
Elf_Shdr *sechdr = &info->sechdrs[secindex];
unsigned long offset;

offset = sym->st_value;
Expand Down

0 comments on commit 4b8a5cf

Please sign in to comment.