Initramfs: Difference between revisions

From coreboot
Jump to navigation Jump to search
(Fix objcopy --add-section to work also when the section already exists.)
mNo edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
How to inject a separate initramfs file into a 2.6 vmlinux (as section .init.ramfs):
This page describes how to inject a gzipped initramfs cpio file into vmlinux as section '''.init.ramfs''':


First turn the initramfs into an ELF, excluding anything but the file data:
Firs, turn the initramfs into an ELF binary, excluding everything but the file data:


    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
$ '''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'''


Note that the symbol names _binary_initramfs_{start,end,size} depend on the input filename. objcopy does some translation here, e.g. a period (.) in the filename will become an underscore (_) in the symbols.
Note that the symbol names '''_binary_initramfs_{start,end,size}''' above depend on the input filename. objcopy does some translation so e.g. a period (.) in the filename becomes an underscore (_) in the symbol names. Then, remove any previous '''.init.ramfs''' section in vmlinux and add the new one from '''initramfs.elf''':


Now remove any existing .init.ramfs section in vmlinux and add the section in initramfs.elf:
$ '''objcopy -I elf32-i386 -O elf32-i386 -R .init.ramfs --add-section .init.ramfs=initramfs.elf vmlinux vmlinux.withnewinitramfs'''


    objcopy -I elf32-i386 -O elf32-i386 -R .init.ramfs --add-section .init.ramfs=initramfs.elf vmlinux vmlinux.withnewinitramfs
Done! Please test using '''vmlinux.withnewinitramfs''' as [[Payloads|payload]] with coreboot and let us know the result!
 
All done.

Latest revision as of 16:35, 19 September 2010

This page describes how to inject a gzipped initramfs cpio file into vmlinux as section .init.ramfs:

Firs, turn the initramfs into an ELF binary, excluding everything but the file data:

$ 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

Note that the symbol names _binary_initramfs_{start,end,size} above depend on the input filename. objcopy does some translation so e.g. a period (.) in the filename becomes an underscore (_) in the symbol names. Then, remove any previous .init.ramfs section in vmlinux and add the new one from initramfs.elf:

$ objcopy -I elf32-i386 -O elf32-i386 -R .init.ramfs --add-section .init.ramfs=initramfs.elf vmlinux vmlinux.withnewinitramfs

Done! Please test using vmlinux.withnewinitramfs as payload with coreboot and let us know the result!