@@ -33,6 +33,19 @@ bool arch_support_alt_relocation(struct special_alt *special_alt,
return false;
}
+static struct section *get_switch_table_info_section(struct objtool_file *file)
+{
+ static bool first = true;
+ static struct section *info_section = NULL;
+
+ if (first) {
+ first = false;
+ info_section = find_section_by_name(file->elf,
+ ".discard.switch_table_info");
+ }
+
+ return info_section;
+}
/*
* Aarch64 jump tables are just arrays of offsets (of varying size/signess)
@@ -64,8 +77,7 @@ struct reloc *arch_find_switch_table(struct objtool_file *file,
void *sti_sec_start;
struct reloc *text_reloc;
- table_info_sec = find_section_by_name(file->elf,
- ".discard.switch_table_info");
+ table_info_sec = get_switch_table_info_section(file);
if (!table_info_sec)
goto try_c_jmptbl;
Section ".discard.switch_table_info", created by the gcc plugin will be looked up for every dynamic jump in the object file while the section might not even exist. Cache the result of the first lookup. Signed-off-by: Julien Thierry <jthierry@redhat.com> --- tools/objtool/arch/arm64/special.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)