xref: /linux/arch/um/kernel/skas/Makefile (revision d5f40f0b4bd185bf477c4a579774d2eafd302da7)
1# SPDX-License-Identifier: GPL-2.0
2#
3# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4#
5
6obj-y := stub.o process.o syscall.o \
7	 stub_exe_embed.o
8obj-$(CONFIG_MMU) += mmu.o uaccess.o
9ifneq ($(CONFIG_MMU),y)
10obj-y += nommu.o
11endif
12
13# Stub executable
14
15stub_exe_objs-y := stub_exe.o
16
17stub_exe_objs := $(foreach F,$(stub_exe_objs-y),$(obj)/$F)
18
19# Object file containing the ELF executable
20$(obj)/stub_exe_embed.o: $(src)/stub_exe_embed.S $(obj)/stub_exe
21
22$(obj)/stub_exe.dbg: $(stub_exe_objs) FORCE
23	$(call if_changed,stub_exe)
24
25$(obj)/stub_exe: OBJCOPYFLAGS := -S
26$(obj)/stub_exe: $(obj)/stub_exe.dbg FORCE
27	$(call if_changed,objcopy)
28
29quiet_cmd_stub_exe = STUB_EXE $@
30      cmd_stub_exe = $(CC) -nostdlib -o $@ \
31			   $(filter-out $(UM_GPROF_OPT) $(UM_GCOV_OPT),$(KBUILD_CFLAGS)) $(STUB_EXE_LDFLAGS) \
32			   $(filter %.o,$^)
33
34STUB_EXE_LDFLAGS = -Wl,-n -static
35
36targets += stub_exe.dbg stub_exe $(stub_exe_objs-y)
37
38# end
39
40# stub.o is in the stub, so it can't be built with profiling
41# GCC hardened also auto-enables -fpic, but we need %ebx so it can't work ->
42# disable it
43
44CFLAGS_stub.o := $(CFLAGS_NO_HARDENING)
45CFLAGS_stub_exe.o := $(CFLAGS_NO_HARDENING)
46
47# stub_signal_restorer() must not touch stack pointer, clang doesn't
48# always omit the frame pointer automatically
49CFLAGS_stub.o += -fomit-frame-pointer
50CFLAGS_stub_exe.o += -fomit-frame-pointer
51
52# Clang's stack var initialisation can use memset() or similar and that
53# cannot be done for this code since we embed/move the stub
54CFLAGS_stub.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized)
55CFLAGS_stub_exe.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized)
56
57UNPROFILE_OBJS := stub.o stub_exe.o
58KCOV_INSTRUMENT := n
59
60include $(srctree)/arch/um/scripts/Makefile.rules
61