Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/asm: Make objtool unreachable macros independent from GCC version

The ASM_UNREACHABLE macro isn't GCC version-specific, so move it outside
the GCC 4.5+ check. Otherwise the 0-day robot will report objtool
warnings for uses of ASM_UNREACHABLE with GCC 4.4.

Also move the annotate_unreachable() macro so the related macros can
stay together.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: aa5d1b81500e ("x86/asm: Add ASM_UNREACHABLE")
Link: http://lkml.kernel.org/r/fb18337dbf230fd36450d9faf19a2b2533dbcba1.1500993873.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
1ee6f00d aa5d1b81

+16 -16
+16 -16
include/linux/compiler-gcc.h
··· 128 128 #define __always_unused __attribute__((unused)) 129 129 #define __mode(x) __attribute__((mode(x))) 130 130 131 + #ifdef CONFIG_STACK_VALIDATION 132 + #define annotate_unreachable() ({ \ 133 + asm("%c0:\n\t" \ 134 + ".pushsection .discard.unreachable\n\t" \ 135 + ".long %c0b - .\n\t" \ 136 + ".popsection\n\t" : : "i" (__LINE__)); \ 137 + }) 138 + #define ASM_UNREACHABLE \ 139 + "999:\n\t" \ 140 + ".pushsection .discard.unreachable\n\t" \ 141 + ".long 999b - .\n\t" \ 142 + ".popsection\n\t" 143 + #else 144 + #define annotate_unreachable() 145 + #endif 146 + 131 147 /* gcc version specific checks */ 132 148 133 149 #if GCC_VERSION < 30200 ··· 215 199 #ifdef LATENT_ENTROPY_PLUGIN 216 200 #define __latent_entropy __attribute__((latent_entropy)) 217 201 #endif 218 - #endif 219 - 220 - #ifdef CONFIG_STACK_VALIDATION 221 - #define annotate_unreachable() ({ \ 222 - asm("%c0:\n\t" \ 223 - ".pushsection .discard.unreachable\n\t" \ 224 - ".long %c0b - .\n\t" \ 225 - ".popsection\n\t" : : "i" (__LINE__)); \ 226 - }) 227 - #define ASM_UNREACHABLE \ 228 - "999:\n\t" \ 229 - ".pushsection .discard.unreachable\n\t" \ 230 - ".long 999b - .\n\t" \ 231 - ".popsection\n\t" 232 - #else 233 - #define annotate_unreachable() 234 202 #endif 235 203 236 204 /*