Skip to content

Commit 4d7365d

Browse files
committed
kbuild: ignore powerpc specific symbols in modpost
Kumar Gala <[email protected]> wrote: We have a case in powerpc in which we want to link some library routines with all module objects. The routines are intended for handling out-of-line function call register save/restore so having them as EXPORT_SYMBOL() is counter productive (we do also need to link the same "library" code into the kernel). Without this patch a powerpc build would error out and fail to build modules with the added register save/restore module. There were two obvious solutions: 1) To link the .o file before the modpost stage 2) To ignore the symbols in modpost Option 1) was ruled out because we do not have any separate linking stage for single file modules. This patch implements option 2 - and do so only for powerpc. The symbols we ignore are all undefined symbols named: _restgpr_*, _savegpr_*, _rest32gpr_*, _save32gpr_* Signed-off-by: Sam Ravnborg <[email protected]> Cc: Kumar Gala <[email protected]> Cc: Paul Mackerras <[email protected]>
1 parent 631025b commit 4d7365d

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

scripts/mod/modpost.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,25 @@ static void parse_elf_finish(struct elf_info *info)
467467
release_file(info->hdr, info->size);
468468
}
469469

470+
static int ignore_undef_symbol(struct elf_info *info, const char *symname)
471+
{
472+
/* ignore __this_module, it will be resolved shortly */
473+
if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
474+
return 1;
475+
/* ignore global offset table */
476+
if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
477+
return 1;
478+
if (info->hdr->e_machine == EM_PPC)
479+
/* Special register function linked on all modules during final link of .ko */
480+
if (strncmp(symname, "_restgpr_", sizeof("_restgpr_") - 1) == 0 ||
481+
strncmp(symname, "_savegpr_", sizeof("_savegpr_") - 1) == 0 ||
482+
strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 ||
483+
strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0)
484+
return 1;
485+
/* Do not ignore this symbol */
486+
return 0;
487+
}
488+
470489
#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_"
471490
#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
472491

@@ -493,11 +512,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
493512
if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL &&
494513
ELF_ST_BIND(sym->st_info) != STB_WEAK)
495514
break;
496-
/* ignore global offset table */
497-
if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
498-
break;
499-
/* ignore __this_module, it will be resolved shortly */
500-
if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0)
515+
if (ignore_undef_symbol(info, symname))
501516
break;
502517
/* cope with newer glibc (2.3.4 or higher) STT_ definition in elf.h */
503518
#if defined(STT_REGISTER) || defined(STT_SPARC_REGISTER)

0 commit comments

Comments
 (0)