2 # Building a vDSO image for AArch32.
4 # Author: Kevin Brodsky <kevin.brodsky@arm.com>
5 # A mix between the arm64 and arm vDSO Makefiles.
7 ifeq ($(cc-name
),clang
)
8 CC_ARM32
:= $(cc-name
) $(CLANG_TARGET_ARM32
) -no-integrated-as
10 CC_ARM32
:= $(CROSS_COMPILE_ARM32
)$(cc-name
)
13 # Same as cc-*option, but using CC_ARM32 instead of CC
14 cc32-option
= $(call try-run
,\
15 $(CC_ARM32
) $(1) -c
-x c
/dev
/null
-o
"$$TMP",$(1),$(2))
16 cc32-disable-warning
= $(call try-run
,\
17 $(CC_ARM32
) -W
$(strip $(1)) -c
-x c
/dev
/null
-o
"$$TMP",-Wno-
$(strip $(1)))
18 cc32-ldoption
= $(call try-run
,\
19 $(CC_ARM32
) $(1) -nostdlib
-x c
/dev
/null
-o
"$$TMP",$(1),$(2))
21 # We cannot use the global flags to compile the vDSO files, the main reason
22 # being that the 32-bit compiler may be older than the main (64-bit) compiler
23 # and therefore may not understand flags set using $(cc-option ...). Besides,
24 # arch-specific options should be taken from the arm Makefile instead of the
26 # As a result we set our own flags here.
28 # From top-level Makefile
30 VDSO_CPPFLAGS
:= -nostdinc
-isystem
$(shell $(CC_ARM32
) -print-file-name
=include)
31 VDSO_CPPFLAGS
+= $(LINUXINCLUDE
)
32 VDSO_CPPFLAGS
+= $(KBUILD_CPPFLAGS
)
34 # Common C and assembly flags
35 # From top-level Makefile
36 VDSO_CAFLAGS
:= $(VDSO_CPPFLAGS
)
37 VDSO_CAFLAGS
+= $(call cc32-option
,-fno-PIE
)
38 ifdef CONFIG_DEBUG_INFO
41 ifeq ($(shell $(CONFIG_SHELL
) $(srctree
)/scripts
/gcc-goto.sh
$(CC_ARM32
)), y
)
42 VDSO_CAFLAGS
+= -DCC_HAVE_ASM_GOTO
46 VDSO_CAFLAGS
+= $(call cc32-option
,-fno-dwarf2-cfi-asm
)
47 VDSO_CAFLAGS
+= -mabi
=aapcs-linux
-mfloat-abi
=soft
48 ifeq ($(CONFIG_CPU_BIG_ENDIAN
), y
)
49 VDSO_CAFLAGS
+= -mbig-endian
51 VDSO_CAFLAGS
+= -mlittle-endian
54 # From arm vDSO Makefile
55 VDSO_CAFLAGS
+= -fPIC
-fno-builtin
-fno-stack-protector
56 VDSO_CAFLAGS
+= -DDISABLE_BRANCH_PROFILING
58 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
59 # fall back to v7. There is no easy way to check for what architecture the code
60 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
61 VDSO_CAFLAGS
+= $(call cc32-option
,-march
=armv8-a
-D__LINUX_ARM_ARCH__
=8,\
62 -march
=armv7-a
-D__LINUX_ARM_ARCH__
=7)
64 VDSO_CFLAGS
:= $(VDSO_CAFLAGS
)
65 # KBUILD_CFLAGS from top-level Makefile
66 VDSO_CFLAGS
+= -Wall
-Wundef
-Wstrict-prototypes
-Wno-trigraphs \
67 -fno-strict-aliasing
-fno-common \
68 -Werror-implicit-function-declaration \
69 -Wno-format-security \
72 # Some useful compiler-dependent flags from top-level Makefile
73 VDSO_CFLAGS
+= $(call cc32-option
,-Wdeclaration-after-statement
,)
74 VDSO_CFLAGS
+= $(call cc32-option
,-Wno-pointer-sign
)
75 VDSO_CFLAGS
+= $(call cc32-option
,-fno-strict-overflow
)
76 VDSO_CFLAGS
+= $(call cc32-option
,-Werror
=strict-prototypes
)
77 VDSO_CFLAGS
+= $(call cc32-option
,-Werror
=date-time
)
78 VDSO_CFLAGS
+= $(call cc32-option
,-Werror
=incompatible-pointer-types
)
80 # The 32-bit compiler does not provide 128-bit integers, which are used in
81 # some headers that are indirectly included from the vDSO code.
82 # This hack makes the compiler happy and should trigger a warning/error if
83 # variables of such type are referenced.
84 VDSO_CFLAGS
+= -D__uint128_t
='void*'
85 # Silence some warnings coming from headers that operate on long's
86 # (on GCC 4.8 or older, there is unfortunately no way to silence this warning)
87 VDSO_CFLAGS
+= $(call cc32-disable-warning
,shift-count-overflow
)
88 VDSO_CFLAGS
+= -Wno-int-to-pointer-cast
90 VDSO_AFLAGS
:= $(VDSO_CAFLAGS
)
91 VDSO_AFLAGS
+= -D__ASSEMBLY__
93 VDSO_LDFLAGS
:= $(VDSO_CPPFLAGS
)
94 # From arm vDSO Makefile
95 VDSO_LDFLAGS
+= -Wl
,-Bsymbolic
-Wl
,--no-undefined
-Wl
,-soname
=linux-vdso.so
.1
96 VDSO_LDFLAGS
+= -Wl
,-z
,max-page-size
=4096 -Wl
,-z
,common-page-size
=4096
97 VDSO_LDFLAGS
+= -nostdlib
-shared
-mfloat-abi
=soft
98 VDSO_LDFLAGS
+= $(call cc32-ldoption
,-Wl
$(comma
)--hash-style
=sysv
)
99 VDSO_LDFLAGS
+= $(call cc32-ldoption
,-Wl
$(comma
)--build-id
)
100 VDSO_LDFLAGS
+= $(call cc32-ldoption
,-fuse-ld
=bfd
)
103 # Borrow vdsomunge.c from the arm vDSO
104 # We have to use a relative path because scripts/Makefile.host prefixes
105 # $(hostprogs-y) with $(obj)
106 munge
:= ..
/..
/..
/arm
/vdso
/vdsomunge
107 hostprogs-y
:= $(munge
)
109 c-obj-vdso
:= vgettimeofday.o
110 asm-obj-vdso
:= sigreturn.o
113 targets
:= $(c-obj-vdso
) $(asm-obj-vdso
) vdso.so vdso.so.dbg vdso.so.raw
114 c-obj-vdso
:= $(addprefix $(obj
)/, $(c-obj-vdso
))
115 asm-obj-vdso
:= $(addprefix $(obj
)/, $(asm-obj-vdso
))
116 obj-vdso
:= $(c-obj-vdso
) $(asm-obj-vdso
)
120 CPPFLAGS_vdso.lds
+= -P
-C
-U
$(ARCH
)
122 # Force dependency (vdso.s includes vdso.so through incbin)
123 $(obj
)/vdso.o
: $(obj
)/vdso.so
125 include/generated
/vdso32-offsets.h
: $(obj
)/vdso.so.dbg FORCE
126 $(call if_changed
,vdsosym
)
128 # Strip rule for vdso.so
129 $(obj
)/vdso.so
: OBJCOPYFLAGS
:= -S
130 $(obj
)/vdso.so
: $(obj
)/vdso.so.dbg FORCE
131 $(call if_changed
,objcopy
)
133 $(obj
)/vdso.so.dbg
: $(obj
)/vdso.so.raw
$(obj
)/$(munge
) FORCE
134 $(call if_changed
,vdsomunge
)
136 # Link rule for the .so file, .lds has to be first
137 $(obj
)/vdso.so.raw
: $(src
)/vdso.lds
$(obj-vdso
) FORCE
138 $(call if_changed
,vdsold
)
140 # Compilation rules for the vDSO sources
141 $(filter-out vgettimeofday.o
, $(c-obj-vdso
)): %.o
: %.c FORCE
142 $(call if_changed_dep
,vdsocc
)
143 $(asm-obj-vdso
): %.o
: %.S FORCE
144 $(call if_changed_dep
,vdsoas
)
146 # Actual build commands
147 quiet_cmd_vdsold
= VDSOL32
$@
148 cmd_vdsold
= $(CC_ARM32
) -Wp
,-MD
,$(depfile
) $(VDSO_LDFLAGS
) \
149 -Wl
,-T
$(filter %.lds
,$^
) $(filter %.o
,$^
) -o
$@
150 quiet_cmd_vdsocc
= VDSOC32
$@
151 cmd_vdsocc
= $(CC_ARM32
) -Wp
,-MD
,$(depfile
) $(VDSO_CFLAGS
) -c
-o
$@
$<
152 quiet_cmd_vdsoas
= VDSOA32
$@
153 cmd_vdsoas
= $(CC_ARM32
) -Wp
,-MD
,$(depfile
) $(VDSO_AFLAGS
) -c
-o
$@
$<
155 quiet_cmd_vdsomunge
= MUNGE
$@
156 cmd_vdsomunge
= $(obj
)/$(munge
) $< $@
158 # Generate vDSO offsets using helper script (borrowed from the 64-bit vDSO)
159 gen-vdsosym
:= $(srctree
)/$(src
)/..
/vdso
/gen_vdso_offsets.sh
160 quiet_cmd_vdsosym
= VDSOSYM
$@
161 # The AArch64 nm should be able to read an AArch32 binary
162 cmd_vdsosym
= $(NM
) $< |
$(gen-vdsosym
) | LC_ALL
=C
sort > $@
164 # Install commands for the unstripped file
165 quiet_cmd_vdso_install
= INSTALL
$@
166 cmd_vdso_install
= cp
$(obj
)/$@.dbg
$(MODLIB
)/vdso
/vdso32.so
168 vdso.so
: $(obj
)/vdso.so.dbg
169 @mkdir
-p
$(MODLIB
)/vdso
170 $(call cmd
,vdso_install
)
172 vdso_install
: vdso.so