report_sec_mismatch() and default_mismatch_handler() are small enough to be merged together.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -1207,17 +1207,27 @@ 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 | −/* | |
| 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) | |
| 1220 | 1213 | { |
| 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 | + | |
| 1221 | 1231 | sec_mismatch_count++; |
| 1222 | 1232 | |
| 1223 | 1233 | switch (mismatch->mismatch) { |
| @@ -1242,31 +1252,6 @@ static void report_sec_mismatch(const char *modname, · 18 unmodified lines | ||
| 1242 | 1252 | } |
| 1243 | 1253 | } |
| 1244 | 1254 | |
| 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 | − | |
| 1270 | 1255 | static int is_executable_section(struct elf_info* elf, unsigned int section_index) |
| 1271 | 1256 | { |
| 1272 | 1257 | if (section_index > elf->num_sections) |