vmlinux.a
is created when the kernel is
made and contains objects that are unconditionally linked into
vmlinux
. (Contrast these objects with those which referred in
$KBUILD_VMLINUX_LIBS
and are conditionally linked).
Creating vmlinux.a
At least in an x64 architecture, vmlinux.a
is created in two steps.
In the first step, vmlinux.a
is created with the objects found ./built-in.a
, lib/lib.a
and arch/x86/lib/lib.a
:
ar cDPrST vmlinux.a ./built-in.a lib/lib.a arch/x86/lib/lib.a
In the second step, the objects referenced in
scripts/head-object-list.txt
are moved
before the first object found in the newly created
vmlinux.a
file (
ar t vmlinux.a | sed -n 1p
). On my current machine, this first object is
init/main.o
.
ar mPiT $(ar t vmlinux.a | sed -n 1p) vmlinux.a $(ar t vmlinux.a | grep -F -f ./scripts/head-object-list.txt)
Content of vmlinux.a
vmlinux.a
is a
thin archive (created with the
T
modifier). It's content looks like so:
!<thin>
// 73742 `
init/main.o/
init/version.o/
init/do_mounts.o/
init/do_mounts_initrd.o/
init/initramfs.o/
init/calibrate.o/
…
arch/x86/lib/retpoline.o/
arch/x86/lib/usercopy.o/
arch/x86/lib/usercopy_64.o/
/0 0 0 0 644 56832 `
/13 0 0 0 644 4352 `
/29 0 0 0 644 15000 `
…