• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0
2# Objects to go into the VDSO.
3obj-vdso-y := elf.o gettimeofday.o sigreturn.o
4
5# Common compiler flags between ABIs.
6ccflags-vdso := \
7	$(filter -I%,$(KBUILD_CFLAGS)) \
8	$(filter -E%,$(KBUILD_CFLAGS)) \
9	$(filter -mmicromips,$(KBUILD_CFLAGS)) \
10	$(filter -march=%,$(KBUILD_CFLAGS)) \
11	$(filter -m%-float,$(KBUILD_CFLAGS)) \
12	$(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \
13	-D__VDSO__
14cflags-vdso := $(ccflags-vdso) \
15	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
16	-O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
17	-DDISABLE_BRANCH_PROFILING \
18	$(call cc-option, -fno-asynchronous-unwind-tables) \
19	$(call cc-option, -fno-stack-protector)
20aflags-vdso := $(ccflags-vdso) \
21	-D__ASSEMBLY__ -Wa,-gdwarf-2
22
23#
24# For the pre-R6 code in arch/mips/vdso/vdso.h for locating
25# the base address of VDSO, the linker will emit a R_MIPS_PC32
26# relocation in binutils > 2.25 but it will fail with older versions
27# because that relocation is not supported for that symbol. As a result
28# of which we are forced to disable the VDSO symbols when building
29# with < 2.25 binutils on pre-R6 kernels. For more references on why we
30# can't use other methods to get the base address of VDSO please refer to
31# the comments on that file.
32#
33ifndef CONFIG_CPU_MIPSR6
34  ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
35    $(warning MIPS VDSO requires binutils >= 2.25)
36    obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
37    ccflags-vdso += -DDISABLE_MIPS_VDSO
38  endif
39endif
40
41# VDSO linker flags.
42VDSO_LDFLAGS := \
43	-Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
44	-nostdlib -shared \
45	$(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
46	$(call cc-ldoption, -Wl$(comma)--build-id)
47
48GCOV_PROFILE := n
49
50#
51# Shared build commands.
52#
53
54quiet_cmd_vdsold = VDSO    $@
55      cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
56                   -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
57
58quiet_cmd_vdsoas_o_S = AS       $@
59      cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
60
61# Strip rule for the raw .so files
62$(obj)/%.so.raw: OBJCOPYFLAGS := -S
63$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
64	$(call if_changed,objcopy)
65
66hostprogs-y := genvdso
67
68quiet_cmd_genvdso = GENVDSO $@
69define cmd_genvdso
70	$(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
71	$(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
72endef
73
74#
75# Build native VDSO.
76#
77
78native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
79
80targets += $(obj-vdso-y)
81targets += vdso.lds
82targets += vdso.so.dbg.raw vdso.so.raw
83targets += vdso.so.dbg vdso.so
84targets += vdso-image.c
85
86obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
87
88$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
89$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
90
91$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
92
93$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
94	$(call if_changed,vdsold)
95
96$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
97                     $(obj)/genvdso FORCE
98	$(call if_changed,genvdso)
99
100obj-y += vdso-image.o
101
102#
103# Build O32 VDSO.
104#
105
106# Define these outside the ifdef to ensure they are picked up by clean.
107targets += $(obj-vdso-y:%.o=%-o32.o)
108targets += vdso-o32.lds
109targets += vdso-o32.so.dbg.raw vdso-o32.so.raw
110targets += vdso-o32.so.dbg vdso-o32.so
111targets += vdso-o32-image.c
112
113ifdef CONFIG_MIPS32_O32
114
115obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
116
117$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
118$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
119
120$(obj)/%-o32.o: $(src)/%.S FORCE
121	$(call if_changed_dep,vdsoas_o_S)
122
123$(obj)/%-o32.o: $(src)/%.c FORCE
124	$(call cmd,force_checksrc)
125	$(call if_changed_rule,cc_o_c)
126
127$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
128$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
129	$(call if_changed_dep,cpp_lds_S)
130
131$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
132	$(call if_changed,vdsold)
133
134$(obj)/vdso-o32-image.c: VDSO_NAME := o32
135$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
136                         $(obj)/genvdso FORCE
137	$(call if_changed,genvdso)
138
139obj-y += vdso-o32-image.o
140
141endif
142
143#
144# Build N32 VDSO.
145#
146
147targets += $(obj-vdso-y:%.o=%-n32.o)
148targets += vdso-n32.lds
149targets += vdso-n32.so.dbg.raw vdso-n32.so.raw
150targets += vdso-n32.so.dbg vdso-n32.so
151targets += vdso-n32-image.c
152
153ifdef CONFIG_MIPS32_N32
154
155obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
156
157$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
158$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
159
160$(obj)/%-n32.o: $(src)/%.S FORCE
161	$(call if_changed_dep,vdsoas_o_S)
162
163$(obj)/%-n32.o: $(src)/%.c FORCE
164	$(call cmd,force_checksrc)
165	$(call if_changed_rule,cc_o_c)
166
167$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32
168$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
169	$(call if_changed_dep,cpp_lds_S)
170
171$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
172	$(call if_changed,vdsold)
173
174$(obj)/vdso-n32-image.c: VDSO_NAME := n32
175$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
176                         $(obj)/genvdso FORCE
177	$(call if_changed,genvdso)
178
179obj-y += vdso-n32-image.o
180
181endif
182
183# FIXME: Need install rule for debug.
184# Needs to deal with dependency for generation of dbg by cmd_genvdso...
185