Skip to content

Commit edd4a86

Browse files
committed
s390/boot: get rid of startup archive
The final kernel image is created by linking decompressor object files with a startup archive. The startup archive file however does not contain only optional code and data which can be discarded if not referenced. It also contains mandatory object data like head.o which must never be discarded, even if not referenced. Move the decompresser code and linker script to the boot directory and get rid of the startup archive so everything is kept during link time. Acked-by: Vasily Gorbik <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 964bc5d commit edd4a86

File tree

11 files changed

+74
-101
lines changed

11 files changed

+74
-101
lines changed

arch/s390/boot/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
image
33
bzImage
44
section_cmp.*
5+
vmlinux
6+
vmlinux.lds
7+
vmlinux.syms

arch/s390/boot/Makefile

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ obj-y += version.o pgm_check_info.o ctype.o
4141
obj-$(findstring y, $(CONFIG_PROTECTED_VIRTUALIZATION_GUEST) $(CONFIG_PGSTE)) += uv.o
4242
obj-$(CONFIG_RELOCATABLE) += machine_kexec_reloc.o
4343
obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
44-
targets := bzImage startup.a section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
45-
subdir- := compressed
44+
obj-y += $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
45+
obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
46+
obj-all := $(obj-y) piggy.o syms.o
47+
48+
targets := bzImage section_cmp.boot.data section_cmp.boot.preserved.data $(obj-y)
49+
targets += vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
50+
targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
51+
targets += vmlinux.bin.zst info.bin syms.bin vmlinux.syms $(obj-all)
4652

4753
OBJECTS := $(addprefix $(obj)/,$(obj-y))
54+
OBJECTS_ALL := $(addprefix $(obj)/,$(obj-all))
4855

4956
quiet_cmd_section_cmp = SECTCMP $*
5057
define cmd_section_cmp
@@ -59,14 +66,67 @@ define cmd_section_cmp
5966
touch $@
6067
endef
6168

62-
$(obj)/bzImage: $(obj)/compressed/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
69+
$(obj)/bzImage: $(obj)/vmlinux $(obj)/section_cmp.boot.data $(obj)/section_cmp.boot.preserved.data FORCE
6370
$(call if_changed,objcopy)
6471

65-
$(obj)/section_cmp%: vmlinux $(obj)/compressed/vmlinux FORCE
72+
$(obj)/section_cmp%: vmlinux $(obj)/vmlinux FORCE
6673
$(call if_changed,section_cmp)
6774

68-
$(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
69-
$(Q)$(MAKE) $(build)=$(obj)/compressed $@
75+
LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup --build-id=sha1 -T
76+
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS_ALL) FORCE
77+
$(call if_changed,ld)
78+
79+
LDFLAGS_vmlinux.syms := --oformat $(LD_BFD) -e startup -T
80+
$(obj)/vmlinux.syms: $(obj)/vmlinux.lds $(OBJECTS) FORCE
81+
$(call if_changed,ld)
82+
83+
quiet_cmd_dumpsyms = DUMPSYMS $<
84+
define cmd_dumpsyms
85+
$(NM) -n -S --format=bsd "$<" | sed -nE 's/^0*([0-9a-fA-F]+) 0*([0-9a-fA-F]+) [tT] ([^ ]*)$$/\1 \2 \3/p' | tr '\n' '\0' > "$@"
86+
endef
87+
88+
$(obj)/syms.bin: $(obj)/vmlinux.syms FORCE
89+
$(call if_changed,dumpsyms)
90+
91+
OBJCOPYFLAGS_syms.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.decompressor.syms
92+
$(obj)/syms.o: $(obj)/syms.bin FORCE
93+
$(call if_changed,objcopy)
94+
95+
OBJCOPYFLAGS_info.bin := -O binary --only-section=.vmlinux.info --set-section-flags .vmlinux.info=load
96+
$(obj)/info.bin: vmlinux FORCE
97+
$(call if_changed,objcopy)
98+
99+
OBJCOPYFLAGS_info.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.info
100+
$(obj)/info.o: $(obj)/info.bin FORCE
101+
$(call if_changed,objcopy)
102+
103+
OBJCOPYFLAGS_vmlinux.bin := -O binary --remove-section=.comment --remove-section=.vmlinux.info -S
104+
$(obj)/vmlinux.bin: vmlinux FORCE
105+
$(call if_changed,objcopy)
106+
107+
suffix-$(CONFIG_KERNEL_GZIP) := .gz
108+
suffix-$(CONFIG_KERNEL_BZIP2) := .bz2
109+
suffix-$(CONFIG_KERNEL_LZ4) := .lz4
110+
suffix-$(CONFIG_KERNEL_LZMA) := .lzma
111+
suffix-$(CONFIG_KERNEL_LZO) := .lzo
112+
suffix-$(CONFIG_KERNEL_XZ) := .xz
113+
suffix-$(CONFIG_KERNEL_ZSTD) := .zst
70114

71-
$(obj)/startup.a: $(OBJECTS) FORCE
72-
$(call if_changed,ar)
115+
$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
116+
$(call if_changed,gzip)
117+
$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
118+
$(call if_changed,bzip2_with_size)
119+
$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE
120+
$(call if_changed,lz4_with_size)
121+
$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
122+
$(call if_changed,lzma_with_size)
123+
$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE
124+
$(call if_changed,lzo_with_size)
125+
$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE
126+
$(call if_changed,xzkern_with_size)
127+
$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE
128+
$(call if_changed,zstd22_with_size)
129+
130+
OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed
131+
$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
132+
$(call if_changed,objcopy)
File renamed without changes.

arch/s390/boot/compressed/.gitignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

arch/s390/boot/compressed/Makefile

Lines changed: 0 additions & 86 deletions
This file was deleted.

arch/s390/boot/kaslr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <asm/timex.h>
99
#include <asm/sclp.h>
1010
#include <asm/kasan.h>
11-
#include "compressed/decompressor.h"
11+
#include "decompressor.h"
1212
#include "boot.h"
1313

1414
#define PRNG_MODE_TDES 1

arch/s390/boot/mem_detect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <asm/sections.h>
88
#include <asm/mem_detect.h>
99
#include <asm/sparsemem.h>
10-
#include "compressed/decompressor.h"
10+
#include "decompressor.h"
1111
#include "boot.h"
1212

1313
struct mem_detect_info __bootdata(mem_detect);

arch/s390/boot/startup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <asm/sclp.h>
1111
#include <asm/diag.h>
1212
#include <asm/uv.h>
13-
#include "compressed/decompressor.h"
13+
#include "decompressor.h"
1414
#include "boot.h"
1515
#include "uv.h"
1616

0 commit comments

Comments
 (0)