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
12071207 return near;
12081208 }
12091209
1210+static 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+
12101218 static void default_mismatch_handler(const char *modname, struct elf_info *elf,
12111219 const struct sectioncheck* const mismatch,
12121220 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
12521260 }
12531261 }
12541262
1255−static 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−
12631263 static void extable_mismatch_handler(const char* modname, struct elf_info *elf,
12641264 const struct sectioncheck* const mismatch,
12651265 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