Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. # Include the generic Makefile to check the built vdso.
  3. include $(srctree)/lib/vdso/Makefile
  4. # Symbols present in the vdso
  5. vdso-syms += rt_sigreturn
  6. vdso-syms += vgettimeofday
  7. # Files to link into the vdso
  8. obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
  9. ifneq ($(c-gettimeofday-y),)
  10. CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
  11. endif
  12. ccflags-y := -fno-stack-protector -DBUILD_VDSO32
  13. # Build rules
  14. targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
  15. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  16. obj-y += vdso.o vdso-syms.o
  17. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  18. # Force dependency
  19. $(obj)/vdso.o: $(obj)/vdso.so
  20. SYSCFLAGS_vdso.so.dbg = $(c_flags)
  21. $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
  22. $(call if_changed,vdsold)
  23. SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
  24. -Wl,--build-id=sha1 -Wl,--hash-style=both
  25. $(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
  26. $(call if_changed,so2s)
  27. # strip rule for the .so file
  28. $(obj)/%.so: OBJCOPYFLAGS := -S
  29. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  30. $(call if_changed,objcopy)
  31. # actual build commands
  32. # The DSO images are built using a special linker script
  33. # Make sure only to export the intended __vdso_xxx symbol offsets.
  34. quiet_cmd_vdsold = VDSOLD $@
  35. cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
  36. -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
  37. $(CROSS_COMPILE)objcopy \
  38. $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
  39. rm $@.tmp
  40. # Extracts symbol offsets from the VDSO, converting them into an assembly file
  41. # that contains the same symbols at the same offsets.
  42. quiet_cmd_so2s = SO2S $@
  43. cmd_so2s = $(NM) -D $< | $(src)/so2s.sh > $@