Subject: ksyms vs. ld
To: None <tech-toolchain@NetBSD.org>
From: Quentin Garnier <email@example.com>
Date: 08/03/2004 14:59:21
I was repeatedly reported a bug the past few months about modload making
ld crash when using ksyms.
It seems like it doesn't happen with binutils 2.13, only with binutils
It also doesn't happen with all modules.
Finally I tried to debug this today and came up with a scenario to
explain what is happening.
It only happens when a symbol from the module is already defined in the
kernel: that means it will happen with standard LKMs when used on
GENERIC (functionality is already included).
The crash happens in src/gnu/dist/binutils/bfd/elflink.h at line 2081:
if ((h->root.u.def.section->owner->flags & DYNAMIC) == 0)
"owner" is NULL, hence ld segfaults. h is more or less a symbol (struct
While it is hard to make sense of the context when you know next to
nothing about bfd internals, I think that what happens here is very
specific to /dev/ksyms.
Indeed, ksyms only exposes strings and symbols tables, no "real"
section. That means symbols are not "owned" (I believe this is the
meaning of the "owner" field) by any section that has content and/or is
to be loaded.
My question is: what should be fixed? ld or ksyms?
Would adding a fake section to ksyms be the right way to do this (I
don't like it)?