Makefile 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # SPDX-License-Identifier: GPL-2.0
  2. #
  3. # Building a vDSO image for AArch64.
  4. #
  5. # Author: Will Deacon <[email protected]>
  6. # Heavily based on the vDSO Makefiles for other archs.
  7. #
  8. # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
  9. # the inclusion of generic Makefile.
  10. ARCH_REL_TYPE_ABS := R_AARCH64_JUMP_SLOT|R_AARCH64_GLOB_DAT|R_AARCH64_ABS64
  11. include $(srctree)/lib/vdso/Makefile
  12. obj-vdso := vgettimeofday.o note.o sigreturn.o
  13. # Build rules
  14. targets := $(obj-vdso) vdso.so vdso.so.dbg
  15. obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
  16. btildflags-$(CONFIG_ARM64_BTI_KERNEL) += -z force-bti
  17. # -Bsymbolic has been added for consistency with arm, the compat vDSO and
  18. # potential future proofing if we end up with internal calls to the exported
  19. # routines, as x86 does (see 6f121e548f83 ("x86, vdso: Reimplement vdso.so
  20. # preparation in build-time C")).
  21. ldflags-y := -shared -soname=linux-vdso.so.1 --hash-style=sysv \
  22. -Bsymbolic --build-id=sha1 -n $(btildflags-y)
  23. ifdef CONFIG_LD_ORPHAN_WARN
  24. ldflags-y += --orphan-handling=warn
  25. endif
  26. ldflags-y += -T
  27. ccflags-y := -fno-common -fno-builtin -fno-stack-protector -ffixed-x18
  28. ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
  29. # -Wmissing-prototypes and -Wmissing-declarations are removed from
  30. # the CFLAGS of vgettimeofday.c to make possible to build the
  31. # kernel with CONFIG_WERROR enabled.
  32. CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \
  33. $(RANDSTRUCT_CFLAGS) $(GCC_PLUGINS_CFLAGS) \
  34. $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
  35. -Wmissing-prototypes -Wmissing-declarations
  36. KASAN_SANITIZE := n
  37. KCSAN_SANITIZE := n
  38. UBSAN_SANITIZE := n
  39. OBJECT_FILES_NON_STANDARD := y
  40. KCOV_INSTRUMENT := n
  41. CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny -fasynchronous-unwind-tables
  42. ifneq ($(c-gettimeofday-y),)
  43. CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
  44. endif
  45. # Disable gcov profiling for VDSO code
  46. GCOV_PROFILE := n
  47. targets += vdso.lds
  48. CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
  49. # Link rule for the .so file, .lds has to be first
  50. $(obj)/vdso.so.dbg: $(obj)/vdso.lds $(obj-vdso) FORCE
  51. $(call if_changed,vdsold_and_vdso_check)
  52. # Strip rule for the .so file
  53. $(obj)/%.so: OBJCOPYFLAGS := -S
  54. $(obj)/%.so: $(obj)/%.so.dbg FORCE
  55. $(call if_changed,objcopy)
  56. # Generate VDSO offsets using helper script
  57. gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh
  58. quiet_cmd_vdsosym = VDSOSYM $@
  59. cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
  60. include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE
  61. $(call if_changed,vdsosym)
  62. # Actual build commands
  63. quiet_cmd_vdsold_and_vdso_check = LD $@
  64. cmd_vdsold_and_vdso_check = $(cmd_ld); $(cmd_vdso_check)
  65. # Install commands for the unstripped file
  66. quiet_cmd_vdso_install = INSTALL $@
  67. cmd_vdso_install = cp $(obj)/[email protected] $(MODLIB)/vdso/$@
  68. vdso.so: $(obj)/vdso.so.dbg
  69. @mkdir -p $(MODLIB)/vdso
  70. $(call cmd,vdso_install)
  71. vdso_install: vdso.so