Skip to content

Commit 0d2a636

Browse files
author
Uwe Kleine-König
committed
modpost: pass around const struct sectioncheck * instead of enum mismatch
This prepares having a per-check whitelist of symbol names. Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent bbd3f4f commit 0d2a636

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

scripts/mod/modpost.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ const struct sectioncheck sectioncheck[] = {
933933
}
934934
};
935935

936-
static int section_mismatch(const char *fromsec, const char *tosec)
936+
static const struct sectioncheck *section_mismatch(
937+
const char *fromsec, const char *tosec)
937938
{
938939
int i;
939940
int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck);
@@ -942,10 +943,10 @@ static int section_mismatch(const char *fromsec, const char *tosec)
942943
for (i = 0; i < elems; i++) {
943944
if (match(fromsec, check->fromsec) &&
944945
match(tosec, check->tosec))
945-
return check->mismatch;
946+
return check;
946947
check++;
947948
}
948-
return NO_MISMATCH;
949+
return NULL;
949950
}
950951

951952
/**
@@ -1158,7 +1159,8 @@ static int is_function(Elf_Sym *sym)
11581159
* Try to find symbols near it so user can find it.
11591160
* Check whitelist before warning - it may be a false positive.
11601161
*/
1161-
static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1162+
static void report_sec_mismatch(const char *modname,
1163+
const struct sectioncheck *mismatch,
11621164
const char *fromsec,
11631165
unsigned long long fromaddr,
11641166
const char *fromsym,
@@ -1189,7 +1191,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
11891191
modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec,
11901192
tosym, to_p);
11911193

1192-
switch (mismatch) {
1194+
switch (mismatch->mismatch) {
11931195
case TEXT_TO_ANY_INIT:
11941196
fprintf(stderr,
11951197
"The function %s%s() references\n"
@@ -1289,11 +1291,11 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
12891291
Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
12901292
{
12911293
const char *tosec;
1292-
enum mismatch mismatch;
1294+
const struct sectioncheck *mismatch;
12931295

12941296
tosec = sec_name(elf, sym->st_shndx);
12951297
mismatch = section_mismatch(fromsec, tosec);
1296-
if (mismatch != NO_MISMATCH) {
1298+
if (mismatch) {
12971299
Elf_Sym *to;
12981300
Elf_Sym *from;
12991301
const char *tosym;

0 commit comments

Comments
 (0)