Skip to content

Commit 377ccbb

Browse files
committed
Makefile: Mute warning for __builtin_return_address(>0) for tracing only
With the latest gcc compilers, they give a warning if __builtin_return_address() parameter is greater than 0. That is because if it is used by a function called by a top level function (or in the case of the kernel, by assembly), it can try to access stack frames outside the stack and crash the system. The tracing system uses __builtin_return_address() of up to 2! But it is well aware of the dangers that it may have, and has even added precautions to protect against it (see the thunk code in arch/x86/entry/thunk*.S) Linus originally added KBUILD_CFLAGS that would suppress the warning for the entire kernel, as simply adding KBUILD_CFLAGS to the tracing directory wouldn't work. The tracing directory plays a bit with the CFLAGS and requires a little more logic. This adds that special logic to only suppress the warning for the tracing directory. If it is used anywhere else outside of tracing, the warning will still be triggered. Link: http://lkml.kernel.org/r/[email protected] Tested-by: Linus Torvalds <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent b2e1c26 commit 377ccbb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ include arch/$(SRCARCH)/Makefile
620620

621621
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
622622
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
623-
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
624623

625624
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
626625
KBUILD_CFLAGS += -Os

kernel/trace/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
# We are fully aware of the dangers of __builtin_return_address()
3+
FRAME_CFLAGS := $(call cc-disable-warning,frame-address)
4+
KBUILD_CFLAGS += $(FRAME_CFLAGS)
5+
26
# Do not instrument the tracer itself:
37

48
ifdef CONFIG_FUNCTION_TRACER

0 commit comments

Comments
 (0)