Skip to content

Commit

Permalink
fixed incorrect plt entry addresses returning for intel 32-bit binari…
Browse files Browse the repository at this point in the history
…es for elf_plt_by_name()
  • Loading branch information
sad0p committed Jan 2, 2023
1 parent d9390a8 commit 017ccba
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ ldd_parse_line(struct elf_shared_object_iterator *iter)
* Same for x86 and i386
*/
#define ELF_RELOC_JUMP_SLOT 7
/*
* Since sh_entsize for 32-bit binaries can't be relied upon for iterating over entries in .plt.
*/
#define PLT_STUB_LEN 16

bool
build_plt_data(struct elfobj *obj)
Expand Down Expand Up @@ -252,7 +256,7 @@ build_plt_data(struct elfobj *obj)
e.data = (void *)plt_node;
hsearch_r(e, ENTER, &ep, &obj->cache.plt);
}
plt_addr = (secure_plt == true) ? plt.address : plt.address + plt.entsize;
plt_addr = (secure_plt == true) ? plt.address : plt.address + PLT_STUB_LEN;
for (;;) {
res = elf_relocation_iterator_next(&r_iter, &r_entry);
if (res == ELF_ITER_ERROR)
Expand All @@ -270,7 +274,7 @@ build_plt_data(struct elfobj *obj)
e.key = (char *)plt_node->symname;
e.data = (void *)plt_node;
hsearch_r(e, ENTER, &ep, &obj->cache.plt);
plt_addr += plt.entsize;
plt_addr += PLT_STUB_LEN;
}
return true;
}
Expand Down

0 comments on commit 017ccba

Please sign in to comment.