Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. # Copied from arch/tile/kernel/vdso/Makefile
  3. # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
  4. # the inclusion of generic Makefile.
  5. ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
  6. include $(srctree)/lib/vdso/Makefile
  7. # Symbols present in the vdso
  8. vdso-syms = rt_sigreturn
  9. ifdef CONFIG_64BIT
  10. vdso-syms += vgettimeofday
  11. endif
  12. vdso-syms += getcpu
  13. vdso-syms += flush_icache
  14. # Files to link into the vdso
  15. obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
  16. ccflags-y := -fno-stack-protector
  17. ifneq ($(c-gettimeofday-y),)
  18. CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
  19. endif
  20. # Build rules
  21. targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
  22. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  23. obj-y += vdso.o
  24. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  25. # Disable -pg to prevent insert call site
  26. CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
  27. # Disable profiling and instrumentation for VDSO code
  28. GCOV_PROFILE := n
  29. KCOV_INSTRUMENT := n
  30. KASAN_SANITIZE := n
  31. # Force dependency
  32. $(obj)/vdso.o: $(obj)/vdso.so
  33. # link rule for the .so file, .lds has to be first
  34. $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
  35. $(call if_changed,vdsold)
  36. LDFLAGS_vdso.so.dbg = -shared -S -soname=linux-vdso.so.1 \
  37. --build-id=sha1 --hash-style=both --eh-frame-hdr
  38. # strip rule for the .so file
  39. $(obj)/%.so: OBJCOPYFLAGS := -S
  40. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  41. $(call if_changed,objcopy)
  42. # Generate VDSO offsets using helper script
  43. gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
  44. quiet_cmd_vdsosym = VDSOSYM $@
  45. cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
  46. include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
  47. $(call if_changed,vdsosym)
  48. # actual build commands
  49. # The DSO images are built using a special linker script
  50. # Make sure only to export the intended __vdso_xxx symbol offsets.
  51. quiet_cmd_vdsold = VDSOLD $@
  52. cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o $@.tmp && \
  53. $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
  54. rm $@.tmp
  55. # install commands for the unstripped file
  56. quiet_cmd_vdso_install = INSTALL $@
  57. cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
  58. vdso.so: $(obj)/vdso.so.dbg
  59. @mkdir -p $(MODLIB)/vdso
  60. $(call cmd,vdso_install)
  61. vdso_install: vdso.so