History

modpost: squash report_sec_mismatch() into default_mismatch_handler()

report_sec_mismatch() and default_mismatch_handler() are small enough to be merged together.

Masahiro Yamada committed 3 years ago

Commit fc5fa861 parent faee9de1 file · +20 −35Browse files

Unified · Split

scripts/mod/modpost.c+20−35
@@ -1207,17 +1207,27 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, · 1206 unmodified lines
12071207 return near;
12081208 }
12091209
1210−/*
1211− * Print a warning about a section mismatch.
1212− * Try to find symbols near it so user can find it.
1213− * Check whitelist before warning - it may be a false positive.
1214− */
1215−static void report_sec_mismatch(const char *modname,
1216− const struct sectioncheck *mismatch,
1217− const char *fromsec,
1218− const char *fromsym,
1219− const char *tosec, const char *tosym)
1210+static void default_mismatch_handler(const char *modname, struct elf_info *elf,
1211+ const struct sectioncheck* const mismatch,
1212+ Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
12201213 {
1214+ const char *tosec;
1215+ Elf_Sym *to;
1216+ Elf_Sym *from;
1217+ const char *tosym;
1218+ const char *fromsym;
1219+
1220+ from = find_elf_symbol2(elf, r->r_offset, fromsec);
1221+ fromsym = sym_name(elf, from);
1222+
1223+ tosec = sec_name(elf, get_secindex(elf, sym));
1224+ to = find_elf_symbol(elf, r->r_addend, sym);
1225+ tosym = sym_name(elf, to);
1226+
1227+ /* check whitelist - we may ignore it */
1228+ if (!secref_whitelist(mismatch, fromsec, fromsym, tosec, tosym))
1229+ return;
1230+
12211231 sec_mismatch_count++;
12221232
12231233 switch (mismatch->mismatch) {
@@ -1242,31 +1252,6 @@ static void report_sec_mismatch(const char *modname, · 18 unmodified lines
12421252 }
12431253 }
12441254
1245−static void default_mismatch_handler(const char *modname, struct elf_info *elf,
1246− const struct sectioncheck* const mismatch,
1247− Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
1248−{
1249− const char *tosec;
1250− Elf_Sym *to;
1251− Elf_Sym *from;
1252− const char *tosym;
1253− const char *fromsym;
1254−
1255− from = find_elf_symbol2(elf, r->r_offset, fromsec);
1256− fromsym = sym_name(elf, from);
1257−
1258− tosec = sec_name(elf, get_secindex(elf, sym));
1259− to = find_elf_symbol(elf, r->r_addend, sym);
1260− tosym = sym_name(elf, to);
1261−
1262− /* check whitelist - we may ignore it */
1263− if (secref_whitelist(mismatch,
1264− fromsec, fromsym, tosec, tosym)) {
1265− report_sec_mismatch(modname, mismatch,
1266− fromsec, fromsym, tosec, tosym);
1267− }
1268−}
1269−
12701255 static int is_executable_section(struct elf_info* elf, unsigned int section_index)
12711256 {
12721257 if (section_index > elf->num_sections)

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