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.
Unified · Split
| @@ -1207,6 +1207,14 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, · 1206 unmodified lines | ||
| 1207 | 1207 | return near; |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 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 | + | |
| 1210 | 1218 | static void default_mismatch_handler(const char *modname, struct elf_info *elf, |
| 1211 | 1219 | const struct sectioncheck* const mismatch, |
| 1212 | 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 | |
| 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 | − | |
| 1263 | 1263 | static void extable_mismatch_handler(const char* modname, struct elf_info *elf, |
| 1264 | 1264 | const struct sectioncheck* const mismatch, |
| 1265 | 1265 | Elf_Rela* r, Elf_Sym* sym, |