forked from Minki/linux
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: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
1560cb0e18
commit
672fb6740c
@ -845,28 +845,12 @@ static const char *const init_data_sections[] =
|
||||
/* all init sections */
|
||||
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 */
|
||||
static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL };
|
||||
|
||||
/* data section */
|
||||
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 linker_symbols[] =
|
||||
{ "__init_begin", "_sinittext", "_einittext", NULL };
|
||||
@ -898,9 +882,6 @@ enum 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,
|
||||
* default_mismatch_handler() will be called.
|
||||
*
|
||||
@ -910,7 +891,6 @@ struct sectioncheck {
|
||||
const char *bad_tosec[20];
|
||||
const char *good_tosec[20];
|
||||
enum mismatch mismatch;
|
||||
const char *symbol_white_list[20];
|
||||
void (*handler)(const char *modname, struct elf_info *elf,
|
||||
const struct sectioncheck* const mismatch,
|
||||
Elf_Rela *r, Elf_Sym *sym, const char *fromsec);
|
||||
@ -935,16 +915,11 @@ static const struct sectioncheck sectioncheck[] = {
|
||||
.fromsec = { DATA_SECTIONS, NULL },
|
||||
.bad_tosec = { ALL_XXXINIT_SECTIONS, NULL },
|
||||
.mismatch = DATA_TO_ANY_INIT,
|
||||
.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
|
||||
},
|
||||
{
|
||||
.fromsec = { DATA_SECTIONS, NULL },
|
||||
.bad_tosec = { INIT_SECTIONS, NULL },
|
||||
.mismatch = DATA_TO_ANY_INIT,
|
||||
.symbol_white_list = {
|
||||
"*_template", "*_timer", "*_sht", "*_ops",
|
||||
"*_probe", "*_probe_one", "*_console", NULL
|
||||
},
|
||||
},
|
||||
{
|
||||
.fromsec = { TEXT_SECTIONS, NULL },
|
||||
@ -955,7 +930,6 @@ static const struct sectioncheck sectioncheck[] = {
|
||||
.fromsec = { DATA_SECTIONS, NULL },
|
||||
.bad_tosec = { ALL_EXIT_SECTIONS, NULL },
|
||||
.mismatch = DATA_TO_ANY_EXIT,
|
||||
.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
|
||||
},
|
||||
/* Do not reference init code/data from meminit code/data */
|
||||
{
|
||||
@ -1051,15 +1025,6 @@ static const struct sectioncheck *section_mismatch(
|
||||
* fromsec = .data*
|
||||
* 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:
|
||||
* Whitelist all references from .head.text to any init section
|
||||
*
|
||||
@ -1108,10 +1073,22 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
|
||||
strstarts(fromsym, "__param_ops_"))
|
||||
return 0;
|
||||
|
||||
/* Check for pattern 2 */
|
||||
if (match(tosec, init_exit_sections) &&
|
||||
match(fromsec, data_sections) &&
|
||||
match(fromsym, mismatch->symbol_white_list))
|
||||
/* symbols in data sections that may refer to any init/exit sections */
|
||||
if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
|
||||
match(tosec, PATTERNS(ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
|
||||
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;
|
||||
|
||||
/* Check for pattern 3 */
|
||||
|
Loading…
Reference in New Issue
Block a user