objtool: Optimize find_symbol_*() and read_symbols()
All of: read_symbols(), find_symbol_by_offset(), find_symbol_containing(), find_containing_func() do a linear search of the symbols. Add an RB tree to make it go faster. This about halves objtool runtime on vmlinux.o, from 34s to 18s. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lkml.kernel.org/r/20200324160924.499016559@infradead.org
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <gelf.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/hashtable.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/jhash.h>
|
||||
|
||||
#ifdef LIBELF_USE_DEPRECATED
|
||||
@@ -29,6 +30,7 @@ struct section {
|
||||
struct hlist_node hash;
|
||||
struct hlist_node name_hash;
|
||||
GElf_Shdr sh;
|
||||
struct rb_root symbol_tree;
|
||||
struct list_head symbol_list;
|
||||
struct list_head rela_list;
|
||||
DECLARE_HASHTABLE(rela_hash, 16);
|
||||
@@ -43,6 +45,7 @@ struct section {
|
||||
|
||||
struct symbol {
|
||||
struct list_head list;
|
||||
struct rb_node node;
|
||||
struct hlist_node hash;
|
||||
GElf_Sym sym;
|
||||
struct section *sec;
|
||||
|
Reference in New Issue
Block a user