Commit a9bb3e5d authored by Masahiro Yamada's avatar Masahiro Yamada

modpost: remove is_shndx_special() check from section_rel(a)

This check is unneeded. Without it, sec_name() will returns the null
string "", then section_mismatch() will return immediately.

Anyway, special section indices rarely appear in these loops.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 04ed3b47
...@@ -1372,7 +1372,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) ...@@ -1372,7 +1372,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
static void section_rela(const char *modname, struct elf_info *elf, static void section_rela(const char *modname, struct elf_info *elf,
Elf_Shdr *sechdr) Elf_Shdr *sechdr)
{ {
Elf_Sym *sym;
Elf_Rela *rela; Elf_Rela *rela;
Elf_Rela r; Elf_Rela r;
unsigned int r_sym; unsigned int r_sym;
...@@ -1415,11 +1414,8 @@ static void section_rela(const char *modname, struct elf_info *elf, ...@@ -1415,11 +1414,8 @@ static void section_rela(const char *modname, struct elf_info *elf,
continue; continue;
break; break;
} }
sym = elf->symtab_start + r_sym;
/* Skip special sections */ check_section_mismatch(modname, elf, elf->symtab_start + r_sym,
if (is_shndx_special(sym->st_shndx))
continue;
check_section_mismatch(modname, elf, sym,
fsecndx, fromsec, r.r_offset, r.r_addend); fsecndx, fromsec, r.r_offset, r.r_addend);
} }
} }
...@@ -1427,7 +1423,6 @@ static void section_rela(const char *modname, struct elf_info *elf, ...@@ -1427,7 +1423,6 @@ static void section_rela(const char *modname, struct elf_info *elf,
static void section_rel(const char *modname, struct elf_info *elf, static void section_rel(const char *modname, struct elf_info *elf,
Elf_Shdr *sechdr) Elf_Shdr *sechdr)
{ {
Elf_Sym *sym;
Elf_Rel *rel; Elf_Rel *rel;
Elf_Rela r; Elf_Rela r;
unsigned int r_sym; unsigned int r_sym;
...@@ -1474,11 +1469,8 @@ static void section_rel(const char *modname, struct elf_info *elf, ...@@ -1474,11 +1469,8 @@ static void section_rel(const char *modname, struct elf_info *elf,
default: default:
fatal("Please add code to calculate addend for this architecture\n"); fatal("Please add code to calculate addend for this architecture\n");
} }
sym = elf->symtab_start + r_sym;
/* Skip special sections */ check_section_mismatch(modname, elf, elf->symtab_start + r_sym,
if (is_shndx_special(sym->st_shndx))
continue;
check_section_mismatch(modname, elf, sym,
fsecndx, fromsec, r.r_offset, r.r_addend); fsecndx, fromsec, r.r_offset, r.r_addend);
} }
} }
......
...@@ -151,11 +151,6 @@ struct elf_info { ...@@ -151,11 +151,6 @@ struct elf_info {
Elf32_Word *symtab_shndx_stop; Elf32_Word *symtab_shndx_stop;
}; };
static inline int is_shndx_special(unsigned int i)
{
return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE;
}
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */
static inline unsigned int get_secindex(const struct elf_info *info, static inline unsigned int get_secindex(const struct elf_info *info,
const Elf_Sym *sym) const Elf_Sym *sym)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment