Merge branch 'i2c/for-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
[sfrench/cifs-2.6.git] / arch / x86 / boot / compressed / Makefile
index f1356889204e5c74430bc78bf231c12901866730..536ccfcc01c673c4e3196a4fe57276cf7d7d53a8 100644 (file)
@@ -85,7 +85,25 @@ vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
        $(objtree)/drivers/firmware/efi/libstub/lib.a
 vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o
 
+# The compressed kernel is built with -fPIC/-fPIE so that a boot loader
+# can place it anywhere in memory and it will still run. However, since
+# it is executed as-is without any ELF relocation processing performed
+# (and has already had all relocation sections stripped from the binary),
+# none of the code can use data relocations (e.g. static assignments of
+# pointer values), since they will be meaningless at runtime. This check
+# will refuse to link the vmlinux if any of these relocations are found.
+quiet_cmd_check_data_rel = DATAREL $@
+define cmd_check_data_rel
+       for obj in $(filter %.o,$^); do \
+               readelf -S $$obj | grep -qF .rel.local && { \
+                       echo "error: $$obj has data relocations!" >&2; \
+                       exit 1; \
+               } || true; \
+       done
+endef
+
 $(obj)/vmlinux: $(vmlinux-objs-y) FORCE
+       $(call if_changed,check_data_rel)
        $(call if_changed,ld)
 
 OBJCOPYFLAGS_vmlinux.bin :=  -R .comment -S