blob: c3dc12a8b7d9ddc79f8acf126cdd83bbb91dfee2 [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)) \
James Hoganbb930782016-05-24 09:35:11 +01008 $(filter -mmicromips,$(KBUILD_CFLAGS)) \
Alex Smithebb5e782015-10-21 09:54:38 +01009 $(filter -march=%,$(KBUILD_CFLAGS))
10cflags-vdso := $(ccflags-vdso) \
11 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \
Maciej W. Rozycki94cc36b2016-05-26 12:55:45 +010012 -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
13 -DDISABLE_BRANCH_PROFILING \
Alex Smithebb5e782015-10-21 09:54:38 +010014 $(call cc-option, -fno-stack-protector)
15aflags-vdso := $(ccflags-vdso) \
Alex Smithebb5e782015-10-21 09:54:38 +010016 -D__ASSEMBLY__ -Wa,-gdwarf-2
17
18#
19# For the pre-R6 code in arch/mips/vdso/vdso.h for locating
20# the base address of VDSO, the linker will emit a R_MIPS_PC32
21# relocation in binutils > 2.25 but it will fail with older versions
22# because that relocation is not supported for that symbol. As a result
23# of which we are forced to disable the VDSO symbols when building
24# with < 2.25 binutils on pre-R6 kernels. For more references on why we
25# can't use other methods to get the base address of VDSO please refer to
26# the comments on that file.
27#
28ifndef CONFIG_CPU_MIPSR6
James Hogand5ece1c2015-12-26 22:47:52 +000029 ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
Qais Yousef2a037f32015-12-08 10:11:43 +000030 $(warning MIPS VDSO requires binutils >= 2.25)
Alex Smithebb5e782015-10-21 09:54:38 +010031 obj-vdso-y := $(filter-out gettimeofday.o, $(obj-vdso-y))
32 ccflags-vdso += -DDISABLE_MIPS_VDSO
33 endif
34endif
35
36# VDSO linker flags.
37VDSO_LDFLAGS := \
38 -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
39 -nostdlib -shared \
40 $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
41 $(call cc-ldoption, -Wl$(comma)--build-id)
42
43GCOV_PROFILE := n
44
45#
46# Shared build commands.
47#
48
49quiet_cmd_vdsold = VDSO $@
50 cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
51 -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
52
James Hogan2afb9742016-05-13 19:41:06 +010053# Strip rule for the raw .so files
54$(obj)/%.so.raw: OBJCOPYFLAGS := -S
55$(obj)/%.so.raw: $(obj)/%.so.dbg.raw FORCE
56 $(call if_changed,objcopy)
57
Alex Smithebb5e782015-10-21 09:54:38 +010058hostprogs-y := genvdso
59
60quiet_cmd_genvdso = GENVDSO $@
61define cmd_genvdso
James Hogan2afb9742016-05-13 19:41:06 +010062 $(foreach file,$(filter %.raw,$^),cp $(file) $(file:%.raw=%) &&) \
63 $(obj)/genvdso $(<:%.raw=%) $(<:%.dbg.raw=%) $@ $(VDSO_NAME)
Alex Smithebb5e782015-10-21 09:54:38 +010064endef
65
66#
67# Build native VDSO.
68#
69
70native-abi := $(filter -mabi=%,$(KBUILD_CFLAGS))
71
72targets += $(obj-vdso-y)
James Hogan2afb9742016-05-13 19:41:06 +010073targets += vdso.lds
74targets += vdso.so.dbg.raw vdso.so.raw
75targets += vdso.so.dbg vdso.so
76targets += vdso-image.c
Alex Smithebb5e782015-10-21 09:54:38 +010077
78obj-vdso := $(obj-vdso-y:%.o=$(obj)/%.o)
79
80$(obj-vdso): KBUILD_CFLAGS := $(cflags-vdso) $(native-abi)
81$(obj-vdso): KBUILD_AFLAGS := $(aflags-vdso) $(native-abi)
82
James Hogan034827c2016-10-06 23:10:41 +010083$(obj)/vdso.lds: KBUILD_CPPFLAGS := $(ccflags-vdso) $(native-abi)
Alex Smithebb5e782015-10-21 09:54:38 +010084
James Hogan2afb9742016-05-13 19:41:06 +010085$(obj)/vdso.so.dbg.raw: $(obj)/vdso.lds $(obj-vdso) FORCE
Alex Smithebb5e782015-10-21 09:54:38 +010086 $(call if_changed,vdsold)
87
James Hogan2afb9742016-05-13 19:41:06 +010088$(obj)/vdso-image.c: $(obj)/vdso.so.dbg.raw $(obj)/vdso.so.raw \
89 $(obj)/genvdso FORCE
Alex Smithebb5e782015-10-21 09:54:38 +010090 $(call if_changed,genvdso)
91
92obj-y += vdso-image.o
93
94#
95# Build O32 VDSO.
96#
97
98# Define these outside the ifdef to ensure they are picked up by clean.
99targets += $(obj-vdso-y:%.o=%-o32.o)
James Hogan2afb9742016-05-13 19:41:06 +0100100targets += vdso-o32.lds
101targets += vdso-o32.so.dbg.raw vdso-o32.so.raw
102targets += vdso-o32.so.dbg vdso-o32.so
103targets += vdso-o32-image.c
Alex Smithebb5e782015-10-21 09:54:38 +0100104
105ifdef CONFIG_MIPS32_O32
106
107obj-vdso-o32 := $(obj-vdso-y:%.o=$(obj)/%-o32.o)
108
109$(obj-vdso-o32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=32
110$(obj-vdso-o32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=32
111
112$(obj)/%-o32.o: $(src)/%.S FORCE
113 $(call if_changed_dep,as_o_S)
114
115$(obj)/%-o32.o: $(src)/%.c FORCE
116 $(call cmd,force_checksrc)
117 $(call if_changed_rule,cc_o_c)
118
119$(obj)/vdso-o32.lds: KBUILD_CPPFLAGS := -mabi=32
120$(obj)/vdso-o32.lds: $(src)/vdso.lds.S FORCE
121 $(call if_changed_dep,cpp_lds_S)
122
James Hogan2afb9742016-05-13 19:41:06 +0100123$(obj)/vdso-o32.so.dbg.raw: $(obj)/vdso-o32.lds $(obj-vdso-o32) FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100124 $(call if_changed,vdsold)
125
126$(obj)/vdso-o32-image.c: VDSO_NAME := o32
James Hogan2afb9742016-05-13 19:41:06 +0100127$(obj)/vdso-o32-image.c: $(obj)/vdso-o32.so.dbg.raw $(obj)/vdso-o32.so.raw \
128 $(obj)/genvdso FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100129 $(call if_changed,genvdso)
130
131obj-y += vdso-o32-image.o
132
133endif
134
135#
136# Build N32 VDSO.
137#
138
139targets += $(obj-vdso-y:%.o=%-n32.o)
James Hogan2afb9742016-05-13 19:41:06 +0100140targets += vdso-n32.lds
141targets += vdso-n32.so.dbg.raw vdso-n32.so.raw
142targets += vdso-n32.so.dbg vdso-n32.so
143targets += vdso-n32-image.c
Alex Smithebb5e782015-10-21 09:54:38 +0100144
145ifdef CONFIG_MIPS32_N32
146
147obj-vdso-n32 := $(obj-vdso-y:%.o=$(obj)/%-n32.o)
148
149$(obj-vdso-n32): KBUILD_CFLAGS := $(cflags-vdso) -mabi=n32
150$(obj-vdso-n32): KBUILD_AFLAGS := $(aflags-vdso) -mabi=n32
151
152$(obj)/%-n32.o: $(src)/%.S FORCE
153 $(call if_changed_dep,as_o_S)
154
155$(obj)/%-n32.o: $(src)/%.c FORCE
156 $(call cmd,force_checksrc)
157 $(call if_changed_rule,cc_o_c)
158
159$(obj)/vdso-n32.lds: KBUILD_CPPFLAGS := -mabi=n32
160$(obj)/vdso-n32.lds: $(src)/vdso.lds.S FORCE
161 $(call if_changed_dep,cpp_lds_S)
162
James Hogan2afb9742016-05-13 19:41:06 +0100163$(obj)/vdso-n32.so.dbg.raw: $(obj)/vdso-n32.lds $(obj-vdso-n32) FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100164 $(call if_changed,vdsold)
165
166$(obj)/vdso-n32-image.c: VDSO_NAME := n32
James Hogan2afb9742016-05-13 19:41:06 +0100167$(obj)/vdso-n32-image.c: $(obj)/vdso-n32.so.dbg.raw $(obj)/vdso-n32.so.raw \
168 $(obj)/genvdso FORCE
Alex Smithebb5e782015-10-21 09:54:38 +0100169 $(call if_changed,genvdso)
170
171obj-y += vdso-n32-image.o
172
173endif
174
175# FIXME: Need install rule for debug.
176# Needs to deal with dependency for generation of dbg by cmd_genvdso...