Skip to content

Commit 7b12b91

Browse files
Paolo 'Blaisorblade' GiarrussoLinus Torvalds
authored andcommitted
[PATCH] uml: cleanup unprofile expression and build infrastructure
*) Rather than duplicate in various buggy ways the application of CFLAGS_NO_HARDENING and UNPROFILE (which apply to the same files), centralize it in Makefile.rules. UNPROFILE_OBJS mustn't be listed in USER_OBJS but are compiled as such. I've also verified that unprofile didn't work in the current form, because we set _c_flags directly (using CFLAGS and not USER_CFLAGS, which is wrong), which is normally used by c_flags, but we also override c_flags for all USER_OBJS, and there we don't call unprofile. Instead it only worked for unmap.o, the only one which wasn't a USER_OBJ. We need to set c_flags (which is not a public Kbuild API) to clear a lot of compilation flags like -nostdinc which Kbuild forces on everything. *) Rather than $(CFLAGS_$(notdir $@)), which expands to CFLAGS_anObj.s when building "anObj.s", use $(CFLAGS_$(*F).o) which always accesses CFLAGS_anObj.o, like done by Kbuild. *) Make c_flags apply to all targets having the same basename, rather than listing .s, .i, .lst and .o, with the use (which I tested) of $(USER_OBJS:.o=.%): c_flags = ... and of - $(obj)/unmap.c: _c_flags = ... + $(obj)/unmap.%: _c_flags = ... Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[email protected]> Acked-by: Jeff Dike <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 275e6e1 commit 7b12b91

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

arch/um/kernel/skas/Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
obj-y := clone.o exec_kern.o mem.o mmu.o process_kern.o \
77
syscall.o tlb.o uaccess.o
88

9-
USER_OBJS := clone.o
10-
11-
include arch/um/scripts/Makefile.rules
12-
139
# clone.o is in the stub, so it can't be built with profiling
1410
# GCC hardened also auto-enables -fpic, but we need %ebx so it can't work ->
1511
# disable it
1612

1713
CFLAGS_clone.o := $(CFLAGS_NO_HARDENING)
14+
UNPROFILE_OBJS := clone.o
1815

19-
# since we're setting c_flags we _must_ add $(CFLAGS_$(*F).o).
20-
21-
$(obj)/clone.o : c_flags = -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS)) $(CFLAGS_$(*F).o)
16+
include arch/um/scripts/Makefile.rules

arch/um/scripts/Makefile.rules

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ USER_SINGLE_OBJS := \
77
USER_OBJS += $(filter %_user.o,$(obj-y) $(obj-m) $(USER_SINGLE_OBJS))
88
USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
99

10-
$(USER_OBJS) $(USER_OBJS:.o=.i) $(USER_OBJS:.o=.s) $(USER_OBJS:.o=.lst): \
11-
c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(notdir $@))
10+
$(USER_OBJS:.o=.%): \
11+
c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) $(CFLAGS_$(*F).o)
1212
$(USER_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \
1313
-Dunix -D__unix__ -D__$(SUBARCH)__
1414

15+
# These are like USER_OBJS but filter USER_CFLAGS through unprofile instead of
16+
# using it directly.
17+
UNPROFILE_OBJS := $(foreach file,$(UNPROFILE_OBJS),$(obj)/$(file))
18+
19+
$(UNPROFILE_OBJS:.o=.%): \
20+
c_flags = -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS)) $(CFLAGS_$(*F).o)
21+
$(UNPROFILE_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \
22+
-Dunix -D__unix__ -D__$(SUBARCH)__
1523

1624
# The stubs and unmap.o can't try to call mcount or update basic block data
1725
define unprofile

arch/um/sys-i386/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ subarch-obj-y = lib/bitops.o kernel/semaphore.o
88
subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o
99
subarch-obj-$(CONFIG_MODULES) += kernel/module.o
1010

11-
USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o stub_segv.o
11+
USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
1212

1313
USER_OBJS += user-offsets.s
1414
extra-y += user-offsets.s
1515

16-
CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
17-
1816
extra-$(CONFIG_MODE_TT) += unmap.o
1917

18+
UNPROFILE_OBJS := stub_segv.o
19+
CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
20+
2021
include arch/um/scripts/Makefile.rules
2122

22-
$(obj)/stub_segv.o $(obj)/unmap.o: \
23-
_c_flags = $(call unprofile,$(CFLAGS))
23+
$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))

arch/um/sys-x86_64/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ subarch-obj-$(CONFIG_MODULES) += kernel/module.o
1616

1717
ldt-y = ../sys-i386/ldt.o
1818

19-
USER_OBJS := ptrace_user.o sigcontext.o stub_segv.o
19+
USER_OBJS := ptrace_user.o sigcontext.o
2020

2121
USER_OBJS += user-offsets.s
2222
extra-y += user-offsets.s
2323

24-
CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
25-
2624
extra-$(CONFIG_MODE_TT) += unmap.o
2725

26+
UNPROFILE_OBJS := stub_segv.o
27+
CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
28+
2829
include arch/um/scripts/Makefile.rules
2930

30-
$(obj)/stub_segv.o $(obj)/unmap.o: \
31-
_c_flags = $(call unprofile,$(CFLAGS))
31+
$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))

0 commit comments

Comments
 (0)