Skip to content

Commit 06e2474

Browse files
author
Peter Zijlstra
committed
objtool: Remove annotate_{,un}reachable()
There are no users of annotate_reachable() left. And the annotate_unreachable() usage in unreachable() is plain wrong; it will hide dangerous fall-through code-gen. Remove both. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://lore.kernel.org/r/20241128094312.235637588@infradead.org
1 parent 624bde3 commit 06e2474

File tree

2 files changed

+2
-68
lines changed

2 files changed

+2
-68
lines changed

include/linux/compiler.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,35 +109,9 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
109109

110110
/* Unreachable code */
111111
#ifdef CONFIG_OBJTOOL
112-
/*
113-
* These macros help objtool understand GCC code flow for unreachable code.
114-
* The __COUNTER__ based labels are a hack to make each instance of the macros
115-
* unique, to convince GCC not to merge duplicate inline asm statements.
116-
*/
117-
#define __stringify_label(n) #n
118-
119-
#define __annotate_reachable(c) ({ \
120-
asm volatile(__stringify_label(c) ":\n\t" \
121-
".pushsection .discard.reachable\n\t" \
122-
".long " __stringify_label(c) "b - .\n\t" \
123-
".popsection\n\t"); \
124-
})
125-
#define annotate_reachable() __annotate_reachable(__COUNTER__)
126-
127-
#define __annotate_unreachable(c) ({ \
128-
asm volatile(__stringify_label(c) ":\n\t" \
129-
".pushsection .discard.unreachable\n\t" \
130-
".long " __stringify_label(c) "b - .\n\t" \
131-
".popsection\n\t" : : "i" (c)); \
132-
})
133-
#define annotate_unreachable() __annotate_unreachable(__COUNTER__)
134-
135112
/* Annotate a C jump table to allow objtool to follow the code flow */
136113
#define __annotate_jump_table __section(".rodata..c_jump_table,\"a\",@progbits #")
137-
138114
#else /* !CONFIG_OBJTOOL */
139-
#define annotate_reachable()
140-
#define annotate_unreachable()
141115
#define __annotate_jump_table
142116
#endif /* CONFIG_OBJTOOL */
143117

@@ -147,7 +121,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
147121
* control elsewhere.
148122
*/
149123
#define unreachable() do { \
150-
annotate_unreachable(); \
151124
barrier_before_unreachable(); \
152125
__builtin_unreachable(); \
153126
} while (0)

tools/objtool/check.c

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -638,47 +638,8 @@ static int add_dead_ends(struct objtool_file *file)
638638
uint64_t offset;
639639

640640
/*
641-
* Check for manually annotated dead ends.
642-
*/
643-
rsec = find_section_by_name(file->elf, ".rela.discard.unreachable");
644-
if (!rsec)
645-
goto reachable;
646-
647-
for_each_reloc(rsec, reloc) {
648-
if (reloc->sym->type == STT_SECTION) {
649-
offset = reloc_addend(reloc);
650-
} else if (reloc->sym->local_label) {
651-
offset = reloc->sym->offset;
652-
} else {
653-
WARN("unexpected relocation symbol type in %s", rsec->name);
654-
return -1;
655-
}
656-
657-
insn = find_insn(file, reloc->sym->sec, offset);
658-
if (insn)
659-
insn = prev_insn_same_sec(file, insn);
660-
else if (offset == reloc->sym->sec->sh.sh_size) {
661-
insn = find_last_insn(file, reloc->sym->sec);
662-
if (!insn) {
663-
WARN("can't find unreachable insn at %s+0x%" PRIx64,
664-
reloc->sym->sec->name, offset);
665-
return -1;
666-
}
667-
} else {
668-
WARN("can't find unreachable insn at %s+0x%" PRIx64,
669-
reloc->sym->sec->name, offset);
670-
return -1;
671-
}
672-
673-
insn->dead_end = true;
674-
}
675-
676-
reachable:
677-
/*
678-
* These manually annotated reachable checks are needed for GCC 4.4,
679-
* where the Linux unreachable() macro isn't supported. In that case
680-
* GCC doesn't know the "ud2" is fatal, so it generates code as if it's
681-
* not a dead end.
641+
* UD2 defaults to being a dead-end, allow them to be annotated for
642+
* non-fatal, eg WARN.
682643
*/
683644
rsec = find_section_by_name(file->elf, ".rela.discard.reachable");
684645
if (!rsec)

0 commit comments

Comments
 (0)