xref: /openbmc/linux/arch/arm/vdso/Makefile (revision ba61bb17)
1# SPDX-License-Identifier: GPL-2.0
2hostprogs-y := vdsomunge
3
4obj-vdso := vgettimeofday.o datapage.o
5
6# Build rules
7targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.so.raw vdso.lds
8obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
9
10ccflags-y := -fPIC -fno-common -fno-builtin -fno-stack-protector
11ccflags-y += -DDISABLE_BRANCH_PROFILING
12
13VDSO_LDFLAGS := -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
14VDSO_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
15VDSO_LDFLAGS += -nostdlib -shared
16VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
17VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)--build-id)
18VDSO_LDFLAGS += $(call cc-ldoption, -fuse-ld=bfd)
19
20obj-$(CONFIG_VDSO) += vdso.o
21extra-$(CONFIG_VDSO) += vdso.lds
22CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
23
24CFLAGS_REMOVE_vdso.o = -pg
25
26# Force -O2 to avoid libgcc dependencies
27CFLAGS_REMOVE_vgettimeofday.o = -pg -Os
28CFLAGS_vgettimeofday.o = -O2
29
30# Disable gcov profiling for VDSO code
31GCOV_PROFILE := n
32
33# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
34KCOV_INSTRUMENT := n
35
36# Force dependency
37$(obj)/vdso.o : $(obj)/vdso.so
38
39# Link rule for the .so file
40$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
41	$(call if_changed,vdsold)
42
43$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE
44	$(call if_changed,vdsomunge)
45
46# Strip rule for the .so file
47$(obj)/%.so: OBJCOPYFLAGS := -S
48$(obj)/%.so: $(obj)/%.so.dbg FORCE
49	$(call if_changed,objcopy)
50
51# Actual build commands
52quiet_cmd_vdsold = VDSO    $@
53      cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
54                   -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
55
56quiet_cmd_vdsomunge = MUNGE   $@
57      cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
58
59#
60# Install the unstripped copy of vdso.so.dbg.  If our toolchain
61# supports build-id, install .build-id links as well.
62#
63# Cribbed from arch/x86/vdso/Makefile.
64#
65quiet_cmd_vdso_install = INSTALL $<
66define cmd_vdso_install
67	cp $< "$(MODLIB)/vdso/vdso.so"; \
68	if readelf -n $< | grep -q 'Build ID'; then \
69	  buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
70	  first=`echo $$buildid | cut -b-2`; \
71	  last=`echo $$buildid | cut -b3-`; \
72	  mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
73	  ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
74	fi
75endef
76
77$(MODLIB)/vdso: FORCE
78	@mkdir -p $(MODLIB)/vdso
79
80PHONY += vdso_install
81vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso
82	$(call cmd,vdso_install)
83