History

modpost: add handler function pointer to sectioncheck.

This will be useful when we want to have special handlers which need to go through more hops to print useful information to the user.

Quentin Casasnovas committed 11 years ago

Commit 644e8f11 parent 157d1971 file · +42 −26Browse files

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

Unified · Split

scripts/mod/modpost.c+42−26
@@ -930,6 +930,10 @@ struct sectioncheck { · 929 unmodified lines
930930 const char *good_tosec[20];
931931 enum mismatch mismatch;
932932 const char *symbol_white_list[20];
933+ void (*handler)(const char *modname, struct elf_info *elf,
934+ const struct sectioncheck* const mismatch,
935+ Elf_Rela *r, Elf_Sym *sym, const char *fromsec);
936+
933937 };
934938
935939 static const struct sectioncheck sectioncheck[] = {
@@ -1417,37 +1421,49 @@ static void report_sec_mismatch(const char *modname, · 481 unmodified lines
14171421 fprintf(stderr, "\n");
14181422 }
14191423
1420−static void check_section_mismatch(const char *modname, struct elf_info *elf,
1421− Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
1424+static void default_mismatch_handler(const char *modname, struct elf_info *elf,
1425+ const struct sectioncheck* const mismatch,
1426+ Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
14221427 {
14231428 const char *tosec;
1424− const struct sectioncheck *mismatch;
1429+ Elf_Sym *to;
1430+ Elf_Sym *from;
1431+ const char *tosym;
1432+ const char *fromsym;
14251433
14261434 tosec = sec_name(elf, get_secindex(elf, sym));
1427− mismatch = section_mismatch(fromsec, tosec);
1435+ from = find_elf_symbol2(elf, r->r_offset, fromsec);
1436+ fromsym = sym_name(elf, from);
1437+ to = find_elf_symbol(elf, r->r_addend, sym);
1438+ tosym = sym_name(elf, to);
1439+
1440+ if (!strncmp(fromsym, "reference___initcall",
1441+ sizeof("reference___initcall")-1))
1442+ return;
1443+
1444+ /* check whitelist - we may ignore it */
1445+ if (secref_whitelist(mismatch,
1446+ fromsec, fromsym, tosec, tosym)) {
1447+ report_sec_mismatch(modname, mismatch,
1448+ fromsec, r->r_offset, fromsym,
1449+ is_function(from), tosec, tosym,
1450+ is_function(to));
1451+ }
1452+}
1453+
1454+static void check_section_mismatch(const char *modname, struct elf_info *elf,
1455+ Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
1456+{
1457+ const char *tosec = sec_name(elf, get_secindex(elf, sym));;
1458+ const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec);
1459+
14281460 if (mismatch) {
1429− Elf_Sym *to;
1430− Elf_Sym *from;
1431− const char *tosym;
1432− const char *fromsym;
1433−
1434− from = find_elf_symbol2(elf, r->r_offset, fromsec);
1435− fromsym = sym_name(elf, from);
1436− to = find_elf_symbol(elf, r->r_addend, sym);
1437− tosym = sym_name(elf, to);
1438−
1439− if (!strncmp(fromsym, "reference___initcall",
1440− sizeof("reference___initcall")-1))
1441− return;
1442−
1443− /* check whitelist - we may ignore it */
1444− if (secref_whitelist(mismatch,
1445− fromsec, fromsym, tosec, tosym)) {
1446− report_sec_mismatch(modname, mismatch,
1447− fromsec, r->r_offset, fromsym,
1448− is_function(from), tosec, tosym,
1449− is_function(to));
1450− }
1461+ if (mismatch->handler)
1462+ mismatch->handler(modname, elf, mismatch,
1463+ r, sym, fromsec);
1464+ else
1465+ default_mismatch_handler(modname, elf, mismatch,
1466+ r, sym, fromsec);
14511467 }
14521468 }
14531469

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