linux-mips
[Top] [All Lists]

[PATCH] Ignore unresolved weak symbols in module.

To: linux-mips@linux-mips.org
Subject: [PATCH] Ignore unresolved weak symbols in module.
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Tue, 23 May 2006 00:45:07 +0900 (JST)
Cc: ralf@linux-mips.org
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
On Fri, 21 Apr 2006 23:33:35 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> 
wrote:
> > > The problem is if you try to load oprofile as a module.  The kernel 
> > > module linker evidentially does not understand weak symbols and refuses 
> > > to load the module because they are undefined.
> > 
> > Actually it contains code to handle weak symbols so this is a bit
> > surprising not last because STB_WEAK handling happen in the generic
> > module loader code and is being used by other architectures as well.
> 
> This is still unresolved.  The "oprofile: Unknown symbol" message is
> printed in arch/mips/kernel/module.c file.  How about this patch?

ping.


[PATCH] Ignore unresolved weak symbols in module.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index e54a7f4..d7bf021 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -288,6 +288,9 @@ int apply_relocate(Elf_Shdr *sechdrs, co
                sym = (Elf_Sym *)sechdrs[symindex].sh_addr
                        + ELF_MIPS_R_SYM(rel[i]);
                if (!sym->st_value) {
+                       /* Ignore unresolved weak symbol */
+                       if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
+                               continue;
                        printk(KERN_WARNING "%s: Unknown symbol %s\n",
                               me->name, strtab + sym->st_name);
                        return -ENOENT;
@@ -325,6 +328,9 @@ int apply_relocate_add(Elf_Shdr *sechdrs
                sym = (Elf_Sym *)sechdrs[symindex].sh_addr
                        + ELF_MIPS_R_SYM(rel[i]);
                if (!sym->st_value) {
+                       /* Ignore unresolved weak symbol */
+                       if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
+                               continue;
                        printk(KERN_WARNING "%s: Unknown symbol %s\n",
                               me->name, strtab + sym->st_name);
                        return -ENOENT;

<Prev in Thread] Current Thread [Next in Thread>