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