diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2020-05-25 14:47:05 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2020-05-29 03:08:49 +0900 |
commit | 565587d8d5b518234652063820561587fc269c11 (patch) | |
tree | f4f7b5db837c2722e8e423021fac55d79c47e9eb /scripts/mod | |
parent | d2e4d05cf1a1f8bfe168ea29b217355be7a4e9ec (diff) | |
download | lwn-565587d8d5b518234652063820561587fc269c11.tar.gz lwn-565587d8d5b518234652063820561587fc269c11.zip |
modpost: refactor sech_name()
Use sym_get_data_by_offset() helper to get access to the .shstrtab
section data. No functional change is intended because
elf->sechdrs[elf->secindex_strings].sh_addr is 0 for both ET_REL
and ET_EXEC object types.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/modpost.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8c5f1bd75481..160139508821 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -288,18 +288,6 @@ static enum export export_no(const char *s) return export_unknown; } -static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) -{ - return (void *)elf->hdr + - elf->sechdrs[elf->secindex_strings].sh_offset + - sechdr->sh_name; -} - -static const char *sec_name(struct elf_info *elf, int secindex) -{ - return sech_name(elf, &elf->sechdrs[secindex]); -} - static void *sym_get_data_by_offset(const struct elf_info *info, unsigned int secindex, unsigned long offset) { @@ -317,6 +305,17 @@ static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) sym->st_value); } +static const char *sech_name(const struct elf_info *info, Elf_Shdr *sechdr) +{ + return sym_get_data_by_offset(info, info->secindex_strings, + sechdr->sh_name); +} + +static const char *sec_name(const struct elf_info *info, int secindex) +{ + return sech_name(info, &info->sechdrs[secindex]); +} + #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) static enum export export_from_secname(struct elf_info *elf, unsigned int sec) |