lkml.org 
[lkml]   [2021]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 14/17] objtool: arm64: Cache section with switch table information
Date
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(-)

diff --git a/tools/objtool/arch/arm64/special.c b/tools/objtool/arch/arm64/special.c
index 396b9c5feebd..c9c3e0bfd581 100644
--- a/tools/objtool/arch/arm64/special.c
+++ b/tools/objtool/arch/arm64/special.c
@@ -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;

--
2.25.4
\
 
 \ /
  Last update: 2021-01-20 19:55    [W:0.794 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site