linux-5.11 镜像 的生成过程
vmlinux -objcopy-> arch/arm/boot/Image
arch/arm/boot/Image -gzip & add arch/arm/boot/compressed/head.S-> arch/arm/boot/compressed/vmlinux
arch/arm/boot/compressed/vmlinux -objcopy-> arch/arm/boot/zImage
arch/arm/boot/zImage -mkuboot-> arch/arm/boot/uImage
五种镜像的感性区别
vmlinux : 5M
arch/arm/boot/Image : 6.5M
arch/arm/boot/compressed/vmlinux : 1.9M
arch/arm/boot/zImage : 1.8M
arch/arm/boot/uImage : 1.8M
五种镜像
arm-linux-gnueabi-gcc
-E -Wp,-MMD,arch/arm/kernel/.vmlinux.lds.d
-nostdinc
-isystem /home/mmt/work/BiscuitOS/output/linux-5.10-arm32/arm-linux-gnueabi/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include
-I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi
-include ./include/linux/kconfig.h
-D__KERNEL__
-mlittle-endian
-DTEXT_OFFSET=0x00008000
-P
-Uarm
-D__ASSEMBLY__
-DLINKER_SCRIPT
-o arch/arm/kernel/vmlinux.lds arch/arm/kernel/vmlinux.lds.S
arm-linux-gnueabi-ld
-EL
--no-undefined
-X
--pic-veneer
-z norelro
--build-id=sha1
--orphan-handling=warn
-o vmlinux
-T ./arch/arm/kernel/vmlinux.lds
--whole-archive
For each archive mentioned on the command line after the --whole-archive option, include every object file in the archive in the link, rather than searching the archive for the required object files. This is normally used to turn an
archive file into a shared library, forcing every object to be included in the resulting shared library. This option may be used more than once.
Two notes when using this option from gcc: First, gcc doesn't know about this option, so you have to use -Wl,-whole-archive. Second, don't forget to use -Wl,-no-whole-archive after your list of archives, because gcc will add its own list
of archives to your link and you may not want this flag to affect those as well.
arch/arm/kernel/head.o
init/built-in.a
usr/built-in.a
arch/arm/built-in.a
arch/arm/mach-s3c/built-in.a
kernel/built-in.a
certs/built-in.a
mm/built-in.a
fs/built-in.a
ipc/built-in.a
security/built-in.a
crypto/built-in.a
block/built-in.a
arch/arm/lib/built-in.a
lib/built-in.a
drivers/built-in.a
sound/built-in.a
net/built-in.a
virt/built-in.a
--no-whole-archive
--start-group
arch/arm/lib/lib.a
lib/lib.a
--end-group
.tmp_vmlinux.kallsyms2.o
arm-linux-gnueabi-objcopy
-O binary
Write the output file using the object format bfdname.
-R .comment
Remove any section matching sectionpattern from the output file. This option may be given more than once. Note that using this option inappropriately may make the output file unusable. Wildcard characters are accepted in
sectionpattern. Using both the -j and -R options together results in undefined behaviour.
-S
Do not copy relocation and symbol information from the source file.
vmlinux
infile
arch/arm/boot/Image
outfile
- arch/arm/boot/compressed/vmlinux
cat arch/arm/boot/compressed/../Image |
gzip
-n
When compressing, do not save the original file name and time stamp by default. (The original name is always saved if the name had to be
truncated.) When decompressing, do not restore the original file name if present (remove only the gzip suffix from the compressed file name)
and do not restore the original time stamp if present (copy it from the compressed file). This option is the default when decompressing.
-f
Force compression or decompression even if the file has multiple links or the corresponding file already exists, or if the compressed data is
read from or written to a terminal. If the input data is not in a format recognized by gzip, and if the option --stdout is also given, copy
the input data without change to the standard output: let zcat behave as cat. If -f is not given, and when not running in the background,
gzip prompts to verify whether an existing file should be overwritten.
-9
Regulate the speed of compression using the specified digit #, where -1 or --fast indicates the fastest compression method (less compression)
and -9 or --best indicates the slowest compression method (best compression). The default compression level is -6 (that is, biased towards
high compression at expense of speed).
> arch/arm/boot/compressed/piggy_data
$ cat arch/arm/boot/compressed/piggy.S
.section .piggydata, "a"
.globl input_data
input_data:
.incbin "arch/arm/boot/compressed/piggy_data"
.globl input_data_end
input_data_end:
arm-linux-gnueabi-gcc
-Wp,-MMD,arch/arm/boot/compressed/.piggy.o.d
-nostdinc
-isystem /home/suws/ok6410/system-new/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include
-I./arch/arm/include
-I./arch/arm/include/generated
-I./include
-I./arch/arm/include/uapi
-I./arch/arm/include/generated/uapi
-I./include/uapi
-I./include/generated/uapi
-include ./include/linux/kconfig.h
-D__KERNEL__
-mlittle-endian
-D__ASSEMBLY__
-fno-PIE
-mabi=aapcs-linux
-mfpu=vfp
Use hardware FPP floating point. This is the default. (FIS floating point on the PDP-11/40 is not supported.)
-funwind-tables
Similar to -fexceptions, except that it just generates any needed static data, but does not affect the generated code in any other way. You normally do not need to enable this option; instead, a language processor that needs this
handling enables it on your behalf.
-marm
Select between generating code that executes in ARM and Thumb states. The default for most configurations is to generate code that executes in ARM state, but the default can be changed by configuring GCC with the --with-mode=state
configure option.
-Wa,-mno-warn-deprecated
-D__LINUX_ARM_ARCH__=6
-march=armv6k
-mtune=arm1136j-s
Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions. While picking a specific cpu-type schedules things appropriately for that particular chip, the compiler does not
generate any code that cannot run on the default machine type unless you use a -march=cpu-type option. For example, if GCC is configured for i686-pc-linux-gnu then -mtune=pentium4 generates code that is tuned for Pentium 4 but still runs
on i686 machines.
The choices for cpu-type are the same as for -march. In addition, -mtune supports 2 extra choices for cpu-type:
-include asm/unified.h
-msoft-float
Generate output containing library calls for floating point.
Warning: the requisite libraries are not part of GCC. Normally the facilities of the machine's usual C compiler are used, but this can't be done directly in cross-compilation. You must make your own arrangements to provide suitable
library functions for cross-compilation.
On machines where a function returns floating-point results in the 80387 register stack, some floating-point opcodes may be emitted even if -msoft-float is used.
-DZIMAGE
-c
-o arch/arm/boot/compressed/piggy.o
arch/arm/boot/compressed/piggy.S
arm-linux-gnueabi-gcc
-E -Wp,-MMD,arch/arm/boot/compressed/.vmlinux.lds.d
-nostdinc
-isystem /home/mmt/work/BiscuitOS/output/linux-5.10-arm32/arm-linux-gnueabi/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/bin/../lib/gcc/arm-linux-gnueabi/7.4.1/include
-I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi
-include ./include/linux/kconfig.h
-D__KERNEL__
-mlittle-endian
-DTEXT_START="0"
-DBSS_START="ALIGN(8)"
-DTEXT_OFFSET="0x00008000"
-DMALLOC_SIZE="65536"
-P
-Uarm
-D__ASSEMBLY__
-DLINKER_SCRIPT
-o arch/arm/boot/compressed/vmlinux.lds
arch/arm/boot/compressed/vmlinux.lds.S
arm-linux-gnueabi-ld
-EL
--defsym _kernel_bss_size=190768
--defsym=symbol=expression
Create a global symbol in the output file, containing the absolute address given by expression. You may use this option as many times as necessary to define multiple symbols in the command line. A limited form of arithmetic is supported
for the expression in this context: you may give a hexadecimal constant or the name of an existing symbol, or use "+" and "-" to add or subtract hexadecimal constants or symbols. If you need more elaborate expressions, consider using the
linker command language from a script. Note: there should be no white space between symbol, the equals sign ("="), and expression.
--no-undefined
-X
--orphan-handling=warn
-T arch/arm/boot/compressed/vmlinux.lds
arch/arm/boot/compressed/head.o
arch/arm/boot/compressed/piggy.o
arch/arm/boot/compressed/misc.o
arch/arm/boot/compressed/decompress.o
arch/arm/boot/compressed/string.o
arch/arm/boot/compressed/hyp-stub.o
arch/arm/boot/compressed/lib1funcs.o
arch/arm/boot/compressed/ashldi3.o
arch/arm/boot/compressed/bswapsdi2.o
-o arch/arm/boot/compressed/vmlinux
arm-linux-gnueabi-objcopy
-O binary
-R .comment
-S
arch/arm/boot/compressed/vmlinux
arch/arm/boot/zImage
bash
./scripts/mkuboot.sh
-A arm
-A arm 架构是arm
-O linux
-O linux 系统是linux
-C none
-C none 没压缩
-T kernel
-T kernel 类型是kernel
-a 0x50008000
加载地址
-e 0x50008000
入口地址
-n 'Linux-5.11.0-187606-gd64fe683e8d'
名字
-d arch/arm/boot/zImage
输入文件
arch/arm/boot/uImage
输入文件
五种镜像的使用
bootcmd=fatload mmc 0:1 0x50008000 uImage;bootm 0x50008000;
fatload 就是一个一个字节的拷贝,下面就看 bootm 做了什么了