Makefile 2.5 KB

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