[CRIU] [PATCH 05/23] Makefiles: move -Wa, --noexecstack out of CFLAGS
Kirill Kolyshkin
kir at virtuozzo.com
Tue Oct 18 12:00:05 PDT 2016
On 10/17/2016 01:43 AM, Dmitry Safonov wrote:
>
> 2016-10-14 21:33 GMT+03:00 Kir Kolyshkin <kir at virtuozzo.com><mailto:kir at virtuozzo.com>:
>>
>> On 10/14/2016 11:17 AM, Dmitry Safonov wrote:
>>>
>>> On 10/14/2016 09:15 PM, Kir Kolyshkin wrote:
>>>>
>>>> On 10/14/2016 02:40 AM, Dmitry Safonov wrote:
>>>>>
>>>>> On 10/14/2016 04:42 AM, Kir Kolyshkin wrote:
>>>>>>
>>>>>> On 10/13/2016 05:19 AM, Pavel Emelyanov wrote:
>>>>>>>
>>>>>>> On 10/12/2016 04:46 AM, Kir Kolyshkin wrote:
>>>>>>>>
>>>>>>>> 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.
>>>>>>>
>>>>>>> Cyrill, Dima what would you say?
>>>>>>
>>>>>> 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: diff --git a/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S index 00ccf79..4091680 100644 --- 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. Let me know what you think. Kir.
>>>>>
>>>>> There is also an option to provide this somehow like: %.o: override AFLAGS += -Wa,--noexecstack
>>>>
>>>> That's same (or very similar to) as (2) above (and similar to the way it was done before). Same consequences -- breaks dependency generation with clang.
>>>
>>> No, it will pass AFLAGS only for %.o files, but not for %.d. Anyway again, I don't think it's prettier than ldflags and may need to be more target-specific.
>>
>> I'm afraid it's not the case. Check scripts/nmk/scripts/build.mk, it has this define nmk-asflags $(CFLAGS) $(AFLAGS) $(asflags-y) $(AFLAGS_$(@F)) endef and then $(nmk-asflags) are used for everything that involves .S as a source.
>
> That's ok - `override' directive would make it work for %.o objects only. (Sorry, have answerd outside criu-maillist - from mobile phone).
As far as I understand the meaning of "override" statement in GNU make, it just lets you override the variable given from the command line, that's it. I fail to see how it can be used in a scenario you are talking about. Care to provide a complete example?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20161018/18d92b66/attachment.html>
More information about the CRIU
mailing list