History

modpost: squash report_extable_warnings() into extable_mismatch_handler()

Collect relevant code into one place to clarify all the cases are covered by 'if () ... else if ... else ...'.

Masahiro Yamada committed 3 years ago

Commit faee9de1 parent 6691e6f1 file · +14 −26Browse files

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

Unified · Split

scripts/mod/modpost.c+14−26
@@ -1275,40 +1275,19 @@ static int is_executable_section(struct elf_info* elf, unsigned int section_inde · 1274 unmodified lines
12751275 return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR);
12761276 }
12771277
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−
13021278 static void extable_mismatch_handler(const char* modname, struct elf_info *elf,
13031279 const struct sectioncheck* const mismatch,
13041280 Elf_Rela* r, Elf_Sym* sym,
13051281 const char *fromsec)
13061282 {
13071283 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);
13081286
13091287 sec_mismatch_count++;
13101288
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);
13121291
13131292 if (match(tosec, mismatch->bad_tosec))
13141293 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
13171296 "You might get more information about where this is\n"
13181297 "coming from by using scripts/check_extable.sh %s\n",
13191298 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
13211309 error("%s+0x%lx references non-executable section '%s'\n",
13221310 fromsec, (long)r->r_offset, tosec);
13231311 }