xref: /openbmc/linux/arch/arm/vdso/Makefile (revision 82e6fdd6)
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# Force dependency
34$(obj)/vdso.o : $(obj)/vdso.so
35
36# Link rule for the .so file
37$(obj)/vdso.so.raw: $(src)/vdso.lds $(obj-vdso) FORCE
38	$(call if_changed,vdsold)
39
40$(obj)/vdso.so.dbg: $(obj)/vdso.so.raw $(obj)/vdsomunge FORCE
41	$(call if_changed,vdsomunge)
42
43# Strip rule for the .so file
44$(obj)/%.so: OBJCOPYFLAGS := -S
45$(obj)/%.so: $(obj)/%.so.dbg FORCE
46	$(call if_changed,objcopy)
47
48# Actual build commands
49quiet_cmd_vdsold = VDSO    $@
50      cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
51                   -Wl,-T $(filter %.lds,$^) $(filter %.o,$^) -o $@
52
53quiet_cmd_vdsomunge = MUNGE   $@
54      cmd_vdsomunge = $(objtree)/$(obj)/vdsomunge $< $@
55
56#
57# Install the unstripped copy of vdso.so.dbg.  If our toolchain
58# supports build-id, install .build-id links as well.
59#
60# Cribbed from arch/x86/vdso/Makefile.
61#
62quiet_cmd_vdso_install = INSTALL $<
63define cmd_vdso_install
64	cp $< "$(MODLIB)/vdso/vdso.so"; \
65	if readelf -n $< | grep -q 'Build ID'; then \
66	  buildid=`readelf -n $< |grep 'Build ID' |sed -e 's/^.*Build ID: \(.*\)$$/\1/'`; \
67	  first=`echo $$buildid | cut -b-2`; \
68	  last=`echo $$buildid | cut -b3-`; \
69	  mkdir -p "$(MODLIB)/vdso/.build-id/$$first"; \
70	  ln -sf "../../vdso.so" "$(MODLIB)/vdso/.build-id/$$first/$$last.debug"; \
71	fi
72endef
73
74$(MODLIB)/vdso: FORCE
75	@mkdir -p $(MODLIB)/vdso
76
77PHONY += vdso_install
78vdso_install: $(obj)/vdso.so.dbg $(MODLIB)/vdso
79	$(call cmd,vdso_install)
80