Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #
  2. # Building vDSO images for x86.
  3. #
  4. VDSO64-y := y
  5. vdso-install-$(VDSO64-y) += vdso.so
  6. # files to link into the vdso
  7. vobjs-y := vdso-note.o um_vdso.o
  8. # files to link into kernel
  9. obj-$(VDSO64-y) += vdso.o vma.o
  10. vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
  11. $(obj)/vdso.o: $(obj)/vdso.so
  12. targets += vdso.so vdso.so.dbg vdso.lds $(vobjs-y)
  13. export CPPFLAGS_vdso.lds += -P -C
  14. VDSO_LDFLAGS_vdso.lds = -m64 -Wl,-soname=linux-vdso.so.1 \
  15. -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
  16. $(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
  17. $(obj)/vdso.so.dbg: $(src)/vdso.lds $(vobjs) FORCE
  18. $(call if_changed,vdso)
  19. $(obj)/%.so: OBJCOPYFLAGS := -S
  20. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  21. $(call if_changed,objcopy)
  22. #
  23. # Don't omit frame pointers for ease of userspace debugging, but do
  24. # optimize sibling calls.
  25. #
  26. CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
  27. $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
  28. -fno-omit-frame-pointer -foptimize-sibling-calls
  29. $(vobjs): KBUILD_CFLAGS += $(CFL)
  30. #
  31. # vDSO code runs in userspace and -pg doesn't help with profiling anyway.
  32. #
  33. CFLAGS_REMOVE_vdso-note.o = -pg -fprofile-arcs -ftest-coverage
  34. CFLAGS_REMOVE_um_vdso.o = -pg -fprofile-arcs -ftest-coverage
  35. targets += vdso-syms.lds
  36. obj-$(VDSO64-y) += vdso-syms.lds
  37. #
  38. # Match symbols in the DSO that look like VDSO*; produce a file of constants.
  39. #
  40. sed-vdsosym := -e 's/^00*/0/' \
  41. -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
  42. quiet_cmd_vdsosym = VDSOSYM $@
  43. define cmd_vdsosym
  44. $(NM) $< | LC_ALL=C sed -n $(sed-vdsosym) | LC_ALL=C sort > $@
  45. endef
  46. $(obj)/%-syms.lds: $(obj)/%.so.dbg FORCE
  47. $(call if_changed,vdsosym)
  48. #
  49. # The DSO images are built using a special linker script.
  50. #
  51. quiet_cmd_vdso = VDSO $@
  52. cmd_vdso = $(CC) -nostdlib -o $@ \
  53. $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
  54. -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
  55. sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
  56. VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
  57. GCOV_PROFILE := n
  58. #
  59. # Install the unstripped copy of vdso*.so listed in $(vdso-install-y).
  60. #
  61. quiet_cmd_vdso_install = INSTALL $@
  62. cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
  63. $(vdso-install-y): %.so: $(obj)/%.so.dbg FORCE
  64. @mkdir -p $(MODLIB)/vdso
  65. $(call cmd,vdso_install)
  66. PHONY += vdso_install $(vdso-install-y)
  67. vdso_install: $(vdso-install-y)