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