提交 bac2279c 编写于 作者: Y yinchuang

Add cache for relocation

Signed-off-by: Nyinchuang <yinchuang@huawei.com>
上级 dec5ecd3
...@@ -112,6 +112,10 @@ struct dso { ...@@ -112,6 +112,10 @@ struct dso {
/* mark the dso status */ /* mark the dso status */
unsigned int flags; unsigned int flags;
int cache_sym_index;
struct dso *cache_dso;
Sym *cache_sym;
Phdr *phdr; Phdr *phdr;
int phnum; int phnum;
size_t phentsize; size_t phentsize;
...@@ -954,10 +958,18 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri ...@@ -954,10 +958,18 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
ctx = type==REL_COPY ? head->syms_next : head; ctx = type==REL_COPY ? head->syms_next : head;
struct verinfo vinfo = { .s = name, .v = "" }; struct verinfo vinfo = { .s = name, .v = "" };
vinfo.use_vna_hash = get_vna_hash(dso, sym_index, &vinfo.vna_hash); vinfo.use_vna_hash = get_vna_hash(dso, sym_index, &vinfo.vna_hash);
def = (sym->st_info>>4) == STB_LOCAL if (dso->cache_sym_index == sym_index) {
? (struct symdef){ .dso = dso, .sym = sym } def = (struct symdef){ .dso = dso->cache_dso, .sym = dso->cache_sym };
: dso != &ldso ? find_sym_by_saved_so_list(type, ctx, &vinfo, type==REL_PLT, dso) } else {
: find_sym2(ctx, &vinfo, type==REL_PLT, 0, dso->namespace); def = (sym->st_info>>4) == STB_LOCAL
? (struct symdef){ .dso = dso, .sym = sym }
: dso != &ldso ? find_sym_by_saved_so_list(type, ctx, &vinfo, type==REL_PLT, dso)
: find_sym2(ctx, &vinfo, type==REL_PLT, 0, dso->namespace);
dso->cache_sym_index = sym_index;
dso->cache_dso = def.dso;
dso->cache_sym = def.sym;
}
if (!def.sym && (sym->st_shndx != SHN_UNDEF if (!def.sym && (sym->st_shndx != SHN_UNDEF
|| sym->st_info>>4 != STB_WEAK)) { || sym->st_info>>4 != STB_WEAK)) {
if (dso->lazy && (type==REL_PLT || type==REL_GOT)) { if (dso->lazy && (type==REL_PLT || type==REL_GOT)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册