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