Makefile 2.68 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0-only
Palmer Dabbelt's avatar
Palmer Dabbelt committed
2 3
# Copied from arch/tile/kernel/vdso/Makefile

4 5 6 7
# Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
# the inclusion of generic Makefile.
ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
include $(srctree)/lib/vdso/Makefile
Palmer Dabbelt's avatar
Palmer Dabbelt committed
8
# Symbols present in the vdso
9
vdso-syms  = rt_sigreturn
10
ifdef CONFIG_64BIT
11
vdso-syms += vgettimeofday
12
endif
13
vdso-syms += getcpu
14
vdso-syms += flush_icache
Palmer Dabbelt's avatar
Palmer Dabbelt committed
15 16

# Files to link into the vdso
17
obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
Palmer Dabbelt's avatar
Palmer Dabbelt committed
18

19 20
ccflags-y := -fno-stack-protector

21
ifneq ($(c-gettimeofday-y),)
22
  CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
23 24
endif

Palmer Dabbelt's avatar
Palmer Dabbelt committed
25 26 27 28 29 30 31
# Build rules
targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
obj-vdso := $(addprefix $(obj)/, $(obj-vdso))

obj-y += vdso.o vdso-syms.o
CPPFLAGS_vdso.lds += -P -C -U$(ARCH)

32 33 34
# Disable -pg to prevent insert call site
CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os

Palmer Dabbelt's avatar
Palmer Dabbelt committed
35 36
# Disable gcov profiling for VDSO code
GCOV_PROFILE := n
37
KCOV_INSTRUMENT := n
Palmer Dabbelt's avatar
Palmer Dabbelt committed
38 39 40 41 42 43 44 45 46 47

# Force dependency
$(obj)/vdso.o: $(obj)/vdso.so

# link rule for the .so file, .lds has to be first
SYSCFLAGS_vdso.so.dbg = $(c_flags)
$(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
	$(call if_changed,vdsold)

# We also create a special relocatable object that should mirror the symbol
48 49
# table and layout of the linked DSO. With ld --just-symbols we can then
# refer to these symbols in the kernel code rather than hand-coded addresses.
Palmer Dabbelt's avatar
Palmer Dabbelt committed
50 51

SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
52
	-Wl,--build-id=sha1 -Wl,--hash-style=both
Palmer Dabbelt's avatar
Palmer Dabbelt committed
53 54 55
$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
	$(call if_changed,vdsold)

56
LDFLAGS_vdso-syms.o := -r --just-symbols
Palmer Dabbelt's avatar
Palmer Dabbelt committed
57 58 59 60 61 62 63 64 65 66 67 68 69
$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
	$(call if_changed,ld)

# strip rule for the .so file
$(obj)/%.so: OBJCOPYFLAGS := -S
$(obj)/%.so: $(obj)/%.so.dbg FORCE
	$(call if_changed,objcopy)

# actual build commands
# The DSO images are built using a special linker script
# Add -lgcc so rv32 gets static muldi3 and lshrdi3 definitions.
# Make sure only to export the intended __vdso_xxx symbol offsets.
quiet_cmd_vdsold = VDSOLD  $@
70 71
      cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
                           -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
Palmer Dabbelt's avatar
Palmer Dabbelt committed
72
                   $(CROSS_COMPILE)objcopy \
Ilie Halip's avatar
Ilie Halip committed
73 74
                           $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
                   rm $@.tmp
Palmer Dabbelt's avatar
Palmer Dabbelt committed
75 76 77 78 79 80 81 82 83 84

# install commands for the unstripped file
quiet_cmd_vdso_install = INSTALL $@
      cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@

vdso.so: $(obj)/vdso.so.dbg
	@mkdir -p $(MODLIB)/vdso
	$(call cmd,vdso_install)

vdso_install: vdso.so