cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

Makefile (2544B)


      1# SPDX-License-Identifier: GPL-2.0-only
      2#
      3# Makefile for compat_vdso
      4#
      5
      6# Symbols present in the compat_vdso
      7compat_vdso-syms  = rt_sigreturn
      8compat_vdso-syms += getcpu
      9compat_vdso-syms += flush_icache
     10
     11COMPAT_CC := $(CC)
     12COMPAT_LD := $(LD)
     13
     14COMPAT_CC_FLAGS := -march=rv32g -mabi=ilp32
     15COMPAT_LD_FLAGS := -melf32lriscv
     16
     17# Files to link into the compat_vdso
     18obj-compat_vdso = $(patsubst %, %.o, $(compat_vdso-syms)) note.o
     19
     20# Build rules
     21targets := $(obj-compat_vdso) compat_vdso.so compat_vdso.so.dbg compat_vdso.lds
     22obj-compat_vdso := $(addprefix $(obj)/, $(obj-compat_vdso))
     23
     24obj-y += compat_vdso.o
     25CPPFLAGS_compat_vdso.lds += -P -C -U$(ARCH)
     26
     27# Disable profiling and instrumentation for VDSO code
     28GCOV_PROFILE := n
     29KCOV_INSTRUMENT := n
     30KASAN_SANITIZE := n
     31UBSAN_SANITIZE := n
     32
     33# Force dependency
     34$(obj)/compat_vdso.o: $(obj)/compat_vdso.so
     35
     36# link rule for the .so file, .lds has to be first
     37$(obj)/compat_vdso.so.dbg: $(obj)/compat_vdso.lds $(obj-compat_vdso) FORCE
     38	$(call if_changed,compat_vdsold)
     39LDFLAGS_compat_vdso.so.dbg = -shared -S -soname=linux-compat_vdso.so.1 \
     40	--build-id=sha1 --hash-style=both --eh-frame-hdr
     41
     42$(obj-compat_vdso): %.o: %.S FORCE
     43	$(call if_changed_dep,compat_vdsoas)
     44
     45# strip rule for the .so file
     46$(obj)/%.so: OBJCOPYFLAGS := -S
     47$(obj)/%.so: $(obj)/%.so.dbg FORCE
     48	$(call if_changed,objcopy)
     49
     50# Generate VDSO offsets using helper script
     51gen-compat_vdsosym := $(srctree)/$(src)/gen_compat_vdso_offsets.sh
     52quiet_cmd_compat_vdsosym = VDSOSYM $@
     53	cmd_compat_vdsosym = $(NM) $< | $(gen-compat_vdsosym) | LC_ALL=C sort > $@
     54
     55include/generated/compat_vdso-offsets.h: $(obj)/compat_vdso.so.dbg FORCE
     56	$(call if_changed,compat_vdsosym)
     57
     58# actual build commands
     59# The DSO images are built using a special linker script
     60# Make sure only to export the intended __compat_vdso_xxx symbol offsets.
     61quiet_cmd_compat_vdsold = VDSOLD  $@
     62      cmd_compat_vdsold = $(COMPAT_LD) $(ld_flags) $(COMPAT_LD_FLAGS) -T $(filter-out FORCE,$^) -o $@.tmp && \
     63                   $(OBJCOPY) $(patsubst %, -G __compat_vdso_%, $(compat_vdso-syms)) $@.tmp $@ && \
     64                   rm $@.tmp
     65
     66# actual build commands
     67quiet_cmd_compat_vdsoas = VDSOAS $@
     68      cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $<
     69
     70# install commands for the unstripped file
     71quiet_cmd_compat_vdso_install = INSTALL $@
     72      cmd_compat_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/compat_vdso/$@
     73
     74compat_vdso.so: $(obj)/compat_vdso.so.dbg
     75	@mkdir -p $(MODLIB)/compat_vdso
     76	$(call cmd,compat_vdso_install)
     77
     78compat_vdso_install: compat_vdso.so