Commit 672fb674 authored by Masahiro Yamada's avatar Masahiro Yamada

modpost: remove .symbol_white_list field entirely

It is not so useful to have symbol whitelists in arrays. With this
over-engineering, the code is difficult to follow.

Let's do it more directly, and collect the relevant code to one place.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 1560cb0e
...@@ -845,28 +845,12 @@ static const char *const init_data_sections[] = ...@@ -845,28 +845,12 @@ static const char *const init_data_sections[] =
/* all init sections */ /* all init sections */
static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
/* All init and exit sections (code + data) */
static const char *const init_exit_sections[] =
{ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
/* all text sections */ /* all text sections */
static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL }; static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL };
/* data section */ /* data section */
static const char *const data_sections[] = { DATA_SECTIONS, NULL }; static const char *const data_sections[] = { DATA_SECTIONS, NULL };
/* symbols in .data that may refer to init/exit sections */
#define DEFAULT_SYMBOL_WHITE_LIST \
"*driver", \
"*_template", /* scsi uses *_template a lot */ \
"*_timer", /* arm uses ops structures named _timer a lot */ \
"*_sht", /* scsi also used *_sht to some extent */ \
"*_ops", \
"*_probe", \
"*_probe_one", \
"*_console"
static const char *const head_sections[] = { ".head.text*", NULL }; static const char *const head_sections[] = { ".head.text*", NULL };
static const char *const linker_symbols[] = static const char *const linker_symbols[] =
{ "__init_begin", "_sinittext", "_einittext", NULL }; { "__init_begin", "_sinittext", "_einittext", NULL };
...@@ -898,9 +882,6 @@ enum mismatch { ...@@ -898,9 +882,6 @@ enum mismatch {
* *
* @mismatch: Type of mismatch. * @mismatch: Type of mismatch.
* *
* @symbol_white_list: Do not match a relocation to a symbol in this list
* even if it is targeting a section in @bad_to_sec.
*
* @handler: Specific handler to call when a match is found. If NULL, * @handler: Specific handler to call when a match is found. If NULL,
* default_mismatch_handler() will be called. * default_mismatch_handler() will be called.
* *
...@@ -910,7 +891,6 @@ struct sectioncheck { ...@@ -910,7 +891,6 @@ struct sectioncheck {
const char *bad_tosec[20]; const char *bad_tosec[20];
const char *good_tosec[20]; const char *good_tosec[20];
enum mismatch mismatch; enum mismatch mismatch;
const char *symbol_white_list[20];
void (*handler)(const char *modname, struct elf_info *elf, void (*handler)(const char *modname, struct elf_info *elf,
const struct sectioncheck* const mismatch, const struct sectioncheck* const mismatch,
Elf_Rela *r, Elf_Sym *sym, const char *fromsec); Elf_Rela *r, Elf_Sym *sym, const char *fromsec);
...@@ -935,16 +915,11 @@ static const struct sectioncheck sectioncheck[] = { ...@@ -935,16 +915,11 @@ static const struct sectioncheck sectioncheck[] = {
.fromsec = { DATA_SECTIONS, NULL }, .fromsec = { DATA_SECTIONS, NULL },
.bad_tosec = { ALL_XXXINIT_SECTIONS, NULL }, .bad_tosec = { ALL_XXXINIT_SECTIONS, NULL },
.mismatch = DATA_TO_ANY_INIT, .mismatch = DATA_TO_ANY_INIT,
.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
}, },
{ {
.fromsec = { DATA_SECTIONS, NULL }, .fromsec = { DATA_SECTIONS, NULL },
.bad_tosec = { INIT_SECTIONS, NULL }, .bad_tosec = { INIT_SECTIONS, NULL },
.mismatch = DATA_TO_ANY_INIT, .mismatch = DATA_TO_ANY_INIT,
.symbol_white_list = {
"*_template", "*_timer", "*_sht", "*_ops",
"*_probe", "*_probe_one", "*_console", NULL
},
}, },
{ {
.fromsec = { TEXT_SECTIONS, NULL }, .fromsec = { TEXT_SECTIONS, NULL },
...@@ -955,7 +930,6 @@ static const struct sectioncheck sectioncheck[] = { ...@@ -955,7 +930,6 @@ static const struct sectioncheck sectioncheck[] = {
.fromsec = { DATA_SECTIONS, NULL }, .fromsec = { DATA_SECTIONS, NULL },
.bad_tosec = { ALL_EXIT_SECTIONS, NULL }, .bad_tosec = { ALL_EXIT_SECTIONS, NULL },
.mismatch = DATA_TO_ANY_EXIT, .mismatch = DATA_TO_ANY_EXIT,
.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
}, },
/* Do not reference init code/data from meminit code/data */ /* Do not reference init code/data from meminit code/data */
{ {
...@@ -1051,15 +1025,6 @@ static const struct sectioncheck *section_mismatch( ...@@ -1051,15 +1025,6 @@ static const struct sectioncheck *section_mismatch(
* fromsec = .data* * fromsec = .data*
* atsym = __param_ops_* * atsym = __param_ops_*
* *
* Pattern 2:
* Many drivers utilise a *driver container with references to
* add, remove, probe functions etc.
* the pattern is identified by:
* tosec = init or exit section
* fromsec = data section
* atsym = *driver, *_template, *_sht, *_ops, *_probe,
* *probe_one, *_console, *_timer
*
* Pattern 3: * Pattern 3:
* Whitelist all references from .head.text to any init section * Whitelist all references from .head.text to any init section
* *
...@@ -1108,10 +1073,22 @@ static int secref_whitelist(const struct sectioncheck *mismatch, ...@@ -1108,10 +1073,22 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
strstarts(fromsym, "__param_ops_")) strstarts(fromsym, "__param_ops_"))
return 0; return 0;
/* Check for pattern 2 */ /* symbols in data sections that may refer to any init/exit sections */
if (match(tosec, init_exit_sections) && if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
match(fromsec, data_sections) && match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
match(fromsym, mismatch->symbol_white_list)) match(fromsym, PATTERNS("*_template", // scsi uses *_template a lot
"*_timer", // arm uses ops structures named _timer a lot
"*_sht", // scsi also used *_sht to some extent
"*_ops",
"*_probe",
"*_probe_one",
"*_console")))
return 0;
/* symbols in data sections that may refer to meminit/exit sections */
if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
match(fromsym, PATTERNS("*driver")))
return 0; return 0;
/* Check for pattern 3 */ /* Check for pattern 3 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment