Skip to content

Commit 9303ed3

Browse files
kolyshkinxemul
authored andcommitted
Makefiles: move -Wa,--noexecstack out of CFLAGS
The problem is, -Wa is a flag for assembler, but CFLAGS are also used to generate dependencies, and clang complains loudly when it is used for deps: > > DEP compel/arch/x86/plugins/std/syscalls-64.d > > clang-3.8: error: argument unused during compilation: > > '-Wa,--noexecstack' This patch moved the noexecflag from assembler to linker. I am not 100% sure but the end result seems to be the same. This fixes dependency generation when using clang instead of gcc. I surely have done my research before proposing this change, and I have tested this change as good as I could. Sorry, I should have provided more background in the commit message. Here it goes. There are a few ways to have non-executable stack: 1. mark the assembler source file (.S) with .section .note.GNU-stack,"",%progbits 2. pass the -Wa,--noexecstack to compiler 3. pass the -z execstack to linker All three ways are fine, let's see them in greater details. Some people say (1) is the best way, but we have way too many .S files now (23 of them, to be exact). Anyway, I can certainly do it this way if you like, just let me know. It would look like this: --- a/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S +++ b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S @@ -3,6 +3,8 @@ * that are not implemented in the AArch64 Linux kernel */ +.section .note.GNU-stack,"",%progbits + ENTRY(sys_open) mov x3, x2 mov x2, x1 Way (2) is what is currently used. Unfortunately it breaks dependency generation with clang. One way to fix it would be to filter-out the bad flag when we're generating deps. I tried experimenting with $(filter-out) function in Makefiles today but it's complicated and I failed to make it work. Way (3) is what this commit offers. It seem to work fine while being the least intrusive. Signed-off-by: Kir Kolyshkin <[email protected]> Reviewed-by: Cyrill Gorcunov <[email protected]> Reviewed-by: Dmitry Safonov <[email protected]> Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent da31f9d commit 9303ed3

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

compel/plugins/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ asflags-y += -iquote $(PLUGIN_ARCH_DIR)/include
2222
asflags-y += -iquote $(PLUGIN_ARCH_DIR)
2323

2424
# General flags for assembly
25-
asflags-y += -fpie -Wstrict-prototypes -Wa,--noexecstack
25+
asflags-y += -fpie -Wstrict-prototypes
2626
asflags-y += -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
2727
asflags-y += -fno-stack-protector
28+
ldflags-y += -z noexecstack
2829

2930
#
3031
# Fds plugin

criu/pie/Makefile.library

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
target := native
22

33
CFLAGS := $(filter-out -DCONFIG_X86_64,$(CFLAGS))
4-
CFLAGS += -Wa,--noexecstack -fno-stack-protector -DCR_NOGLIBC
4+
CFLAGS += -fno-stack-protector -DCR_NOGLIBC
5+
LDFLAGS += -z noexecstack
56

67
CFLAGS_native += -fpie
78

lib/c/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ obj-y += $(SRC_DIR)/images/rpc.pb-c.o
44
ccflags-y += -iquote $(SRC_DIR)/criu/$(ARCH_DIR)/include
55
ccflags-y += -iquote $(SRC_DIR)/criu/include -iquote $(obj)/..
66
ccflags-y += -iquote $(SRC_DIR)/images
7-
ccflags-y += -fPIC -Wa,--noexecstack -fno-stack-protector
7+
ccflags-y += -fPIC -fno-stack-protector
8+
ldflags-y += -z noexecstack

0 commit comments

Comments
 (0)