Skip to content

Commit be2f0b1

Browse files
committed
objtool: Get rid of reloc->jump_table_start
Rework the jump table logic slightly so 'jump_table_start' is no longer needed. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 40.37G - After: peak heap memory consumption: 38.64G Link: https://lore.kernel.org/r/e1602ed8a6171ada3cfac0bd8449892ec82bd188.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
1 parent 0696b6e commit be2f0b1

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

tools/objtool/check.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,13 +1989,14 @@ static int add_special_section_alts(struct objtool_file *file)
19891989
}
19901990

19911991
static int add_jump_table(struct objtool_file *file, struct instruction *insn,
1992-
struct reloc *table)
1992+
struct reloc *next_table)
19931993
{
1994-
struct reloc *reloc = table;
1995-
struct instruction *dest_insn;
1996-
struct alternative *alt;
19971994
struct symbol *pfunc = insn_func(insn)->pfunc;
1995+
struct reloc *table = insn_jump_table(insn);
1996+
struct instruction *dest_insn;
19981997
unsigned int prev_offset = 0;
1998+
struct reloc *reloc = table;
1999+
struct alternative *alt;
19992000

20002001
/*
20012002
* Each @reloc is a switch table relocation which points to the target
@@ -2004,7 +2005,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
20042005
for_each_reloc_from(table->sec, reloc) {
20052006

20062007
/* Check for the end of the table: */
2007-
if (reloc != table && reloc->jump_table_start)
2008+
if (reloc != table && reloc == next_table)
20082009
break;
20092010

20102011
/* Make sure the table entries are consecutive: */
@@ -2119,29 +2120,39 @@ static void mark_func_jump_tables(struct objtool_file *file,
21192120
continue;
21202121

21212122
reloc = find_jump_table(file, func, insn);
2122-
if (reloc) {
2123-
reloc->jump_table_start = true;
2123+
if (reloc)
21242124
insn->_jump_table = reloc;
2125-
}
21262125
}
21272126
}
21282127

21292128
static int add_func_jump_tables(struct objtool_file *file,
21302129
struct symbol *func)
21312130
{
2132-
struct instruction *insn;
2133-
int ret;
2131+
struct instruction *insn, *insn_t1 = NULL, *insn_t2;
2132+
int ret = 0;
21342133

21352134
func_for_each_insn(file, func, insn) {
21362135
if (!insn_jump_table(insn))
21372136
continue;
21382137

2139-
ret = add_jump_table(file, insn, insn_jump_table(insn));
2138+
if (!insn_t1) {
2139+
insn_t1 = insn;
2140+
continue;
2141+
}
2142+
2143+
insn_t2 = insn;
2144+
2145+
ret = add_jump_table(file, insn_t1, insn_jump_table(insn_t2));
21402146
if (ret)
21412147
return ret;
2148+
2149+
insn_t1 = insn_t2;
21422150
}
21432151

2144-
return 0;
2152+
if (insn_t1)
2153+
ret = add_jump_table(file, insn_t1, NULL);
2154+
2155+
return ret;
21452156
}
21462157

21472158
/*

tools/objtool/include/objtool/elf.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ struct reloc {
7575
struct section *sec;
7676
struct symbol *sym;
7777
struct list_head sym_reloc_entry;
78-
bool jump_table_start;
7978
};
8079

8180
struct elf {

0 commit comments

Comments
 (0)