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