blob: fff01eddf3e915f384d43c417aad04a76797dad7 [file] [log] [blame]
Alex Smithebb5e782015-10-21 09:54:38 +01001# Objects to go into the VDSO.
2obj-vdso-y := elf.o gettimeofday.o sigreturn.o
3
4# Common compiler flags between ABIs.
5ccflags-vdso := \
6 $(filter -I%,$(KBUILD_CFLAGS)) \
7 $(filter -E%,$(KBUILD_CFLAGS)) \
8 $(filter -march=%,$(KBUILD_CFLAGS))
9cflags-vdso := $(ccflags-vdso) \
10 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
Maciej W. Rozycki94cc36b2016-05-26 12:55:45 +010011 -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
12 -DDISABLE_BRANCH_PROFILING \
Alex Smithebb5e782015-10-21 09:54:38 +010013 $(call cc-option, -fno-stack-protector)
14aflags-vdso := $(ccflags-vdso) \
15 $(filter -I%,$(KBUILD_CFLAGS)) \
16 $(filter -E%,$(KBUILD_CFLAGS)) \
17 -D__ASSEMBLY__ -Wa,-gdwarf-2
18
19#
20# For the pre-R6 code in arch/mips/vdso/vdso.h for locating
21# the base address of VDSO, the linker will emit a R_MIPS_PC32
22# relocation in binutils > 2.25 but it will fail with older versions
23# because that relocation is not supported for that symbol. As a result
24# of which we are forced to disable the VDSO symbols when building
25# with < 2.25 binutils on pre-R6 kernels. For more references on why we
26# can't use other methods to get the base address of VDSO please refer to
27# the comments on that file.
28#
29ifndef CONFIG_CPU_MIPSR6
James Hogand5ece1c2015-12-26 22:47:52 +000030 ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
Qais Yousef2a037f32015-12-08 10:11:43 +000031 $(warning MIPS VDSO requires binutils >= 2.25)
Alex Smithebb5e782015-10-21 09:54:38 +010032 obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
33 ccflags-vdso += -DDISABLE_MIPS_VDSO
34 endif
35endif
36
37# VDSO linker flags.
38VDSO_LDFLAGS := \
39 -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
40 -nostdlib -shared \
41 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
42 $(call cc-ldoption, -Wl$(comma)--build-id)
43
44GCOV_PROFILE := n
45
46#
47# Shared build commands.
48#
49
50quiet_cmd_vdsold = VDSO $@
51 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
52 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
53
James Hogan2afb9742016-05-13 19:41:06 +010054# Strip rule for the raw .so files
55$(obj)/%.so.raw: OBJCOPYFLAGS := -S
56$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
57 $(call if_changed,objcopy)
58
Alex Smithebb5e782015-10-21 09:54:38 +010059hostprogs-y := genvdso
60
61quiet_cmd_genvdso = GENVDSO $@
62define cmd_genvdso
James Hogan2afb9742016-05-13 19:41:06 +010063 $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
64 $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
Alex Smithebb5e782015-10-21 09:54:38 +010065endef
66
67#
68# Build native VDSO.
69#
70
71native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
72
73targets += $(obj-vdso-y)
James Hogan2afb9742016-05-13 19:41:06 +010074targets += vdso.lds
75targets += vdso.so.dbg.raw vdso.so.raw
76targets += vdso.so.dbg vdso.so
77targets += vdso-image.c
Alex Smithebb5e782015-10-21 09:54:38 +010078
79obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
80
81$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
82$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
83
84$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(native-abi)
85
James Hogan2afb9742016-05-13 19:41:06 +010086$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
Alex Smithebb5e782015-10-21 09:54:38 +010087 $(call if_changed,vdsold)
88
James Hogan2afb9742016-05-13 19:41:06 +010089$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
90 $(obj)/genvdso FORCE
Alex Smithebb5e782015-10-21 09:54:38 +010091 $(call if_changed,genvdso)
92
93obj-y += vdso-image.o
94
95#
96# Build O32 VDSO.
97#
98
99# Define these outside the ifdef to ensure they are picked up by clean.
100targets += $(obj-vdso-y:%.o=%-o32.o)
James Hogan2afb9742016-05-13 19:41:06 +0100101targets += vdso-o32.lds
102targets += vdso-o32.so.dbg.raw vdso-o32.so.raw
103targets += vdso-o32.so.dbg vdso-o32.so
104targets += vdso-o32-image.c
Alex Smithebb5e782015-10-21 09:54:38 +0100105
106ifdef CONFIG_MIPS32_O32
107
108obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
109
110$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
111$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
112
113$(obj)/%-o32.o: $(src)/%.S FORCE
114 $(call if_changed_dep,as_o_S)
115
116$(obj)/%-o32.o: $(src)/%.c FORCE
117 $(call cmd,force_checksrc)
118 $(call if_changed_rule,cc_o_c)
119
120$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := -mabi=32
121$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
122 $(call if_changed_dep,cpp_lds_S)
123
James Hogan2afb9742016-05-13 19:41:06 +0100124$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100125 $(call if_changed,vdsold)
126
127$(obj)/vdso-o32-image.c: VDSO_NAME := o32
James Hogan2afb9742016-05-13 19:41:06 +0100128$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
129 $(obj)/genvdso FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100130 $(call if_changed,genvdso)
131
132obj-y += vdso-o32-image.o
133
134endif
135
136#
137# Build N32 VDSO.
138#
139
140targets += $(obj-vdso-y:%.o=%-n32.o)
James Hogan2afb9742016-05-13 19:41:06 +0100141targets += vdso-n32.lds
142targets += vdso-n32.so.dbg.raw vdso-n32.so.raw
143targets += vdso-n32.so.dbg vdso-n32.so
144targets += vdso-n32-image.c
Alex Smithebb5e782015-10-21 09:54:38 +0100145
146ifdef CONFIG_MIPS32_N32
147
148obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
149
150$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
151$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
152
153$(obj)/%-n32.o: $(src)/%.S FORCE
154 $(call if_changed_dep,as_o_S)
155
156$(obj)/%-n32.o: $(src)/%.c FORCE
157 $(call cmd,force_checksrc)
158 $(call if_changed_rule,cc_o_c)
159
160$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := -mabi=n32
161$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
162 $(call if_changed_dep,cpp_lds_S)
163
James Hogan2afb9742016-05-13 19:41:06 +0100164$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100165 $(call if_changed,vdsold)
166
167$(obj)/vdso-n32-image.c: VDSO_NAME := n32
James Hogan2afb9742016-05-13 19:41:06 +0100168$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
169 $(obj)/genvdso FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100170 $(call if_changed,genvdso)
171
172obj-y += vdso-n32-image.o
173
174endif
175
176# FIXME: Need install rule for debug.
177# Needs to deal with dependency for generation of dbg by cmd_genvdso...