Skip to content

Instantly share code, notes, and snippets.

@augustl
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save augustl/ac457256c3947319df5e to your computer and use it in GitHub Desktop.
Save augustl/ac457256c3947319df5e to your computer and use it in GitHub Desktop.
looping
// halt_elf_header *elf_header
void *p = (void *)elf_header + elf_header->e_shoff;
void *end = p + sizeof(halt_elf_section_header) * elf_header->e_shnum;
halt_elf_section_header *section_header;
for (; p < end; p += sizeof(halt_elf_section_header)) {
section_header = p;
}
// halt_elf_header *elf_header
int i;
for (i = 0; i < elf_header->e_shnum; i++) {
halt_elf_section_header *section_header = &((halt_elf_section_header *)((void *)elf_header + elf_header->e_shoff))[i];
}
// halt_elf_header *elf_header
int i;
halt_elf_section_header *section_headers = (halt_elf_section_header *)((void *)elf_header + elf_header->e_shoff);
for (i = 0; i < elf_header->e_shnum; i++) {
halt_elf_section_header *section_header = &section_headers[i];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment