Makefile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. hostprogs-y := vdsomunge
  2. obj-vdso := vgettimeofday.o datapage.o
  3. # Build rules
  4. targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.so.raw vdso.lds
  5. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  6. ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector
  7. ccflags-y += -DDISABLE_BRANCH_PROFILING
  8. VDSO_LDFLAGS := -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
  9. VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
  10. VDSO_LDFLAGS += -nostdlib -shared
  11. VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
  12. VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id)
  13. VDSO_LDFLAGS += $(call cc-ldoption, -fuse-ld=bfd)
  14. obj-$(CONFIG_VDSO) += vdso.o
  15. extra-$(CONFIG_VDSO) += vdso.lds
  16. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  17. CFLAGS_REMOVE_vdso.o = -pg
  18. # Force -O2 to avoid libgcc dependencies
  19. CFLAGS_REMOVE_vgettimeofday.o = -pg -Os
  20. CFLAGS_vgettimeofday.o = -O2
  21. # Disable gcov profiling for VDSO code
  22. GCOV_PROFILE := n
  23. # Force dependency
  24. $(obj)/vdso.o : $(obj)/vdso.so
  25. # Link rule for the .so file
  26. $(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
  27. $(call if_changed,vdsold)
  28. $(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE
  29. $(call if_changed,vdsomunge)
  30. # Strip rule for the .so file
  31. $(obj)/%.so: OBJCOPYFLAGS := -S
  32. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  33. $(call if_changed,objcopy)
  34. # Actual build commands
  35. quiet_cmd_vdsold = VDSO $@
  36. cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
  37. -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
  38. quiet_cmd_vdsomunge = MUNGE $@
  39. cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
  40. #
  41. # Install the unstripped copy of vdso.so.dbg. If our toolchain
  42. # supports build-id, install .build-id links as well.
  43. #
  44. # Cribbed from arch/x86/vdso/Makefile.
  45. #
  46. quiet_cmd_vdso_install = INSTALL $<
  47. define cmd_vdso_install
  48. cp $< "$(MODLIB)/vdso/vdso.so"; \
  49. if readelf -n $< | grep -q 'Build ID'; then \
  50. buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
  51. first=`echo $$buildid | cut -b-2`; \
  52. last=`echo $$buildid | cut -b3-`; \
  53. mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
  54. ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
  55. fi
  56. endef
  57. $(MODLIB)/vdso: FORCE
  58. @mkdir -p $(MODLIB)/vdso
  59. PHONY += vdso_install
  60. vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso
  61. $(call cmd,vdso_install)