Skip to main content

discover_plt_thunks

Function discover_plt_thunks 

Source
pub fn discover_plt_thunks(elf: &Elf64File) -> Result<Vec<Function>, PltError>
Expand description

Discover every PLT thunk across .plt, .plt.got, and .plt.sec (IBT-aware variants), and return one Function per entry, named by its imported symbol.

Returns an empty vector when any of the prerequisites is missing (no PLT section at all, or no .rela.plt to resolve names) — those are legitimate ELF shapes for static binaries / shared objects without imports, not errors.

Two entry shapes are recognised:

  • jmp qword ptr [rip+disp32] — the classic PLT entry (.plt, .plt.got).
  • endbr64; jmp qword ptr [rip+disp32]; … — IBT-aware PLT entry (.plt.sec).

Either way, the GOT slot pointed to by the jmp is looked up in the .rela.plt table to recover the import’s name.

.plt’s first entry (the resolver stub) is skipped; the other sections don’t have a resolver entry.