Skip to content

Commit

Permalink
linux/export: fix reference to exported functions for parisc64
Browse files Browse the repository at this point in the history
commit 08700ec upstream.

John David Anglin reported parisc has been broken since commit
ddb5cdb ("kbuild: generate KSYMTAB entries by modpost").

Like ia64, parisc64 uses a function descriptor. The function
references must be prefixed with P%.

Also, symbols prefixed $$ from the library have the symbol type
STT_LOPROC instead of STT_FUNC. They should be handled as functions
too.

Fixes: ddb5cdb ("kbuild: generate KSYMTAB entries by modpost")
Reported-by: John David Anglin <dave.anglin@bell.net>
Tested-by: John David Anglin <dave.anglin@bell.net>
Tested-by: Helge Deller <deller@gmx.de>
Closes: https://lore.kernel.org/linux-parisc/1901598a-e11d-f7dd-a5d9-9a69d06e6b6e@bell.net/T/#u
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
masahir0y authored and gregkh committed Sep 19, 2023
1 parent 610dbd8 commit 53092c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/export-internal.h
Expand Up @@ -52,6 +52,8 @@

#ifdef CONFIG_IA64
#define KSYM_FUNC(name) @fptr(name)
#elif defined(CONFIG_PARISC) && defined(CONFIG_64BIT)
#define KSYM_FUNC(name) P%name
#else
#define KSYM_FUNC(name) name
#endif
Expand Down
9 changes: 9 additions & 0 deletions scripts/mod/modpost.c
Expand Up @@ -1226,6 +1226,15 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf,
*/
s->is_func = (ELF_ST_TYPE(sym->st_info) == STT_FUNC);

/*
* For parisc64, symbols prefixed $$ from the library have the symbol type
* STT_LOPROC. They should be handled as functions too.
*/
if (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64 &&
elf->hdr->e_machine == EM_PARISC &&
ELF_ST_TYPE(sym->st_info) == STT_LOPROC)
s->is_func = true;

if (match(secname, PATTERNS(INIT_SECTIONS)))
warn("%s: %s: EXPORT_SYMBOL used for init symbol. Remove __init or EXPORT_SYMBOL.\n",
mod->name, name);
Expand Down

0 comments on commit 53092c7

Please sign in to comment.