[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Kernel module complying and unresolved symbol(s)
> From: Simon Posnjak <email@example.com>
> Date: Thu, 23 Sep 2004 12:17:33 +0200
> V tor, 21.09.2004 ob 05:29 je Hans-Peter Nilsson napisal(a):
> > That last line should have been something like (untested):
> > cris-axis-linux-gnu-gcc --nostdlib -static -Wl,--whole-archive liblatency_rt.a -Wl,--no-whole-archive -lgcc -r -o latency_rt.o
> > For education only, that should be roughly equivalent to (also untested):
> > cris-ld -mcrislinux --whole-archive liblatency_rt.a --no-whole-archive `cris-axis-linux-gnu-gcc --print-libgcc-file-name` -r -o latency_rt.o
> If I use the first line (calling the linker through gcc) I get a module
> which has size of 5.2M (unstrip) and has everything compiled in.
Oops. Replace the --nostdlib with -nostdlib.
> loads in to the kernel and dose nothing.
It has the whole of glibc included, which is supposedly
detrimental (due to my typo, which effectively disabled
> In the second case I get a module which is much smaller but it will not
> load in to the kernel. (The errors are in errror.txt) When I compare the
> nm output of the complied (look at nm-com.txt) and of the linked module
> (look at nm-lnk.txt) I can see that linker put the missing functions in
> to the module and this missing functions are the ones about which the
> insmod complains.
Right, the module loader probably can't handle those
relocations. Maybe it should. The libgcc.a code is compiled to
work in a shared library as well as static linking (-fpic),
which means it has some non-trivial relocations.
> So I think that resolution to this problem would probably be to have
> some kind of FP emulation in the kernel. Any ideas?
You could supposedly accomplish that by linking in *the whole*
of libgcc.a, not just the (non-fp) code that the kernel
currently needs. I guess you could add
--whole-archive ... --no-whole-archive around the current
definition of LIBGCC in arch/cris/Makefile. You also need to
export those floating-point-symbols, so modules can use them.
It seems you do this in arch/cris/kernel/crisksyms.c.
Then you just link your module with
cris-axis-linux-gnu-gcc -nostdlib -static -Wl,--whole-archive liblatency_rt.a -Wl,--no-whole-archive -r -o latency_rt.o