s390: introduce .boot.data section compile time validation
authorVasily Gorbik <gor@linux.ibm.com>
Tue, 10 Apr 2018 12:24:40 +0000 (14:24 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 9 Oct 2018 09:21:08 +0000 (11:21 +0200)
Make sure that .boot.data sections of vmlinux and
arch/s390/compressed/vmlinux match before producing the compressed kernel
image. Symbols presence, order and sizes are cross-checked.

Reviewed-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/boot/.gitignore
arch/s390/boot/Makefile

index 017d5912ad2d59a1a85024c20732298b7ad347a4..16ff906e46103b99ddcc4ae65d4ef93108f77419 100644 (file)
@@ -1,2 +1,3 @@
 image
 bzImage
+section_cmp.*
index 5e2cec6e4b3e58c7b3c03ee947ca8d2a6aeeb476..b6903c47e0ac2878a2599f7947929d4fba7fed8a 100644 (file)
@@ -28,14 +28,30 @@ endif
 CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char
 
 obj-y  := head.o als.o startup.o mem_detect.o ebcdic.o sclp_early_core.o mem.o
-targets        := bzImage startup.a $(obj-y)
+targets        := bzImage startup.a section_cmp.boot.data $(obj-y)
 subdir-        := compressed
 
 OBJECTS := $(addprefix $(obj)/,$(obj-y))
 
-$(obj)/bzImage: $(obj)/compressed/vmlinux FORCE
+quiet_cmd_section_cmp = SECTCMP $*
+define cmd_section_cmp
+       s1=`$(OBJDUMP) -t -j "$*" "$<" | sort | \
+               sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
+       s2=`$(OBJDUMP) -t -j "$*" "$(word 2,$^)" | sort | \
+               sed -n "/0000000000000000/! s/.*\s$*\s\+//p" | sha256sum`; \
+       if [ "$$s1" != "$$s2" ]; then \
+               echo "error: section $* differs between $< and $(word 2,$^)" >&2; \
+               exit 1; \
+       fi; \
+       touch $@
+endef
+
+$(obj)/bzImage: $(obj)/compressed/vmlinux $(obj)/section_cmp.boot.data FORCE
        $(call if_changed,objcopy)
 
+$(obj)/section_cmp%: vmlinux $(obj)/compressed/vmlinux FORCE
+       $(call if_changed,section_cmp)
+
 $(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
        $(Q)$(MAKE) $(build)=$(obj)/compressed $@