link_elf.c vs link_elf_obj.c ?

Kostik Belousov kostikbel at gmail.com
Mon Feb 5 12:26:20 UTC 2007


On Fri, Feb 02, 2007 at 05:27:56PM -0800, Luigi Rizzo wrote:
> does anyone know what is the difference between these two files ?
> They seem to do two similar but slightly different things related
> to elf file loading.
> 
> But diff shows large pieces of common code, and there is even
> more commonality if you factor out whitespace changes and
> variable renaming.

ELF specification defines 3 kinds of objects (putting core files aside);
- executables
- shared objects (AKA .so)
- relocatable objects (AKA .o, created by assembler).
Executables and .so are usually created by linker, while relocatables are the
assembler output (although ld -r can glue several .o files into one).
Executables and .so are in some sense finalized, and they contain a tables
that are useful for dynamic linker. Also, they usually carry different kind
of relocations then relocatables.

Now, in-kernel dynamic linker used for linking newly-loaded kld, shall deal
with either .so-kind of modules (on FreeBSD, all arches except amd64), or
relocatables (amd64). Two linkers you found deal with .so-kind (link_elf.c)
or relocatables (link_elf_obj.c).

Reasons why amd64 cannot use shared objects for kld mostly caused by
toolchains limitations and CPU architecture (it is impossible to create
working non-PIC .so there).

Note that Solaris uses relocatables for modules.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070205/49a649aa/attachment.pgp


More information about the freebsd-current mailing list