Commit 3194de9c authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Handle MODULE_SYMBOL_PREFIX in module postprocessing

Loosely based on a patch by Miles Bader, have modpost deal with
weird archs (v850) which prefix their symbols with '_'.

Modpost does not yet handle ppc64 "prefix function symbols with '.'"
correctly, btw.
parent 939ff499
......@@ -25,7 +25,7 @@ $(addprefix $(obj)/,$(filter-out fixdep,$(build-targets))): $(obj)/fixdep
$(obj)/modpost.o $(obj)/file2alias.o: $(obj)/elfconfig.h
quiet_cmd_elfconfig = MKELF $@
cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@
cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
$(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
$(call if_changed,elfconfig)
......
......@@ -9,6 +9,9 @@ main(int argc, char **argv)
unsigned char ei[EI_NIDENT];
union { short s; char c[2]; } endian_test;
if (argc != 2) {
fprintf(stderr, "Error: no arch\n");
}
if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
fprintf(stderr, "Error: input truncated\n");
return 1;
......@@ -52,6 +55,11 @@ main(int argc, char **argv)
else
abort();
if (strcmp(argv[1], "v850") == 0)
printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
else
printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
return 0;
}
......@@ -265,6 +265,9 @@ parse_elf_finish(struct elf_info *info)
munmap(info->hdr, info->size);
}
#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_"
#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
void
handle_modversions(struct module *mod, struct elf_info *info,
Elf_Sym *sym, const char *symname)
......@@ -279,9 +282,10 @@ handle_modversions(struct module *mod, struct elf_info *info,
break;
case SHN_ABS:
/* CRC'd symbol */
if (memcmp(symname, "__crc_", 6) == 0) {
if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
crc = (unsigned int) sym->st_value;
add_exported_symbol(symname+6, mod, &crc);
add_exported_symbol(symname + strlen(CRC_PFX),
mod, &crc);
modversions = 1;
}
break;
......@@ -290,15 +294,20 @@ handle_modversions(struct module *mod, struct elf_info *info,
if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL)
break;
s = alloc_symbol(symname);
if (memcmp(symname, MODULE_SYMBOL_PREFIX,
strlen(MODULE_SYMBOL_PREFIX)) == 0) {
s = alloc_symbol(symname +
strlen(MODULE_SYMBOL_PREFIX));
/* add to list */
s->next = mod->unres;
mod->unres = s;
}
break;
default:
/* All exported symbols */
if (memcmp(symname, "__ksymtab_", 10) == 0) {
add_exported_symbol(symname+10, mod, NULL);
if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
add_exported_symbol(symname + strlen(KSYMTAB_PFX),
mod, NULL);
}
break;
}
......
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