blochl ... the instructions from coreboot look pretty staightforward to me:
Code: Select all
# file initramfs
initramfs: ASCII cpio archive (SVR4 with no CRC)
# objcopy -I binary -O elf32-i386 -B i386 --redefine-sym _binary_initramfs_start=.init.ramfs -N _binary_initramfs_end -N _binary_initramfs_size initramfs initramfs.elf
# file initramfs.elf
initramfs.elf: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped
# cp /usr/src/linux/vmlinux .
# file vmlinux
vmlinux: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, BuildID[sha1]=364adc71e0470c199d5cd55e6bcaeb9163943ce4, not stripped
# objcopy -I elf32-i386 -O elf32-i386 -R .init.ramfs --add-section .init.ramfs=initramfs.elf vmlinux vmlinux.withnewinitramfs
# ls -lh vmlinux*
-rwxr-xr-x 1 root root 10M 2018-04-28 19:46 vmlinux*
-rwxr-xr-x 1 root root 16M 2018-10-18 15:31 vmlinux.withnewinitramfs*Code: Select all
vmlinux: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00602000 ffffffff81000000 0000000001000000 00200000 2**12
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .notes 00000024 ffffffff81602000 0000000001602000 00802000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 __ex_table 0000255c ffffffff81602030 0000000001602030 00802030 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .rodata 0010ee78 ffffffff81800000 0000000001800000 00a00000 2**12
CONTENTS, ALLOC, LOAD, DATA
4 .pci_fixup 00003300 ffffffff8190ee78 000000000190ee78 00b0ee78 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 __param 00002120 ffffffff81912178 0000000001912178 00b12178 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 __modver 00000d68 ffffffff81914298 0000000001914298 00b14298 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .data 00086a80 ffffffff81a00000 0000000001a00000 00c00000 2**13
CONTENTS, ALLOC, LOAD, DATA
8 __bug_table 00009f60 ffffffff81a86a80 0000000001a86a80 00c86a80 2**0
CONTENTS, ALLOC, LOAD, DATA
9 .orc_unwind_ip 0006e860 ffffffff81a909e0 0000000001a909e0 00c909e0 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .orc_unwind 000a5c90 ffffffff81aff242 0000000001aff242 00cff242 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
11 .orc_lookup 00018084 ffffffff81ba4ed4 0000000001ba4ed4 00da4ed2 2**0
ALLOC
12 .vvar 00001000 ffffffff81bbd000 0000000001bbd000 00dbd000 2**4
CONTENTS, ALLOC, LOAD, DATA
13 .init.text 0002b7bd ffffffff81bbe000 0000000001bbe000 00dbe000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
14 .altinstr_aux 000007de ffffffff81be97bd 0000000001be97bd 00de97bd 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
15 .init.data 00506678 ffffffff81bea000 0000000001bea000 00dea000 2**13
CONTENTS, ALLOC, LOAD, DATA
16 .x86_cpu_dev.init 00000018 ffffffff820f0678 00000000020f0678 012f0678 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
17 .altinstructions 00002db4 ffffffff820f0690 00000000020f0690 012f0690 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
18 .altinstr_replacement 00000abd ffffffff820f3444 00000000020f3444 012f3444 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
19 .iommu_table 00000050 ffffffff820f3f08 00000000020f3f08 012f3f08 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
20 .apicdrivers 00000010 ffffffff820f3f58 00000000020f3f58 012f3f58 2**3
CONTENTS, ALLOC, LOAD, DATA
21 .exit.text 00001282 ffffffff820f3f68 00000000020f3f68 012f3f68 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
22 .data..percpu 00000000 ffffffff820f6000 00000000020f51ea 012f51ea 2**0
CONTENTS, ALLOC, LOAD, DATA
23 .smp_locks 00000000 ffffffff820f6000 ffffffff820f6000 012f51ea 2**0
CONTENTS
24 .data_nosave 00000000 ffffffff820f6000 ffffffff820f6000 012f51ea 2**0
CONTENTS
25 .bss 00031000 ffffffff820f6000 00000000020f6000 012f51ea 2**12
ALLOC
26 .brk 0002c000 ffffffff82127000 0000000002127000 012f51ea 2**0
ALLOC
Code: Select all
objcopy --add-section .initrd="external.initramfs" \
--change-section-vma .initrd=0x3000000 \
original-bzImage new-bzImage
Code: Select all
objdump -h new-bzImageCode: Select all
Sections:
Idx Name Size VMA LMA File off Algn
0 .setup 00003be0 0000000000000200 0000000000000200 00000250 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .reloc 00000020 0000000000003de0 0000000000003de0 00003e30 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .text 0071d230 0000000000003e00 0000000000003e00 00003e50 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .bss 00c5afd0 0000000000721030 0000000000721030 00000000 2**4
ALLOC
4 .initrd 00000200 0000000003000000 0000000003000000 00721090 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
Code: Select all
Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section .bss
blochl ... why not build an initramfs that doesn't require updating? ... there's no reason to really (it's just that some think it a good idea to include kernel modules in the initramfs). Here's an example, or the prebuilt version. Note, these will be built against uClibc (and with the 'devel' branch, musl), and so the size is considerably smaller.blochl wrote:Therefore I'm going for the really messy solution of recompiling the kernel each time I want to change the initramfs. It's very messy and not elegant, but it's the only way to get what I want in a reliable manner.