Makefile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
  3. # the inclusion of generic Makefile.
  4. ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
  5. include $(srctree)/lib/vdso/Makefile
  6. # Symbols present in the vdso
  7. vdso-syms += rt_sigreturn
  8. vdso-syms += vgettimeofday
  9. # Files to link into the vdso
  10. obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
  11. ifneq ($(c-gettimeofday-y),)
  12. CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
  13. endif
  14. ccflags-y := -fno-stack-protector -DBUILD_VDSO32
  15. # Build rules
  16. targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
  17. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  18. obj-y += vdso.o vdso-syms.o
  19. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  20. # Disable gcov profiling for VDSO code
  21. GCOV_PROFILE := n
  22. KCOV_INSTRUMENT := n
  23. # Force dependency
  24. $(obj)/vdso.o: $(obj)/vdso.so
  25. SYSCFLAGS_vdso.so.dbg = $(c_flags)
  26. $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
  27. $(call if_changed,vdsold)
  28. SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
  29. -Wl,--build-id=sha1 -Wl,--hash-style=both
  30. $(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
  31. $(call if_changed,so2s)
  32. # strip rule for the .so file
  33. $(obj)/%.so: OBJCOPYFLAGS := -S
  34. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  35. $(call if_changed,objcopy)
  36. # actual build commands
  37. # The DSO images are built using a special linker script
  38. # Make sure only to export the intended __vdso_xxx symbol offsets.
  39. quiet_cmd_vdsold = VDSOLD $@
  40. cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
  41. -Wl,-T,$(filter-out FORCE,$^) -o [email protected] && \
  42. $(CROSS_COMPILE)objcopy \
  43. $(patsubst %, -G __vdso_%, $(vdso-syms)) [email protected] $@ && \
  44. rm [email protected]
  45. # Extracts symbol offsets from the VDSO, converting them into an assembly file
  46. # that contains the same symbols at the same offsets.
  47. quiet_cmd_so2s = SO2S $@
  48. cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
  49. # install commands for the unstripped file
  50. quiet_cmd_vdso_install = INSTALL $@
  51. cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@
  52. vdso.so: $(obj)/vdso.so.dbg
  53. @mkdir -p $(MODLIB)/vdso
  54. $(call cmd,vdso_install)
  55. vdso_install: vdso.so