History

modpost: clean up is_executable_section()

SHF_EXECINSTR is a bit flag (#define SHF_EXECINSTR 0x4). Compare the masked flag to '!= 0'. There is no good reason to stop modpost immediately even if a special section index is given. You will get a section mismatch error anyway. Also, change the return type to bool.

Masahiro Yamada committed 3 years ago

Commit f4c35481 parent fc5fa861 file · +8 −8Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/mod/modpost.c+8−8
@@ -1207,6 +1207,14 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, · 1206 unmodified lines
1207 return near;1207 return near;
1208}1208}
1209 1209
1210static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
1211{
1212 if (secndx > elf->num_sections)
1213 return false;
1214
1215 return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;
1216}
1217
1210static void default_mismatch_handler(const char *modname, struct elf_info *elf,1218static void default_mismatch_handler(const char *modname, struct elf_info *elf,
1211 const struct sectioncheck* const mismatch,1219 const struct sectioncheck* const mismatch,
1212 Elf_Rela *r, Elf_Sym *sym, const char *fromsec)1220 Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
@@ -1252,14 +1260,6 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, · 39 unmodified lines
1252 }1260 }
1253}1261}
1254 1262
1255static int is_executable_section(struct elf_info* elf, unsigned int section_index)
1256{
1257 if (section_index > elf->num_sections)
1258 fatal("section_index is outside elf->num_sections!\n");
1259
1260 return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR);
1261}
1262
1263static void extable_mismatch_handler(const char* modname, struct elf_info *elf,1263static void extable_mismatch_handler(const char* modname, struct elf_info *elf,
1264 const struct sectioncheck* const mismatch,1264 const struct sectioncheck* const mismatch,
1265 Elf_Rela* r, Elf_Sym* sym,1265 Elf_Rela* r, Elf_Sym* sym,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t