Skip to content

Commit cd92ac2

Browse files
jwrdegoedeVasily Gorbik
authored andcommitted
s390/purgatory: Make sure we fail the build if purgatory has missing symbols
Since we link purgatory with -r aka we enable "incremental linking" no checks for unresolved symbols are done while linking the purgatory. This commit adds an extra check for unresolved symbols by calling ld without -r before running objcopy to generate purgatory.ro. This will help us catch missing symbols in the purgatory sooner. Note this commit also removes --no-undefined from LDFLAGS_purgatory as that has no effect. Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Tested-by: Philipp Rudo <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 6feeee8 commit cd92ac2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

arch/s390/purgatory/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
purgatory
2+
purgatory.chk
23
purgatory.lds
34
purgatory.ro

arch/s390/purgatory/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OBJECT_FILES_NON_STANDARD := y
44

55
purgatory-y := head.o purgatory.o string.o sha256.o mem.o
66

7-
targets += $(purgatory-y) purgatory.lds purgatory purgatory.ro
7+
targets += $(purgatory-y) purgatory.lds purgatory purgatory.chk purgatory.ro
88
PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
99

1010
$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
@@ -26,15 +26,22 @@ KBUILD_CFLAGS += $(CLANG_FLAGS)
2626
KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
2727
KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
2828

29-
LDFLAGS_purgatory := -r --no-undefined -nostdlib -z nodefaultlib -T
29+
# Since we link purgatory with -r unresolved symbols are not checked, so we
30+
# also link a purgatory.chk binary without -r to check for unresolved symbols.
31+
PURGATORY_LDFLAGS := -nostdlib -z nodefaultlib
32+
LDFLAGS_purgatory := -r $(PURGATORY_LDFLAGS) -T
33+
LDFLAGS_purgatory.chk := -e purgatory_start $(PURGATORY_LDFLAGS)
3034
$(obj)/purgatory: $(obj)/purgatory.lds $(PURGATORY_OBJS) FORCE
3135
$(call if_changed,ld)
3236

37+
$(obj)/purgatory.chk: $(obj)/purgatory FORCE
38+
$(call if_changed,ld)
39+
3340
OBJCOPYFLAGS_purgatory.ro := -O elf64-s390
3441
OBJCOPYFLAGS_purgatory.ro += --remove-section='*debug*'
3542
OBJCOPYFLAGS_purgatory.ro += --remove-section='.comment'
3643
OBJCOPYFLAGS_purgatory.ro += --remove-section='.note.*'
37-
$(obj)/purgatory.ro: $(obj)/purgatory FORCE
44+
$(obj)/purgatory.ro: $(obj)/purgatory $(obj)/purgatory.chk FORCE
3845
$(call if_changed,objcopy)
3946

4047
$(obj)/kexec-purgatory.o: $(obj)/kexec-purgatory.S $(obj)/purgatory.ro FORCE

0 commit comments

Comments
 (0)