Skip to content

Commit 22c3d58

Browse files
author
Peter Zijlstra
committed
objtool: Convert ANNOTATE_NOENDBR to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2116b34 commit 22c3d58

File tree

4 files changed

+19
-40
lines changed

4 files changed

+19
-40
lines changed

include/linux/objtool.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@
4545
#define STACK_FRAME_NON_STANDARD_FP(func)
4646
#endif
4747

48-
#define ANNOTATE_NOENDBR \
49-
"986: \n\t" \
50-
".pushsection .discard.noendbr\n\t" \
51-
".long 986b\n\t" \
52-
".popsection\n\t"
53-
5448
#define ASM_REACHABLE \
5549
"998:\n\t" \
5650
".pushsection .discard.reachable\n\t" \
@@ -64,6 +58,8 @@
6458
".long " __stringify(type) "\n\t" \
6559
".popsection\n\t"
6660

61+
#define ANNOTATE_NOENDBR ASM_ANNOTATE(ANNOTYPE_NOENDBR)
62+
6763
#else /* __ASSEMBLY__ */
6864

6965
/*
@@ -122,13 +118,6 @@
122118
#endif
123119
.endm
124120

125-
.macro ANNOTATE_NOENDBR
126-
.Lhere_\@:
127-
.pushsection .discard.noendbr
128-
.long .Lhere_\@
129-
.popsection
130-
.endm
131-
132121
/*
133122
* Use objtool to validate the entry requirement that all code paths do
134123
* VALIDATE_UNRET_END before RET.
@@ -161,6 +150,8 @@
161150
.popsection
162151
.endm
163152

153+
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR
154+
164155
#endif /* __ASSEMBLY__ */
165156

166157
#else /* !CONFIG_OBJTOOL */

include/linux/objtool_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ struct unwind_hint {
5454
#define UNWIND_HINT_TYPE_SAVE 6
5555
#define UNWIND_HINT_TYPE_RESTORE 7
5656

57+
/*
58+
* Annotate types
59+
*/
60+
#define ANNOTYPE_NOENDBR 1
61+
5762
#endif /* _LINUX_OBJTOOL_TYPES_H */

tools/include/linux/objtool_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ struct unwind_hint {
5454
#define UNWIND_HINT_TYPE_SAVE 6
5555
#define UNWIND_HINT_TYPE_RESTORE 7
5656

57+
/*
58+
* Annotate types
59+
*/
60+
#define ANNOTYPE_NOENDBR 1
61+
5762
#endif /* _LINUX_OBJTOOL_TYPES_H */

tools/objtool/check.c

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,32 +2412,12 @@ static int read_annotate(struct objtool_file *file, void (*func)(int type, struc
24122412
return 0;
24132413
}
24142414

2415-
static void __annotate_nop(int type, struct instruction *insn)
2415+
static void __annotate_noendbr(int type, struct instruction *insn)
24162416
{
2417-
}
2418-
2419-
static int read_noendbr_hints(struct objtool_file *file)
2420-
{
2421-
struct instruction *insn;
2422-
struct section *rsec;
2423-
struct reloc *reloc;
2424-
2425-
rsec = find_section_by_name(file->elf, ".rela.discard.noendbr");
2426-
if (!rsec)
2427-
return 0;
2428-
2429-
for_each_reloc(rsec, reloc) {
2430-
insn = find_insn(file, reloc->sym->sec,
2431-
reloc->sym->offset + reloc_addend(reloc));
2432-
if (!insn) {
2433-
WARN("bad .discard.noendbr entry");
2434-
return -1;
2435-
}
2436-
2437-
insn->noendbr = 1;
2438-
}
2417+
if (type != ANNOTYPE_NOENDBR)
2418+
return;
24392419

2440-
return 0;
2420+
insn->noendbr = 1;
24412421
}
24422422

24432423
static int read_retpoline_hints(struct objtool_file *file)
@@ -2713,12 +2693,10 @@ static int decode_sections(struct objtool_file *file)
27132693
if (ret)
27142694
return ret;
27152695

2716-
read_annotate(file, __annotate_nop);
2717-
27182696
/*
27192697
* Must be before read_unwind_hints() since that needs insn->noendbr.
27202698
*/
2721-
ret = read_noendbr_hints(file);
2699+
ret = read_annotate(file, __annotate_noendbr);
27222700
if (ret)
27232701
return ret;
27242702

0 commit comments

Comments
 (0)