MCPcopy Create free account
hub / github.com/GJDuck/e9patch / parseGOT

Function parseGOT

src/e9tool/e9frontend.cpp:783–806  ·  view source on GitHub ↗

* Parse the Global Offset Table (GOT). */

Source from the content-addressed store, hash-verified

781 * Parse the Global Offset Table (GOT).
782 */
783static void parseGOT(const uint8_t *data, const Elf64_Shdr *shdr_got,
784 const Elf64_Shdr *shdr_rela_got, const Elf64_Sym *dynsym_tab,
785 size_t dynsym_num, const char *dynstr_tab, size_t dynstr_len,
786 GOTInfo &got)
787{
788 const Elf64_Rela *rela_tab =
789 (const Elf64_Rela *)(data + shdr_rela_got->sh_offset);
790 size_t rela_num = shdr_rela_got->sh_size / sizeof(Elf64_Rela);
791 for (size_t i = 0; i < rela_num; i++)
792 {
793 const Elf64_Rela *rela = rela_tab + i;
794 if (rela->r_offset < shdr_got->sh_addr ||
795 rela->r_offset >= shdr_got->sh_addr + shdr_got->sh_size)
796 continue;
797 size_t idx = (size_t)ELF64_R_SYM(rela->r_info);
798 if (idx >= dynsym_num)
799 continue;
800 const Elf64_Sym *sym = dynsym_tab + idx;
801 const char *name = parseName(dynstr_tab, dynstr_len, sym->st_name);
802 if (name == nullptr || sym->st_shndx != SHN_UNDEF)
803 continue;
804 got.insert({name, rela->r_offset});
805 }
806}
807
808/*
809 * Parse the Procedure Linkage Table (PLT).

Callers 1

parseELFMethod · 0.85

Calls 1

parseNameFunction · 0.85

Tested by

no test coverage detected