Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # SPDX-License-Identifier: GPL-2.0
  2. # List of files in the vdso, has to be asm only for now
  3. KCOV_INSTRUMENT := n
  4. obj-vdso32 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
  5. # Build rules
  6. targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
  7. obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
  8. KBUILD_AFLAGS += -DBUILD_VDSO
  9. KBUILD_CFLAGS += -DBUILD_VDSO
  10. KBUILD_AFLAGS_31 := $(filter-out -m64,$(KBUILD_AFLAGS))
  11. KBUILD_AFLAGS_31 += -m31 -s
  12. KBUILD_CFLAGS_31 := $(filter-out -m64,$(KBUILD_CFLAGS))
  13. KBUILD_CFLAGS_31 += -m31 -fPIC -shared -fno-common -fno-builtin
  14. KBUILD_CFLAGS_31 += -nostdlib -Wl,-soname=linux-vdso32.so.1 \
  15. $(call cc-ldoption, -Wl$(comma)--hash-style=both)
  16. $(targets:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_31)
  17. $(targets:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_31)
  18. obj-y += vdso32_wrapper.o
  19. extra-y += vdso32.lds
  20. CPPFLAGS_vdso32.lds += -P -C -U$(ARCH)
  21. # Disable gcov profiling, ubsan and kasan for VDSO code
  22. GCOV_PROFILE := n
  23. UBSAN_SANITIZE := n
  24. KASAN_SANITIZE := n
  25. # Force dependency (incbin is bad)
  26. $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so
  27. # link rule for the .so file, .lds has to be first
  28. $(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE
  29. $(call if_changed,vdso32ld)
  30. # strip rule for the .so file
  31. $(obj)/%.so: OBJCOPYFLAGS := -S
  32. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  33. $(call if_changed,objcopy)
  34. # assembly rules for the .S files
  35. $(obj-vdso32): %.o: %.S FORCE
  36. $(call if_changed_dep,vdso32as)
  37. # actual build commands
  38. quiet_cmd_vdso32ld = VDSO32L $@
  39. cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $(filter %.lds %.o,$^) -o $@
  40. quiet_cmd_vdso32as = VDSO32A $@
  41. cmd_vdso32as = $(CC) $(a_flags) -c -o $@ $<
  42. # install commands for the unstripped file
  43. quiet_cmd_vdso_install = INSTALL $@
  44. cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
  45. vdso32.so: $(obj)/vdso32.so.dbg
  46. @mkdir -p $(MODLIB)/vdso
  47. $(call cmd,vdso_install)
  48. vdso_install: vdso32.so