1 # SPDX-License-Identifier: GPL-2.0 2 # 3 # Makefile for vdso32 4 # 5 6 include $(srctree)/lib/vdso/Makefile 7 8 # Same as cc-*option, but using CC_COMPAT inst 9 ifeq ($(CONFIG_CC_IS_CLANG), y) 10 CC_COMPAT ?= $(CC) 11 CC_COMPAT += --target=arm-linux-gnueabi 12 else 13 CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc 14 endif 15 16 ifeq ($(CONFIG_LD_IS_LLD), y) 17 LD_COMPAT ?= $(LD) 18 else 19 LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld 20 endif 21 22 cc32-option = $(call try-run,\ 23 $(CC_COMPAT) $(1) -c -x c /dev/null -o 24 cc32-disable-warning = $(call try-run,\ 25 $(CC_COMPAT) -W$(strip $(1)) -c -x c / 26 27 # We cannot use the global flags to compile th 28 # being that the 32-bit compiler may be older 29 # and therefore may not understand flags set u 30 # arch-specific options should be taken from t 31 # arm64 one. 32 # As a result we set our own flags here. 33 34 # KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top- 35 VDSO_CPPFLAGS := -DBUILD_VDSO -D__KERNEL__ -no 36 VDSO_CPPFLAGS += -isystem $(shell $(CC_COMPAT) 37 VDSO_CPPFLAGS += $(LINUXINCLUDE) 38 39 # Common C and assembly flags 40 # From top-level Makefile 41 VDSO_CAFLAGS := $(VDSO_CPPFLAGS) 42 VDSO_CAFLAGS += $(call cc32-option,-fno-PIE) 43 ifdef CONFIG_DEBUG_INFO 44 VDSO_CAFLAGS += -g 45 endif 46 47 # From arm Makefile 48 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2 49 VDSO_CAFLAGS += -mabi=aapcs-linux -mfloat-abi= 50 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) 51 VDSO_CAFLAGS += -mbig-endian 52 else 53 VDSO_CAFLAGS += -mlittle-endian 54 endif 55 56 # From arm vDSO Makefile 57 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack- 58 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING 59 VDSO_CAFLAGS += -march=armv8-a 60 61 VDSO_CFLAGS := $(VDSO_CAFLAGS) 62 VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1 63 # KBUILD_CFLAGS from top-level Makefile 64 VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototyp 65 -fno-strict-aliasing -fno-commo 66 -Werror-implicit-function-decla 67 -Wno-format-security \ 68 -std=gnu11 69 VDSO_CFLAGS += -O2 70 # Some useful compiler-dependent flags from to 71 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer 72 VDSO_CFLAGS += -fno-strict-overflow 73 VDSO_CFLAGS += $(call cc32-option,-Werror=stri 74 VDSO_CFLAGS += -Werror=date-time 75 VDSO_CFLAGS += $(call cc32-option,-Werror=inco 76 77 # The 32-bit compiler does not provide 128-bit 78 # some headers that are indirectly included fr 79 # This hack makes the compiler happy and shoul 80 # variables of such type are referenced. 81 VDSO_CFLAGS += -D__uint128_t='void*' 82 # Silence some warnings coming from headers th 83 # (on GCC 4.8 or older, there is unfortunately 84 VDSO_CFLAGS += $(call cc32-disable-warning,shi 85 VDSO_CFLAGS += -Wno-int-to-pointer-cast 86 87 # Compile as THUMB2 or ARM. Unwinding via fram 88 # unreliable. 89 ifeq ($(CONFIG_THUMB2_COMPAT_VDSO), y) 90 VDSO_CFLAGS += -mthumb -fomit-frame-pointer 91 else 92 VDSO_CFLAGS += -marm 93 endif 94 95 VDSO_AFLAGS := $(VDSO_CAFLAGS) 96 VDSO_AFLAGS += -D__ASSEMBLY__ 97 98 # From arm vDSO Makefile 99 VDSO_LDFLAGS += -Bsymbolic --no-undefined -son 100 VDSO_LDFLAGS += -z max-page-size=4096 -z commo 101 VDSO_LDFLAGS += -shared --build-id=sha1 102 VDSO_LDFLAGS += --orphan-handling=$(CONFIG_LD_ 103 104 105 # Borrow vdsomunge.c from the arm vDSO 106 # We have to use a relative path because scrip 107 # $(hostprogs) with $(obj) 108 munge := ../../../arm/vdso/vdsomunge 109 hostprogs := $(munge) 110 111 c-obj-vdso := note.o 112 c-obj-vdso-gettimeofday := vgettimeofday.o 113 114 ifneq ($(c-gettimeofday-y),) 115 VDSO_CFLAGS_gettimeofday_o += -include $(c-get 116 endif 117 118 VDSO_CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAG 119 120 # Build rules 121 targets := $(c-obj-vdso) $(c-obj-vdso-gettimeo 122 c-obj-vdso := $(addprefix $(obj)/, $(c-obj-vds 123 c-obj-vdso-gettimeofday := $(addprefix $(obj)/ 124 asm-obj-vdso := $(addprefix $(obj)/, $(asm-obj 125 obj-vdso := $(c-obj-vdso) $(c-obj-vdso-gettime 126 127 targets += vdso.lds 128 CPPFLAGS_vdso.lds += -P -C -U$(ARCH) 129 130 # Strip rule for vdso.so 131 $(obj)/vdso.so: OBJCOPYFLAGS := -S 132 $(obj)/vdso.so: $(obj)/vdso32.so.dbg FORCE 133 $(call if_changed,objcopy) 134 135 $(obj)/vdso32.so.dbg: $(obj)/vdso.so.raw $(obj 136 $(call if_changed,vdsomunge) 137 138 # Link rule for the .so file, .lds has to be f 139 $(obj)/vdso.so.raw: $(obj)/vdso.lds $(obj-vdso 140 $(call if_changed,vdsold_and_vdso_chec 141 142 # Compilation rules for the vDSO sources 143 $(c-obj-vdso): %.o: %.c FORCE 144 $(call if_changed_dep,vdsocc) 145 $(c-obj-vdso-gettimeofday): %.o: %.c FORCE 146 $(call if_changed_dep,vdsocc_gettimeof 147 $(asm-obj-vdso): %.o: %.S FORCE 148 $(call if_changed_dep,vdsoas) 149 150 # Actual build commands 151 quiet_cmd_vdsold_and_vdso_check = LD32 $@ 152 cmd_vdsold_and_vdso_check = $(cmd_vdsold 153 154 quiet_cmd_vdsold = LD32 $@ 155 cmd_vdsold = $(LD_COMPAT) $(VDSO_LDFLAGS 156 -T $(filter %.lds,$^) $(fil 157 quiet_cmd_vdsocc = CC32 $@ 158 cmd_vdsocc = $(CC_COMPAT) -Wp,-MD,$(depf 159 quiet_cmd_vdsocc_gettimeofday = CC32 $@ 160 cmd_vdsocc_gettimeofday = $(CC_COMPAT) - 161 quiet_cmd_vdsoas = AS32 $@ 162 cmd_vdsoas = $(CC_COMPAT) -Wp,-MD,$(depf 163 164 quiet_cmd_vdsomunge = MUNGE $@ 165 cmd_vdsomunge = $(obj)/$(munge) $< $@
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.