Collect relevant code into one place to clarify all the cases are covered by 'if () ... else if ... else ...'.
Unified · Split
| @@ -1275,40 +1275,19 @@ static int is_executable_section(struct elf_info* elf, unsigned int section_inde · 1274 unmodified lines | |||
| 1275 | return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); | 1275 | return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); |
| 1276 | } | 1276 | } |
| 1277 | 1277 | ||
| 1278 | static void report_extable_warnings(const char* modname, struct elf_info* elf, | ||
| 1279 | const struct sectioncheck* const mismatch, | ||
| 1280 | Elf_Rela* r, Elf_Sym* sym, | ||
| 1281 | const char* fromsec, const char* tosec) | ||
| 1282 | { | ||
| 1283 | Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); | ||
| 1284 | const char* tosym_name = sym_name(elf, tosym); | ||
| 1285 | |||
| 1286 | warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n", | ||
| 1287 | modname, fromsec, (long)r->r_offset, tosec, tosym_name); | ||
| 1288 | |||
| 1289 | if (!match(tosec, mismatch->bad_tosec) && | ||
| 1290 | is_executable_section(elf, get_secindex(elf, sym))) | ||
| 1291 | fprintf(stderr, | ||
| 1292 | "The relocation at %s+0x%lx references\n" | ||
| 1293 | "section \"%s\" which is not in the list of\n" | ||
| 1294 | "authorized sections. If you're adding a new section\n" | ||
| 1295 | "and/or if this reference is valid, add \"%s\" to the\n" | ||
| 1296 | "list of authorized sections to jump to on fault.\n" | ||
| 1297 | "This can be achieved by adding \"%s\" to \n" | ||
| 1298 | "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", | ||
| 1299 | fromsec, (long)r->r_offset, tosec, tosec, tosec); | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | static void extable_mismatch_handler(const char* modname, struct elf_info *elf, | 1278 | static void extable_mismatch_handler(const char* modname, struct elf_info *elf, |
| 1303 | const struct sectioncheck* const mismatch, | 1279 | const struct sectioncheck* const mismatch, |
| 1304 | Elf_Rela* r, Elf_Sym* sym, | 1280 | Elf_Rela* r, Elf_Sym* sym, |
| 1305 | const char *fromsec) | 1281 | const char *fromsec) |
| 1306 | { | 1282 | { |
| 1307 | const char* tosec = sec_name(elf, get_secindex(elf, sym)); | 1283 | const char* tosec = sec_name(elf, get_secindex(elf, sym)); |
| 1284 | Elf_Sym *tosym = find_elf_symbol(elf, r->r_addend, sym); | ||
| 1285 | const char *tosym_name = sym_name(elf, tosym); | ||
| 1308 | 1286 | ||
| 1309 | sec_mismatch_count++; | 1287 | sec_mismatch_count++; |
| 1310 | 1288 | ||
| 1311 | report_extable_warnings(modname, elf, mismatch, r, sym, fromsec, tosec); | 1289 | warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n", |
| 1290 | modname, fromsec, (long)r->r_offset, tosec, tosym_name); | ||
| 1312 | 1291 | ||
| 1313 | if (match(tosec, mismatch->bad_tosec)) | 1292 | if (match(tosec, mismatch->bad_tosec)) |
| 1314 | fatal("The relocation at %s+0x%lx references\n" | 1293 | fatal("The relocation at %s+0x%lx references\n" |
| @@ -1317,7 +1296,16 @@ static void extable_mismatch_handler(const char* modname, struct elf_info *elf, · 2 unmodified lines | |||
| 1317 | "You might get more information about where this is\n" | 1296 | "You might get more information about where this is\n" |
| 1318 | "coming from by using scripts/check_extable.sh %s\n", | 1297 | "coming from by using scripts/check_extable.sh %s\n", |
| 1319 | fromsec, (long)r->r_offset, tosec, modname); | 1298 | fromsec, (long)r->r_offset, tosec, modname); |
| 1320 | else if (!is_executable_section(elf, get_secindex(elf, sym))) | 1299 | else if (is_executable_section(elf, get_secindex(elf, sym))) |
| 1300 | warn("The relocation at %s+0x%lx references\n" | ||
| 1301 | "section \"%s\" which is not in the list of\n" | ||
| 1302 | "authorized sections. If you're adding a new section\n" | ||
| 1303 | "and/or if this reference is valid, add \"%s\" to the\n" | ||
| 1304 | "list of authorized sections to jump to on fault.\n" | ||
| 1305 | "This can be achieved by adding \"%s\" to\n" | ||
| 1306 | "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", | ||
| 1307 | fromsec, (long)r->r_offset, tosec, tosec, tosec); | ||
| 1308 | else | ||
| 1321 | error("%s+0x%lx references non-executable section '%s'\n", | 1309 | error("%s+0x%lx references non-executable section '%s'\n", |
| 1322 | fromsec, (long)r->r_offset, tosec); | 1310 | fromsec, (long)r->r_offset, tosec); |
| 1323 | } | 1311 | } |