module: fix symbol versioning with symbol prefixes
PATCH 1/1 module: fix symbol versioning with symbol prefixes
Fix symbol versioning on architectures with symbol prefixes. Although the build was free from warnings the actual modules still wouldn't load as the ____versions table contained unprefixed symbol names, which were being compared against the prefixed symbol names when checking the symbol versions.
This is fixed by modifying modpost to add the symbol prefix to the ____versions table it outputs (Modules.symvers still contains unprefixed symbol names). The check_modstruct_version() function is also fixed as it checks the version of the unprefixed "module_layout" symbol which would no longer work.
---
This conflicts with Rusty's "CONFIG_SYMBOL_PREFIX: cleanup" patch.
kernel/module.c | 3 ++- scripts/mod/modpost.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
kernel/module.c +2 -1
@@ -1212,7 +1212,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,if (!find_symbol (MODULE_SYMBOL_PREFIX "module_layout" ,NULL , &crc, true, false))BUG (); -return check_version (sechdrs, versindex,"module_layout" , mod, crc, +return check_version (sechdrs, versindex, +MODULE_SYMBOL_PREFIX "module_layout" , mod, crc,NULL ); }
scripts/mod/modpost.c +2 -1
@@ -1934,7 +1934,8 @@ static int add_versions(struct buffer *b, struct module *mod) s->name, mod->name);continue ; } -buf_printf (b,"\t{ %#8x, \"%s\" },\n" , s->crc, s->name); +buf_printf (b,"\t{ %#8x, \"%s%s\" },\n" , s->crc, +MODULE_SYMBOL_PREFIX , s->name); }buf_printf (b,"};\n" );
Signature · 1 line
1.8.1.2
Quoted 11 lines · James Hogan
Fix symbol versioning on architectures with symbol prefixes. Although the build was free from warnings the actual modules still wouldn't load as the
____versionstable contained unprefixed symbol names, which were being compared against the prefixed symbol names when checking the symbol versions.This is fixed by modifying modpost to add the symbol prefix to the
____versionstable it outputs (Modules.symvers still contains unprefixed symbol names). Thecheck_modstruct_version()function is also fixed as it checks the version of the unprefixed "module_layout" symbol which would no longer work.
Hmm, this has always been broken, right? And noone noticed? Unless you really want it now, I'll queue it for *next* merge window.
I've applied it (reworked) to my pending-rebases queue, and will put it in modules-next once the cleanup goes in.
Thanks,
Rusty.
From: James Hogan <[email protected]>
Subject: module: fix symbol versioning with symbol prefixes
Fix symbol versioning on architectures with symbol prefixes. Although the build was free from warnings the actual modules still wouldn't load as the ____versions table contained unprefixed symbol names, which were being compared against the prefixed symbol names when checking the symbol versions.
This is fixed by modifying modpost to add the symbol prefix to the ____versions table it outputs (Modules.symvers still contains unprefixed symbol names). The check_modstruct_version() function is also fixed as it checks the version of the unprefixed "module_layout" symbol which would no longer work.
kernel/module.c +2 -1
@@ -1212,7 +1212,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,if (!find_symbol (VMLINUX_SYMBOL_STR (module_layout),NULL , &crc, true, false))BUG (); -return check_version (sechdrs, versindex,"module_layout" , mod, crc, +return check_version (sechdrs, versindex, +VMLINUX_SYMBOL_STR (module_layout), mod, crc,NULL ); }
scripts/mod/modpost.c +2 -1
@@ -1927,7 +1927,8 @@ static int add_versions(struct buffer *b, struct module *mod) s->name, mod->name);continue ; } -buf_printf (b,"\t{ %#8x, \"%s\" },\n" , s->crc, s->name); +buf_printf (b,"\t{ %#8x, \"%s%s\" },\n" , s->crc, +VMLINUX_SYMBOL_PREFIX_STR , s->name); }buf_printf (b,"};\n" );
Quoted 7 lines · Rusty Russell
Quoted 6 lines · James Hogan
Fix symbol versioning on architectures with symbol prefixes. Although the build was free from warnings the actual modules still wouldn't load as the
____versionstable contained unprefixed symbol names, which were being compared against the prefixed symbol names when checking the symbol versions.
Quoted 8 lines
Quoted 5 lines
This is fixed by modifying modpost to add the symbol prefix to the
____versionstable it outputs (Modules.symvers still contains unprefixed symbol names). Thecheck_modstruct_version()function is also fixed as it checks the version of the unprefixed "module_layout" symbol which would no longer work.Hmm, this has always been broken, right? And noone noticed? Unless you really want it now, I'll queue it for *next* merge window.
Yes, that's fine by me.
Quoted 2 lines
I've applied it (reworked) to my pending-rebases queue, and will put it in modules-next once the cleanup goes in.
Thanks
James