diff options
Diffstat (limited to 'tools/objtool/elf.c')
-rw-r--r-- | tools/objtool/elf.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 43abae763b3b..8a0a1bc18cd7 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -212,8 +212,8 @@ struct symbol *find_symbol_by_name(struct elf *elf, const char *name) return NULL; } -struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset, - unsigned int len) +struct rela *find_rela_by_dest_range(struct elf *elf, struct section *sec, + unsigned long offset, unsigned int len) { struct rela *rela; unsigned long o; @@ -221,17 +221,22 @@ struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset, if (!sec->rela) return NULL; - for (o = offset; o < offset + len; o++) - hash_for_each_possible(sec->rela->rela_hash, rela, hash, o) - if (rela->offset == o) + sec = sec->rela; + + for (o = offset; o < offset + len; o++) { + hash_for_each_possible(elf->rela_hash, rela, hash, + sec_offset_hash(sec, o)) { + if (rela->sec == sec && rela->offset == o) return rela; + } + } return NULL; } -struct rela *find_rela_by_dest(struct section *sec, unsigned long offset) +struct rela *find_rela_by_dest(struct elf *elf, struct section *sec, unsigned long offset) { - return find_rela_by_dest_range(sec, offset, 1); + return find_rela_by_dest_range(elf, sec, offset, 1); } static int read_sections(struct elf *elf) @@ -261,7 +266,6 @@ static int read_sections(struct elf *elf) INIT_LIST_HEAD(&sec->symbol_list); INIT_LIST_HEAD(&sec->rela_list); - hash_init(sec->rela_hash); s = elf_getscn(elf->elf, i); if (!s) { @@ -493,7 +497,7 @@ static int read_relas(struct elf *elf) } list_add_tail(&rela->list, &sec->rela_list); - hash_add(sec->rela_hash, &rela->hash, rela->offset); + hash_add(elf->rela_hash, &rela->hash, rela_hash(rela)); nr_rela++; } max_rela = max(max_rela, nr_rela); @@ -526,6 +530,7 @@ struct elf *elf_read(const char *name, int flags) hash_init(elf->symbol_name_hash); hash_init(elf->section_hash); hash_init(elf->section_name_hash); + hash_init(elf->rela_hash); INIT_LIST_HEAD(&elf->sections); elf->fd = open(name, flags); @@ -586,7 +591,6 @@ struct section *elf_create_section(struct elf *elf, const char *name, INIT_LIST_HEAD(&sec->symbol_list); INIT_LIST_HEAD(&sec->rela_list); - hash_init(sec->rela_hash); s = elf_newscn(elf->elf); if (!s) { |