dt-bindings: soc: bcm: use absolute path to other schema
[linux-2.6-microblaze.git] / arch / arm64 / kernel / vdso32 / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # Makefile for vdso32
4 #
5
6 # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
7 # the inclusion of generic Makefile.
8 ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
9 include $(srctree)/lib/vdso/Makefile
10
11 # Same as cc-*option, but using CC_COMPAT instead of CC
12 ifeq ($(CONFIG_CC_IS_CLANG), y)
13 CC_COMPAT ?= $(CC)
14 CC_COMPAT += --target=arm-linux-gnueabi
15 else
16 CC_COMPAT ?= $(CROSS_COMPILE_COMPAT)gcc
17 endif
18
19 ifeq ($(CONFIG_LD_IS_LLD), y)
20 LD_COMPAT ?= $(LD)
21 else
22 LD_COMPAT ?= $(CROSS_COMPILE_COMPAT)ld
23 endif
24
25 cc32-option = $(call try-run,\
26         $(CC_COMPAT) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
27 cc32-disable-warning = $(call try-run,\
28         $(CC_COMPAT) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
29
30 # We cannot use the global flags to compile the vDSO files, the main reason
31 # being that the 32-bit compiler may be older than the main (64-bit) compiler
32 # and therefore may not understand flags set using $(cc-option ...). Besides,
33 # arch-specific options should be taken from the arm Makefile instead of the
34 # arm64 one.
35 # As a result we set our own flags here.
36
37 # KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top-level Makefile
38 VDSO_CPPFLAGS := -DBUILD_VDSO -D__KERNEL__ -nostdinc
39 VDSO_CPPFLAGS += -isystem $(shell $(CC_COMPAT) -print-file-name=include 2>/dev/null)
40 VDSO_CPPFLAGS += $(LINUXINCLUDE)
41
42 # Common C and assembly flags
43 # From top-level Makefile
44 VDSO_CAFLAGS := $(VDSO_CPPFLAGS)
45 VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
46 ifdef CONFIG_DEBUG_INFO
47 VDSO_CAFLAGS += -g
48 endif
49
50 # From arm Makefile
51 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
52 VDSO_CAFLAGS += -mabi=aapcs-linux -mfloat-abi=soft
53 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
54 VDSO_CAFLAGS += -mbig-endian
55 else
56 VDSO_CAFLAGS += -mlittle-endian
57 endif
58
59 # From arm vDSO Makefile
60 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
61 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
62 VDSO_CAFLAGS += -march=armv8-a
63
64 VDSO_CFLAGS := $(VDSO_CAFLAGS)
65 VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1
66 # KBUILD_CFLAGS from top-level Makefile
67 VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
68                -fno-strict-aliasing -fno-common \
69                -Werror-implicit-function-declaration \
70                -Wno-format-security \
71                -Wdeclaration-after-statement \
72                -std=gnu11
73 VDSO_CFLAGS  += -O2
74 # Some useful compiler-dependent flags from top-level Makefile
75 VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,)
76 VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
77 VDSO_CFLAGS += -fno-strict-overflow
78 VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes)
79 VDSO_CFLAGS += -Werror=date-time
80 VDSO_CFLAGS += $(call cc32-option,-Werror=incompatible-pointer-types)
81
82 # The 32-bit compiler does not provide 128-bit integers, which are used in
83 # some headers that are indirectly included from the vDSO code.
84 # This hack makes the compiler happy and should trigger a warning/error if
85 # variables of such type are referenced.
86 VDSO_CFLAGS += -D__uint128_t='void*'
87 # Silence some warnings coming from headers that operate on long's
88 # (on GCC 4.8 or older, there is unfortunately no way to silence this warning)
89 VDSO_CFLAGS += $(call cc32-disable-warning,shift-count-overflow)
90 VDSO_CFLAGS += -Wno-int-to-pointer-cast
91
92 # Compile as THUMB2 or ARM. Unwinding via frame-pointers in THUMB2 is
93 # unreliable.
94 ifeq ($(CONFIG_THUMB2_COMPAT_VDSO), y)
95 VDSO_CFLAGS += -mthumb -fomit-frame-pointer
96 else
97 VDSO_CFLAGS += -marm
98 endif
99
100 VDSO_AFLAGS := $(VDSO_CAFLAGS)
101 VDSO_AFLAGS += -D__ASSEMBLY__
102
103 # From arm vDSO Makefile
104 VDSO_LDFLAGS += -Bsymbolic --no-undefined -soname=linux-vdso.so.1
105 VDSO_LDFLAGS += -z max-page-size=4096 -z common-page-size=4096
106 VDSO_LDFLAGS += -shared --hash-style=sysv --build-id=sha1
107
108
109 # Borrow vdsomunge.c from the arm vDSO
110 # We have to use a relative path because scripts/Makefile.host prefixes
111 # $(hostprogs) with $(obj)
112 munge := ../../../arm/vdso/vdsomunge
113 hostprogs := $(munge)
114
115 c-obj-vdso := note.o
116 c-obj-vdso-gettimeofday := vgettimeofday.o
117
118 ifneq ($(c-gettimeofday-y),)
119 VDSO_CFLAGS_gettimeofday_o += -include $(c-gettimeofday-y)
120 endif
121
122 VDSO_CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os
123
124 # Build rules
125 targets := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso) vdso.so vdso.so.dbg vdso.so.raw
126 c-obj-vdso := $(addprefix $(obj)/, $(c-obj-vdso))
127 c-obj-vdso-gettimeofday := $(addprefix $(obj)/, $(c-obj-vdso-gettimeofday))
128 asm-obj-vdso := $(addprefix $(obj)/, $(asm-obj-vdso))
129 obj-vdso := $(c-obj-vdso) $(c-obj-vdso-gettimeofday) $(asm-obj-vdso)
130
131 targets += vdso.lds
132 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
133
134 include/generated/vdso32-offsets.h: $(obj)/vdso.so.dbg FORCE
135         $(call if_changed,vdsosym)
136
137 # Strip rule for vdso.so
138 $(obj)/vdso.so: OBJCOPYFLAGS := -S
139 $(obj)/vdso.so: $(obj)/vdso.so.dbg FORCE
140         $(call if_changed,objcopy)
141
142 $(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/$(munge) FORCE
143         $(call if_changed,vdsomunge)
144
145 # Link rule for the .so file, .lds has to be first
146 $(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
147         $(call if_changed,vdsold_and_vdso_check)
148
149 # Compilation rules for the vDSO sources
150 $(c-obj-vdso): %.o: %.c FORCE
151         $(call if_changed_dep,vdsocc)
152 $(c-obj-vdso-gettimeofday): %.o: %.c FORCE
153         $(call if_changed_dep,vdsocc_gettimeofday)
154 $(asm-obj-vdso): %.o: %.S FORCE
155         $(call if_changed_dep,vdsoas)
156
157 # Actual build commands
158 quiet_cmd_vdsold_and_vdso_check = LD32    $@
159       cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check)
160
161 quiet_cmd_vdsold = LD32    $@
162       cmd_vdsold = $(LD_COMPAT) $(VDSO_LDFLAGS) \
163                    -T $(filter %.lds,$^) $(filter %.o,$^) -o $@
164 quiet_cmd_vdsocc = CC32    $@
165       cmd_vdsocc = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) -c -o $@ $<
166 quiet_cmd_vdsocc_gettimeofday = CC32    $@
167       cmd_vdsocc_gettimeofday = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_CFLAGS) $(VDSO_CFLAGS_gettimeofday_o) -c -o $@ $<
168 quiet_cmd_vdsoas = AS32    $@
169       cmd_vdsoas = $(CC_COMPAT) -Wp,-MD,$(depfile) $(VDSO_AFLAGS) -c -o $@ $<
170
171 quiet_cmd_vdsomunge = MUNGE   $@
172       cmd_vdsomunge = $(obj)/$(munge) $< $@
173
174 # Generate vDSO offsets using helper script (borrowed from the 64-bit vDSO)
175 gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh
176 quiet_cmd_vdsosym = VDSOSYM $@
177 # The AArch64 nm should be able to read an AArch32 binary
178       cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
179
180 # Install commands for the unstripped file
181 quiet_cmd_vdso_install = INSTALL32 $@
182       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
183
184 vdso.so: $(obj)/vdso.so.dbg
185         @mkdir -p $(MODLIB)/vdso
186         $(call cmd,vdso_install)
187
188 vdso_install: vdso.so