Skip to content

Instantly share code, notes, and snippets.

@nickdesaulniers
Last active January 26, 2022 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickdesaulniers/303ef9f42bd6e338b26702c65b5aa5ed to your computer and use it in GitHub Desktop.
Save nickdesaulniers/303ef9f42bd6e338b26702c65b5aa5ed to your computer and use it in GitHub Desktop.
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 84b87538a15d..92acef97d8ed 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -75,9 +75,11 @@ do { \
*/
#define __WARN_FLAGS(flags) \
do { \
+ __label__ reachable; \
instrumentation_begin(); \
_BUG_FLAGS(ASM_UD2, BUGFLAG_WARNING|(flags)); \
- annotate_reachable(); \
+reachable:\
+ annotate_reachable(reachable); \
instrumentation_end(); \
} while (0)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 3ac21b888d20..cbeabbb04728 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -110,11 +110,10 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
/* These macros help objtool understand GCC code flow for unreachable code. */
#ifdef CONFIG_STACK_VALIDATION
-#define annotate_reachable() ({ \
- asm (".Lreachable%=:\n\t" \
- ".pushsection .discard.reachable\n\t" \
- ".long .Lreachable%= - .\n\t" \
- ".popsection\n\t" ::: "memory"); \
+#define annotate_reachable(label) ({ \
+ asm goto (".pushsection .discard.reachable\n\t" \
+ ".long %l0 - .\n\t" \
+ ".popsection\n\t" :::: label); \
})
#define annotate_unreachable() ({ \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment