Difference between revisions of "Initramfs"

From coreboot
Jump to: navigation, search
(How to inject an initramfs into a vmlinux.)
 
(Fix objcopy --add-section to work also when the section already exists.)
Line 1: Line 1:
How to inject a separate initramfs file into a 2.6 vmlinux: (as section .init.ramfs)
+
How to inject a separate initramfs file into a 2.6 vmlinux (as section .init.ramfs):
  
 
First turn the initramfs into an ELF, excluding anything but the file data:
 
First turn the initramfs into an ELF, excluding anything but the file data:
Line 7: Line 7:
 
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} depend on the input filename. objcopy does some translation here, e.g. a period (.) in the filename will become an underscore (_) in the symbols.
  
Now add the .init.ramfs section from initramfs.elf into the vmlinux file:
+
Now remove any existing .init.ramfs section in vmlinux and add the section in initramfs.elf:
  
     objcopy -I elf32-i386 -O elf32-i386 --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
  
 
All done.
 
All done.

Revision as of 23:43, 6 August 2008

How to inject a separate initramfs file into a 2.6 vmlinux (as section .init.ramfs):

First turn the initramfs into an ELF, excluding anything 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} depend on the input filename. objcopy does some translation here, e.g. a period (.) in the filename will become an underscore (_) in the symbols.

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

All done.