xref: /openbmc/linux/arch/mips/vdso/Makefile (revision 1e022137)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2ebb5e78cSAlex Smith# Objects to go into the VDSO.
3ebb5e78cSAlex Smithobj-vdso-y := elf.o gettimeofday.o sigreturn.o
4ebb5e78cSAlex Smith
5ebb5e78cSAlex Smith# Common compiler flags between ABIs.
6ebb5e78cSAlex Smithccflags-vdso := \
7ebb5e78cSAlex Smith	$(filter -I%,$(KBUILD_CFLAGS)) \
8ebb5e78cSAlex Smith	$(filter -E%,$(KBUILD_CFLAGS)) \
9bb93078eSJames Hogan	$(filter -mmicromips,$(KBUILD_CFLAGS)) \
10351fddddSPaul Burton	$(filter -march=%,$(KBUILD_CFLAGS)) \
110648e50eSPaul Burton	$(filter -m%-float,$(KBUILD_CFLAGS)) \
12351fddddSPaul Burton	-D__VDSO__
13ee67855eSPaul Burton
14076f421dSMasahiro Yamadaifdef CONFIG_CC_IS_CLANG
15ee67855eSPaul Burtonccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS))
16ee67855eSPaul Burtonendif
17ee67855eSPaul Burton
18ebb5e78cSAlex Smithcflags-vdso := $(ccflags-vdso) \
19ebb5e78cSAlex Smith	$(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
2094cc36b8SMaciej W. Rozycki	-O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
2194cc36b8SMaciej W. Rozycki	-DDISABLE_BRANCH_PROFILING \
22cfd75c2dSRobert Schiele	$(call cc-option, -fno-asynchronous-unwind-tables) \
23ebb5e78cSAlex Smith	$(call cc-option, -fno-stack-protector)
24ebb5e78cSAlex Smithaflags-vdso := $(ccflags-vdso) \
25ebb5e78cSAlex Smith	-D__ASSEMBLY__ -Wa,-gdwarf-2
26ebb5e78cSAlex Smith
27ebb5e78cSAlex Smith#
28ebb5e78cSAlex Smith# For the pre-R6 code in arch/mips/vdso/vdso.h for locating
29ebb5e78cSAlex Smith# the base address of VDSO, the linker will emit a R_MIPS_PC32
30ebb5e78cSAlex Smith# relocation in binutils > 2.25 but it will fail with older versions
31ebb5e78cSAlex Smith# because that relocation is not supported for that symbol. As a result
32ebb5e78cSAlex Smith# of which we are forced to disable the VDSO symbols when building
33ebb5e78cSAlex Smith# with < 2.25 binutils on pre-R6 kernels. For more references on why we
34ebb5e78cSAlex Smith# can't use other methods to get the base address of VDSO please refer to
35ebb5e78cSAlex Smith# the comments on that file.
36ebb5e78cSAlex Smith#
37ebb5e78cSAlex Smithifndef CONFIG_CPU_MIPSR6
38d5ece1cbSJames Hogan  ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
392a037f31SQais Yousef    $(warning MIPS VDSO requires binutils >= 2.25)
40ebb5e78cSAlex Smith    obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
41ebb5e78cSAlex Smith    ccflags-vdso += -DDISABLE_MIPS_VDSO
42ebb5e78cSAlex Smith  endif
43ebb5e78cSAlex Smithendif
44ebb5e78cSAlex Smith
45ebb5e78cSAlex Smith# VDSO linker flags.
46ebb5e78cSAlex SmithVDSO_LDFLAGS := \
47ebb5e78cSAlex Smith	-Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
482f002567SPaul Burton	$(addprefix -Wl$(comma),$(filter -E%,$(KBUILD_CFLAGS))) \
491e022137SNick Desaulniers	-nostdlib -shared -Wl,--hash-style=sysv -Wl,--build-id
50ebb5e78cSAlex Smith
51ebb5e78cSAlex SmithGCOV_PROFILE := n
521e35918aSHassan NaveedUBSAN_SANITIZE := n
53ebb5e78cSAlex Smith
54ebb5e78cSAlex Smith#
55ebb5e78cSAlex Smith# Shared build commands.
56ebb5e78cSAlex Smith#
57ebb5e78cSAlex Smith
58ebb5e78cSAlex Smithquiet_cmd_vdsold = VDSO    $@
59ebb5e78cSAlex Smith      cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
60ebb5e78cSAlex Smith                   -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
61ebb5e78cSAlex Smith
62b668970eSArnd Bergmannquiet_cmd_vdsoas_o_S = AS       $@
63b668970eSArnd Bergmann      cmd_vdsoas_o_S = $(CC) $(a_flags) -c -o $@ $<
64b668970eSArnd Bergmann
652afb9745SJames Hogan# Strip rule for the raw .so files
662afb9745SJames Hogan$(obj)/%.so.raw: OBJCOPYFLAGS := -S
672afb9745SJames Hogan$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
682afb9745SJames Hogan	$(call if_changed,objcopy)
692afb9745SJames Hogan
70ebb5e78cSAlex Smithhostprogs-y := genvdso
71ebb5e78cSAlex Smith
72ebb5e78cSAlex Smithquiet_cmd_genvdso = GENVDSO $@
73ebb5e78cSAlex Smithdefine cmd_genvdso
742afb9745SJames Hogan	$(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
752afb9745SJames Hogan	$(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
76ebb5e78cSAlex Smithendef
77ebb5e78cSAlex Smith
78ebb5e78cSAlex Smith#
79ebb5e78cSAlex Smith# Build native VDSO.
80ebb5e78cSAlex Smith#
81ebb5e78cSAlex Smith
82ebb5e78cSAlex Smithnative-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
83ebb5e78cSAlex Smith
84ebb5e78cSAlex Smithtargets += $(obj-vdso-y)
852afb9745SJames Hogantargets += vdso.lds
862afb9745SJames Hogantargets += vdso.so.dbg.raw vdso.so.raw
872afb9745SJames Hogantargets += vdso.so.dbg vdso.so
882afb9745SJames Hogantargets += vdso-image.c
89ebb5e78cSAlex Smith
90ebb5e78cSAlex Smithobj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
91ebb5e78cSAlex Smith
92ebb5e78cSAlex Smith$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
93ebb5e78cSAlex Smith$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
94ebb5e78cSAlex Smith
95034827c7SJames Hogan$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
96ebb5e78cSAlex Smith
972afb9745SJames Hogan$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
98ebb5e78cSAlex Smith	$(call if_changed,vdsold)
99ebb5e78cSAlex Smith
1002afb9745SJames Hogan$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
1012afb9745SJames Hogan                     $(obj)/genvdso FORCE
102ebb5e78cSAlex Smith	$(call if_changed,genvdso)
103ebb5e78cSAlex Smith
104ebb5e78cSAlex Smithobj-y += vdso-image.o
105ebb5e78cSAlex Smith
106ebb5e78cSAlex Smith#
107ebb5e78cSAlex Smith# Build O32 VDSO.
108ebb5e78cSAlex Smith#
109ebb5e78cSAlex Smith
110ebb5e78cSAlex Smith# Define these outside the ifdef to ensure they are picked up by clean.
111ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-o32.o)
1122afb9745SJames Hogantargets += vdso-o32.lds
1132afb9745SJames Hogantargets += vdso-o32.so.dbg.raw vdso-o32.so.raw
1142afb9745SJames Hogantargets += vdso-o32.so.dbg vdso-o32.so
1152afb9745SJames Hogantargets += vdso-o32-image.c
116ebb5e78cSAlex Smith
117ebb5e78cSAlex Smithifdef CONFIG_MIPS32_O32
118ebb5e78cSAlex Smith
119ebb5e78cSAlex Smithobj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
120ebb5e78cSAlex Smith
121ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
122ebb5e78cSAlex Smith$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
123ebb5e78cSAlex Smith
124ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.S FORCE
125b668970eSArnd Bergmann	$(call if_changed_dep,vdsoas_o_S)
126ebb5e78cSAlex Smith
127ebb5e78cSAlex Smith$(obj)/%-o32.o: $(src)/%.c FORCE
128ebb5e78cSAlex Smith	$(call cmd,force_checksrc)
129ebb5e78cSAlex Smith	$(call if_changed_rule,cc_o_c)
130ebb5e78cSAlex Smith
13167fc5dc8SPaul Burton$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=32
132ebb5e78cSAlex Smith$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
133ebb5e78cSAlex Smith	$(call if_changed_dep,cpp_lds_S)
134ebb5e78cSAlex Smith
1352afb9745SJames Hogan$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
136ebb5e78cSAlex Smith	$(call if_changed,vdsold)
137ebb5e78cSAlex Smith
138ebb5e78cSAlex Smith$(obj)/vdso-o32-image.c: VDSO_NAME := o32
1392afb9745SJames Hogan$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
1402afb9745SJames Hogan                         $(obj)/genvdso FORCE
141ebb5e78cSAlex Smith	$(call if_changed,genvdso)
142ebb5e78cSAlex Smith
143ebb5e78cSAlex Smithobj-y += vdso-o32-image.o
144ebb5e78cSAlex Smith
145ebb5e78cSAlex Smithendif
146ebb5e78cSAlex Smith
147ebb5e78cSAlex Smith#
148ebb5e78cSAlex Smith# Build N32 VDSO.
149ebb5e78cSAlex Smith#
150ebb5e78cSAlex Smith
151ebb5e78cSAlex Smithtargets += $(obj-vdso-y:%.o=%-n32.o)
1522afb9745SJames Hogantargets += vdso-n32.lds
1532afb9745SJames Hogantargets += vdso-n32.so.dbg.raw vdso-n32.so.raw
1542afb9745SJames Hogantargets += vdso-n32.so.dbg vdso-n32.so
1552afb9745SJames Hogantargets += vdso-n32-image.c
156ebb5e78cSAlex Smith
157ebb5e78cSAlex Smithifdef CONFIG_MIPS32_N32
158ebb5e78cSAlex Smith
159ebb5e78cSAlex Smithobj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
160ebb5e78cSAlex Smith
161ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
162ebb5e78cSAlex Smith$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
163ebb5e78cSAlex Smith
164ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.S FORCE
165b668970eSArnd Bergmann	$(call if_changed_dep,vdsoas_o_S)
166ebb5e78cSAlex Smith
167ebb5e78cSAlex Smith$(obj)/%-n32.o: $(src)/%.c FORCE
168ebb5e78cSAlex Smith	$(call cmd,force_checksrc)
169ebb5e78cSAlex Smith	$(call if_changed_rule,cc_o_c)
170ebb5e78cSAlex Smith
17167fc5dc8SPaul Burton$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) -mabi=n32
172ebb5e78cSAlex Smith$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
173ebb5e78cSAlex Smith	$(call if_changed_dep,cpp_lds_S)
174ebb5e78cSAlex Smith
1752afb9745SJames Hogan$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
176ebb5e78cSAlex Smith	$(call if_changed,vdsold)
177ebb5e78cSAlex Smith
178ebb5e78cSAlex Smith$(obj)/vdso-n32-image.c: VDSO_NAME := n32
1792afb9745SJames Hogan$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
1802afb9745SJames Hogan                         $(obj)/genvdso FORCE
181ebb5e78cSAlex Smith	$(call if_changed,genvdso)
182ebb5e78cSAlex Smith
183ebb5e78cSAlex Smithobj-y += vdso-n32-image.o
184ebb5e78cSAlex Smith
185ebb5e78cSAlex Smithendif
186ebb5e78cSAlex Smith
187ebb5e78cSAlex Smith# FIXME: Need install rule for debug.
188ebb5e78cSAlex Smith# Needs to deal with dependency for generation of dbg by cmd_genvdso...
189