]> git.ipfire.org Git - thirdparty/linux.git/blame - arch/arm64/kernel/vdso32/Makefile
lib/vdso: Enable common headers
[thirdparty/linux.git] / arch / arm64 / kernel / vdso32 / Makefile
CommitLineData
a7f71a2c
VF
1# SPDX-License-Identifier: GPL-2.0
2#
3# Makefile for vdso32
4#
5
6# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
7# the inclusion of generic Makefile.
8ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
9include $(srctree)/lib/vdso/Makefile
10
eff9cb67 11# Same as cc-*option, but using CC_COMPAT instead of CC
bcaf9b57 12ifeq ($(CONFIG_CC_IS_CLANG), y)
eff9cb67 13CC_COMPAT ?= $(CC)
bcaf9b57 14else
eff9cb67 15CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc
bcaf9b57
WD
16endif
17
a7f71a2c 18cc32-option = $(call try-run,\
eff9cb67 19 $(CC_COMPAT) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
a7f71a2c 20cc32-disable-warning = $(call try-run,\
eff9cb67 21 $(CC_COMPAT) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
a7f71a2c 22cc32-ldoption = $(call try-run,\
eff9cb67 23 $(CC_COMPAT) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
0df2c90e 24cc32-as-instr = $(call try-run,\
eff9cb67 25 printf "%b\n" "$(1)" | $(CC_COMPAT) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
a7f71a2c
VF
26
27# We cannot use the global flags to compile the vDSO files, the main reason
28# being that the 32-bit compiler may be older than the main (64-bit) compiler
29# and therefore may not understand flags set using $(cc-option ...). Besides,
30# arch-specific options should be taken from the arm Makefile instead of the
31# arm64 one.
32# As a result we set our own flags here.
33
c71e88c4 34# KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top-level Makefile
eff9cb67 35VDSO_CPPFLAGS := -D__KERNEL__ -nostdinc -isystem $(shell $(CC_COMPAT) -print-file-name=include)
a7f71a2c 36VDSO_CPPFLAGS += $(LINUXINCLUDE)
a7f71a2c
VF
37
38# Common C and assembly flags
39# From top-level Makefile
40VDSO_CAFLAGS := $(VDSO_CPPFLAGS)
eff9cb67 41ifneq ($(shell $(CC_COMPAT) --version 2>&1 | head -n 1 | grep clang),)
7424ee2b
WD
42VDSO_CAFLAGS += --target=$(notdir $(CROSS_COMPILE_COMPAT:%-=%))
43endif
44
a7f71a2c
VF
45VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
46ifdef CONFIG_DEBUG_INFO
47VDSO_CAFLAGS += -g
48endif
a7f71a2c
VF
49
50# From arm Makefile
51VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
52VDSO_CAFLAGS += -mabi=aapcs-linux -mfloat-abi=soft
53ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
54VDSO_CAFLAGS += -mbig-endian
55else
56VDSO_CAFLAGS += -mlittle-endian
57endif
58
59# From arm vDSO Makefile
60VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
61VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
62
0df2c90e 63
a7f71a2c
VF
64# Try to compile for ARMv8. If the compiler is too old and doesn't support it,
65# fall back to v7. There is no easy way to check for what architecture the code
66# is being compiled, so define a macro specifying that (see arch/arm/Makefile).
67VDSO_CAFLAGS += $(call cc32-option,-march=armv8-a -D__LINUX_ARM_ARCH__=8,\
68 -march=armv7-a -D__LINUX_ARM_ARCH__=7)
69
70VDSO_CFLAGS := $(VDSO_CAFLAGS)
71VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1
72# KBUILD_CFLAGS from top-level Makefile
73VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
74 -fno-strict-aliasing -fno-common \
75 -Werror-implicit-function-declaration \
76 -Wno-format-security \
77 -std=gnu89
78VDSO_CFLAGS += -O2
79# Some useful compiler-dependent flags from top-level Makefile
80VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,)
81VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
82VDSO_CFLAGS += $(call cc32-option,-fno-strict-overflow)
83VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes)
84VDSO_CFLAGS += $(call cc32-option,-Werror=date-time)
85VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types)
86
87# The 32-bit compiler does not provide 128-bit integers, which are used in
88# some headers that are indirectly included from the vDSO code.
89# This hack makes the compiler happy and should trigger a warning/error if
90# variables of such type are referenced.
91VDSO_CFLAGS += -D__uint128_t='void*'
92# Silence some warnings coming from headers that operate on long's
93# (on GCC 4.8 or older, there is unfortunately no way to silence this warning)
94VDSO_CFLAGS += $(call cc32-disable-warning,shift-count-overflow)
95VDSO_CFLAGS += -Wno-int-to-pointer-cast
96
97VDSO_AFLAGS := $(VDSO_CAFLAGS)
98VDSO_AFLAGS += -D__ASSEMBLY__
99
0df2c90e
VF
100# Check for binutils support for dmb ishld
101dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
102
103VDSO_CFLAGS += $(dmbinstr)
104VDSO_AFLAGS += $(dmbinstr)
105
a7f71a2c
VF
106VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
107# From arm vDSO Makefile
108VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
109VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
110VDSO_LDFLAGS += -nostdlib -shared -mfloat-abi=soft
89ff7131
MY
111VDSO_LDFLAGS += -Wl,--hash-style=sysv
112VDSO_LDFLAGS += -Wl,--build-id
a7f71a2c
VF
113VDSO_LDFLAGS += $(call cc32-ldoption,-fuse-ld=bfd)
114
115
116# Borrow vdsomunge.c from the arm vDSO
117# We have to use a relative path because scripts/Makefile.host prefixes
5f2fb52f 118# $(hostprogs) with $(obj)
a7f71a2c 119munge := ../../../arm/vdso/vdsomunge
5f2fb52f 120hostprogs := $(munge)
a7f71a2c
VF
121
122c-obj-vdso := note.o
123c-obj-vdso-gettimeofday := vgettimeofday.o
124asm-obj-vdso := sigreturn.o
125
126ifneq ($(c-gettimeofday-y),)
127VDSO_CFLAGS_gettimeofday_o += -include $(c-gettimeofday-y)
128endif
129
130VDSO_CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
131
132# Build rules
133targets := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso) vdso.so vdso.so.dbg vdso.so.raw
134c-obj-vdso := $(addprefix $(obj)/, $(c-obj-vdso))
135c-obj-vdso-gettimeofday := $(addprefix $(obj)/, $(c-obj-vdso-gettimeofday))
136asm-obj-vdso := $(addprefix $(obj)/, $(asm-obj-vdso))
137obj-vdso := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso)
138
139obj-y += vdso.o
140extra-y += vdso.lds
141CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
142
143# Force dependency (vdso.s includes vdso.so through incbin)
144$(obj)/vdso.o: $(obj)/vdso.so
145
146include/generated/vdso32-offsets.h: $(obj)/vdso.so.dbg FORCE
147 $(call if_changed,vdsosym)
148
149# Strip rule for vdso.so
150$(obj)/vdso.so: OBJCOPYFLAGS := -S
151$(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
152 $(call if_changed,objcopy)
153
154$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/$(munge) FORCE
155 $(call if_changed,vdsomunge)
156
157# Link rule for the .so file, .lds has to be first
158$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
2e2f3c9b 159 $(call if_changed,vdsold_and_vdso_check)
a7f71a2c
VF
160
161# Compilation rules for the vDSO sources
162$(c-obj-vdso): %.o: %.c FORCE
163 $(call if_changed_dep,vdsocc)
164$(c-obj-vdso-gettimeofday): %.o: %.c FORCE
165 $(call if_changed_dep,vdsocc_gettimeofday)
166$(asm-obj-vdso): %.o: %.S FORCE
167 $(call if_changed_dep,vdsoas)
168
169# Actual build commands
a88754b2 170quiet_cmd_vdsold_and_vdso_check = LD32 $@
2e2f3c9b
NA
171 cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check)
172
a88754b2 173quiet_cmd_vdsold = LD32 $@
eff9cb67 174 cmd_vdsold = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_LDFLAGS) \
a7f71a2c 175 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
a88754b2 176quiet_cmd_vdsocc = CC32 $@
eff9cb67 177 cmd_vdsocc = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) -c -o $@ $<
a88754b2 178quiet_cmd_vdsocc_gettimeofday = CC32 $@
eff9cb67 179 cmd_vdsocc_gettimeofday = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) $(VDSO_CFLAGS_gettimeofday_o) -c -o $@ $<
a88754b2 180quiet_cmd_vdsoas = AS32 $@
eff9cb67 181 cmd_vdsoas = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_AFLAGS) -c -o $@ $<
a7f71a2c
VF
182
183quiet_cmd_vdsomunge = MUNGE $@
184 cmd_vdsomunge = $(obj)/$(munge) $< $@
185
186# Generate vDSO offsets using helper script (borrowed from the 64-bit vDSO)
187gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh
188quiet_cmd_vdsosym = VDSOSYM $@
189# The AArch64 nm should be able to read an AArch32 binary
190 cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
191
192# Install commands for the unstripped file
193quiet_cmd_vdso_install = INSTALL $@
194 cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
195
196vdso.so: $(obj)/vdso.so.dbg
197 @mkdir -p $(MODLIB)/vdso
198 $(call cmd,vdso_install)
199
200vdso_install: vdso.so