linux-mips
[Top] [All Lists]

Re: OProfile cannot be loaded as module...

To: ralf@linux-mips.org
Subject: Re: OProfile cannot be loaded as module...
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Fri, 21 Apr 2006 23:33:35 +0900 (JST)
Cc: ddaney@avtrex.com, linux-mips@linux-mips.org
In-reply-to: <20051013225520.GA3234@linux-mips.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <43470BCF.1070709@avtrex.com> <20051013225520.GA3234@linux-mips.org>
Sender: linux-mips-bounce@linux-mips.org
On Thu, 13 Oct 2005 23:55:21 +0100, Ralf Baechle <ralf@linux-mips.org> 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?


[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>
  • Re: OProfile cannot be loaded as module..., Atsushi Nemoto <=