Re: [MODULES] fix weak symbol handling

From: Rusty Russell (rusty@rustcorp.com.au)
Date: Mon Jan 13 2003 - 22:57:11 EST


In message <20030113110036.A873@twiddle.net> you write:
> case SHN_UNDEF:
> + sym[i].st_value
> + = resolve_symbol(sechdrs, symindex, strtab,
> + strtab + sym[i].st_name, mod);
> +
> + /* Ok if resolved. */
> + if (sym[i].st_value != 0)
> + break;
> + /* Ok if weak. */
> + if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK)
> + break;
> +
> + printk(KERN_WARNING "%s: Unknown symbol %s\n",
> + mod->name, strtab + sym[i].st_name);
> + ret = -ENOENT;
> break;

I don't understand this. For a weak symbol, st_shndx won't be
SHN_UNDEF. And you don't want to set its value to 0, anyway. I think
you want:

        default:
                if (ELF_ST_BIND(sym[i].st_info) == STB_WEAK) {
                        unsigned long val = resolve_symbol(...);
                        if (val)
                                sym[i].st_value = val;
                } else
                        ...

Or am I missing something?
Rusty.
PS. "s/Fix weak symbol handling/Implement weak symbol handling/" 8)

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:49 EST