Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 
0003 # Absolute relocation type $(ARCH_REL_TYPE_ABS) needs to be defined before
0004 # the inclusion of generic Makefile.
0005 ARCH_REL_TYPE_ABS := R_CKCORE_ADDR32|R_CKCORE_JUMP_SLOT
0006 include $(srctree)/lib/vdso/Makefile
0007 
0008 # Symbols present in the vdso
0009 vdso-syms  += rt_sigreturn
0010 vdso-syms  += vgettimeofday
0011 
0012 # Files to link into the vdso
0013 obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o
0014 
0015 ifneq ($(c-gettimeofday-y),)
0016         CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y)
0017 endif
0018 
0019 ccflags-y := -fno-stack-protector -DBUILD_VDSO32
0020 
0021 # Build rules
0022 targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
0023 obj-vdso := $(addprefix $(obj)/, $(obj-vdso))
0024 
0025 obj-y += vdso.o vdso-syms.o
0026 CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
0027 
0028 # Disable gcov profiling for VDSO code
0029 GCOV_PROFILE := n
0030 KCOV_INSTRUMENT := n
0031 
0032 # Force dependency
0033 $(obj)/vdso.o: $(obj)/vdso.so
0034 
0035 SYSCFLAGS_vdso.so.dbg = $(c_flags)
0036 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
0037         $(call if_changed,vdsold)
0038 SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
0039         -Wl,--build-id=sha1 -Wl,--hash-style=both
0040 
0041 $(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
0042         $(call if_changed,so2s)
0043 
0044 # strip rule for the .so file
0045 $(obj)/%.so: OBJCOPYFLAGS := -S
0046 $(obj)/%.so: $(obj)/%.so.dbg FORCE
0047         $(call if_changed,objcopy)
0048 
0049 # actual build commands
0050 # The DSO images are built using a special linker script
0051 # Make sure only to export the intended __vdso_xxx symbol offsets.
0052 quiet_cmd_vdsold = VDSOLD  $@
0053       cmd_vdsold = $(CC) $(KBUILD_CFLAGS) $(call cc-option, -no-pie) -nostdlib -nostartfiles $(SYSCFLAGS_$(@F)) \
0054                            -Wl,-T,$(filter-out FORCE,$^) -o $@.tmp && \
0055                    $(CROSS_COMPILE)objcopy \
0056                            $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
0057                    rm $@.tmp
0058 
0059 # Extracts symbol offsets from the VDSO, converting them into an assembly file
0060 # that contains the same symbols at the same offsets.
0061 quiet_cmd_so2s = SO2S    $@
0062       cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
0063 
0064 # install commands for the unstripped file
0065 quiet_cmd_vdso_install = INSTALL $@
0066       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
0067 
0068 vdso.so: $(obj)/vdso.so.dbg
0069         @mkdir -p $(MODLIB)/vdso
0070         $(call cmd,vdso_install)
0071 
0072 vdso_install: vdso.so