Re: [MODULES] fix weak symbol handling

Rusty Russell (rusty@rustcorp.com.au)
Tue, 14 Jan 2003 14:57:11 +1100


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/