Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ccflags-y += -DDISABLE_BRANCH_PROFILING
  18. ifneq ($(c-gettimeofday-y),)
  19. CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
  20. endif
  21. # Build rules
  22. targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds
  23. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  24. obj-y += vdso.o
  25. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  26. ifneq ($(filter vgettimeofday, $(vdso-syms)),)
  27. CPPFLAGS_vdso.lds += -DHAS_VGETTIMEOFDAY
  28. endif
  29. # Disable -pg to prevent insert call site
  30. CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE)
  31. # Disable profiling and instrumentation for VDSO code
  32. GCOV_PROFILE := n
  33. KCOV_INSTRUMENT := n
  34. KASAN_SANITIZE := n
  35. UBSAN_SANITIZE := n
  36. # Force dependency
  37. $(obj)/vdso.o: $(obj)/vdso.so
  38. # link rule for the .so file, .lds has to be first
  39. $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
  40. $(call if_changed,vdsold)
  41. LDFLAGS_vdso.so.dbg = -shared -S -soname=linux-vdso.so.1 \
  42. --build-id=sha1 --hash-style=both --eh-frame-hdr
  43. # strip rule for the .so file
  44. $(obj)/%.so: OBJCOPYFLAGS := -S
  45. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  46. $(call if_changed,objcopy)
  47. # Generate VDSO offsets using helper script
  48. gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
  49. quiet_cmd_vdsosym = VDSOSYM $@
  50. cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
  51. include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
  52. $(call if_changed,vdsosym)
  53. # actual build commands
  54. # The DSO images are built using a special linker script
  55. # Make sure only to export the intended __vdso_xxx symbol offsets.
  56. quiet_cmd_vdsold = VDSOLD $@
  57. cmd_vdsold = $(LD) $(ld_flags) -T $(filter-out FORCE,$^) -o [email protected] && \
  58. $(OBJCOPY) $(patsubst %, -G __vdso_%, $(vdso-syms)) [email protected] $@ && \
  59. rm [email protected]
  60. # install commands for the unstripped file
  61. quiet_cmd_vdso_install = INSTALL $@
  62. cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@
  63. vdso.so: $(obj)/vdso.so.dbg
  64. @mkdir -p $(MODLIB)/vdso
  65. $(call cmd,vdso_install)
  66. vdso_install: vdso.so