Re: What's the deal with building intermediate .o vs .a files?

From: Graham Stoney (greyham@research.canon.com.au)
Date: Sun Apr 09 2000 - 19:01:12 EST


Hi Guys,

Thanks for your answers...

Andi Kleen writes:
> Linking with ar does not include objects with non referenced symbols. This
> sometimes causes problems, because Linux uses call tables in ELF segments
> to initialize some things (e.g. the init_call() macros). ELF segments do
> not generate a symbol reference. For those ld -r is needed.

Groan. I had a bad feeling about this. It's causing me grief because I'm
trying to build a kernel using -ffunction-sections, which puts every function
in its own section. This allows the linker to optimise away functions which
aren't called, even if other functions in the same object are called.

The grief-inducing part is that the linker has a nasty "feature" which
reverses the order of all the resulting .text.* sections when using "ld -r".
This leaves them out of order with respect to the __ex_table used to fixup bad
user space references, causing the exception trapping mechanism to break. I
know how to patch the linker to fix this, but using ar instead avoids the
problem without having to rebuild binutils. Is there some other hack I could
use to get "ar" to work with initcall, like treating it as a C++ constructor
or using KEEP in the .lds file or something?

Thanks,
Graham

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:13 EST