Debian Codegraph @

arch/arm64/kernel/vdso32/Makefile

raw
1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # Makefile for vdso32
4 #
5
6 include $(srctree)/lib/vdso/Makefile.include
7
8 # Same as cc-*option, but using CC_COMPAT instead of CC
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 "$$TMP",$(1),$(2))
24
25 # We cannot use the global flags to compile the vDSO files, the main reason
26 # being that the 32-bit compiler may be older than the main (64-bit) compiler
27 # and therefore may not understand flags set using $(cc-option ...). Besides,
28 # arch-specific options should be taken from the arm Makefile instead of the
29 # arm64 one.
30 # As a result we set our own flags here.
31
32 # KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top-level Makefile
33 VDSO_CPPFLAGS := -DBUILD_VDSO -D__KERNEL__ -nostdinc
34 VDSO_CPPFLAGS += -isystem $(shell $(CC_COMPAT) -print-file-name=include 2>/dev/null)
35 VDSO_CPPFLAGS += $(LINUXINCLUDE)
36
37 # Common C and assembly flags
38 # From top-level Makefile
39 VDSO_CAFLAGS := $(VDSO_CPPFLAGS)
40 VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
41 ifdef CONFIG_DEBUG_INFO
42 VDSO_CAFLAGS += -g
43 endif
44
45 # From arm Makefile
46 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
47 VDSO_CAFLAGS += -mabi=aapcs-linux -mfloat-abi=soft
48 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
49 VDSO_CAFLAGS += -mbig-endian
50 else
51 VDSO_CAFLAGS += -mlittle-endian
52 endif
53
54 # From arm vDSO Makefile
55 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
56 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
57 VDSO_CAFLAGS += -march=armv8-a
58
59 VDSO_CFLAGS := $(VDSO_CAFLAGS)
60 # KBUILD_CFLAGS from top-level Makefile
61 VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
62 -fno-strict-aliasing -fno-common \
63 $(filter -Werror,$(KBUILD_CPPFLAGS)) \
64 -Werror-implicit-function-declaration \
65 -Wno-format-security \
66 -std=gnu11 -fms-extensions
67 VDSO_CFLAGS += -O2
68 # Some useful compiler-dependent flags from top-level Makefile
69 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
70 VDSO_CFLAGS += -fno-strict-overflow
71 VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes)
72 VDSO_CFLAGS += -Werror=date-time
73 VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types)
74 VDSO_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag)
75
76 # Compile as THUMB2 or ARM. Unwinding via frame-pointers in THUMB2 is
77 # unreliable.
78 ifeq ($(CONFIG_THUMB2_COMPAT_VDSO), y)
79 VDSO_CFLAGS += -mthumb -fomit-frame-pointer
80 else
81 VDSO_CFLAGS += -marm
82 endif
83
84 VDSO_AFLAGS := $(VDSO_CAFLAGS)
85 VDSO_AFLAGS += -D__ASSEMBLY__
86
87 # From arm vDSO Makefile
88 VDSO_LDFLAGS += -Bsymbolic --no-undefined -soname=linux-vdso.so.1
89 VDSO_LDFLAGS += -z max-page-size=4096 -z common-page-size=4096
90 VDSO_LDFLAGS += -shared --build-id=sha1
91 VDSO_LDFLAGS += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
92
93
94 # Borrow vdsomunge.c from the arm vDSO
95 # We have to use a relative path because scripts/Makefile.host prefixes
96 # $(hostprogs) with $(obj)
97 munge := ../../../arm/vdso/vdsomunge
98 hostprogs := $(munge)
99
100 c-obj-vdso := note.o
101 c-obj-vdso-gettimeofday := vgettimeofday.o
102
103 ifneq ($(c-gettimeofday-y),)
104 VDSO_CFLAGS_gettimeofday_o += -include $(c-gettimeofday-y)
105 endif
106
107 VDSO_CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
108
109 # Build rules
110 targets := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso) vdso.so vdso32.so.dbg vdso.so.raw
111 c-obj-vdso := $(addprefix $(obj)/, $(c-obj-vdso))
112 c-obj-vdso-gettimeofday := $(addprefix $(obj)/, $(c-obj-vdso-gettimeofday))
113 asm-obj-vdso := $(addprefix $(obj)/, $(asm-obj-vdso))
114 obj-vdso := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso)
115
116 targets += vdso.lds
117 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
118
119 # Strip rule for vdso.so
120 $(obj)/vdso.so: OBJCOPYFLAGS := -S
121 $(obj)/vdso.so: $(obj)/vdso32.so.dbg FORCE
122 $(call if_changed,objcopy)
123
124 $(obj)/vdso32.so.dbg: $(obj)/vdso.so.raw $(obj)/$(munge) FORCE
125 $(call if_changed,vdsomunge)
126
127 # Link rule for the .so file, .lds has to be first
128 $(obj)/vdso.so.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
129 $(call if_changed,vdsold_and_vdso_check)
130
131 # Compilation rules for the vDSO sources
132 $(c-obj-vdso): %.o: %.c FORCE
133 $(call if_changed_dep,vdsocc)
134 $(c-obj-vdso-gettimeofday): %.o: %.c FORCE
135 $(call if_changed_dep,vdsocc_gettimeofday)
136 $(asm-obj-vdso): %.o: %.S FORCE
137 $(call if_changed_dep,vdsoas)
138
139 # Actual build commands
140 quiet_cmd_vdsold_and_vdso_check = LD32 $@
141 cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check)
142
143 quiet_cmd_vdsold = LD32 $@
144 cmd_vdsold = $(LD_COMPAT) $(VDSO_LDFLAGS) \
145 -T $(filter %.lds,$^) $(filter %.o,$^) -o $@
146 quiet_cmd_vdsocc = CC32 $@
147 cmd_vdsocc = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) -c -o $@ $<
148 quiet_cmd_vdsocc_gettimeofday = CC32 $@
149 cmd_vdsocc_gettimeofday = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) $(VDSO_CFLAGS_gettimeofday_o) -c -o $@ $<
150 quiet_cmd_vdsoas = AS32 $@
151 cmd_vdsoas = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_AFLAGS) -c -o $@ $<
152
153 quiet_cmd_vdsomunge = MUNGE $@
154 cmd_vdsomunge = $(obj)/$(munge) $< $@