Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 644e8f14 authored by Quentin Casasnovas's avatar Quentin Casasnovas Committed by Rusty Russell
Browse files

modpost: add handler function pointer to sectioncheck.



This will be useful when we want to have special handlers which need to go
through more hops to print useful information to the user.

Signed-off-by: default avatarQuentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 157d1972
Loading
Loading
Loading
Loading
+42 −26
Original line number Diff line number Diff line
@@ -930,6 +930,10 @@ struct sectioncheck {
	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);

};

static const struct sectioncheck sectioncheck[] = {
@@ -1417,20 +1421,17 @@ static void report_sec_mismatch(const char *modname,
	fprintf(stderr, "\n");
}

static void check_section_mismatch(const char *modname, struct elf_info *elf,
static void default_mismatch_handler(const char *modname, struct elf_info *elf,
				     const struct sectioncheck* const mismatch,
				     Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
{
	const char *tosec;
	const struct sectioncheck *mismatch;

	tosec = sec_name(elf, get_secindex(elf, sym));
	mismatch = section_mismatch(fromsec, tosec);
	if (mismatch) {
	Elf_Sym *to;
	Elf_Sym *from;
	const char *tosym;
	const char *fromsym;

	tosec = sec_name(elf, get_secindex(elf, sym));
	from = find_elf_symbol2(elf, r->r_offset, fromsec);
	fromsym = sym_name(elf, from);
	to = find_elf_symbol(elf, r->r_addend, sym);
@@ -1449,6 +1450,21 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
				    is_function(to));
	}
}

static void check_section_mismatch(const char *modname, struct elf_info *elf,
				   Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
{
	const char *tosec = sec_name(elf, get_secindex(elf, sym));;
	const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec);

	if (mismatch) {
		if (mismatch->handler)
			mismatch->handler(modname, elf,  mismatch,
					  r, sym, fromsec);
		else
			default_mismatch_handler(modname, elf, mismatch,
						 r, sym, fromsec);
	}
}

static unsigned int *reloc_location(struct elf_info *elf,