Skip to content

Commit 96db4a9

Browse files
author
Peter Zijlstra
committed
objtool: Read the NOENDBR annotation
Read the new NOENDBR annotation. While there, attempt to not bloat struct instruction. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3515899 commit 96db4a9

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

tools/objtool/check.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,29 @@ static int read_unwind_hints(struct objtool_file *file)
18661866
return 0;
18671867
}
18681868

1869+
static int read_noendbr_hints(struct objtool_file *file)
1870+
{
1871+
struct section *sec;
1872+
struct instruction *insn;
1873+
struct reloc *reloc;
1874+
1875+
sec = find_section_by_name(file->elf, ".rela.discard.noendbr");
1876+
if (!sec)
1877+
return 0;
1878+
1879+
list_for_each_entry(reloc, &sec->reloc_list, list) {
1880+
insn = find_insn(file, reloc->sym->sec, reloc->sym->offset + reloc->addend);
1881+
if (!insn) {
1882+
WARN("bad .discard.noendbr entry");
1883+
return -1;
1884+
}
1885+
1886+
insn->noendbr = 1;
1887+
}
1888+
1889+
return 0;
1890+
}
1891+
18691892
static int read_retpoline_hints(struct objtool_file *file)
18701893
{
18711894
struct section *sec;
@@ -2099,6 +2122,10 @@ static int decode_sections(struct objtool_file *file)
20992122
if (ret)
21002123
return ret;
21012124

2125+
ret = read_noendbr_hints(file);
2126+
if (ret)
2127+
return ret;
2128+
21022129
/*
21032130
* Must be before add_{jump_call}_destination.
21042131
*/

tools/objtool/include/objtool/check.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ struct instruction {
4545
unsigned int len;
4646
enum insn_type type;
4747
unsigned long immediate;
48-
bool dead_end, ignore, ignore_alts;
49-
bool hint;
50-
bool retpoline_safe;
48+
49+
u8 dead_end : 1,
50+
ignore : 1,
51+
ignore_alts : 1,
52+
hint : 1,
53+
retpoline_safe : 1,
54+
noendbr : 1;
55+
/* 2 bit hole */
5156
s8 instr;
5257
u8 visited;
58+
/* u8 hole */
59+
5360
struct alt_group *alt_group;
5461
struct symbol *call_dest;
5562
struct instruction *jump_dest;

0 commit comments

Comments
 (0)