Lines Matching refs:hdr
34 void SwapElfHeader(Elf32_Ehdr *hdr)
36 hdr->e_type = SwapHalf(hdr->e_type);
37 hdr->e_machine = SwapHalf(hdr->e_machine);
38 hdr->e_version = SwapWord(hdr->e_version);
39 hdr->e_entry = SwapAddr(hdr->e_entry);
40 hdr->e_phoff = SwapOff(hdr->e_phoff);
41 hdr->e_shoff = SwapOff(hdr->e_shoff);
42 hdr->e_flags = SwapWord(hdr->e_flags);
43 hdr->e_ehsize = SwapHalf(hdr->e_ehsize);
44 hdr->e_phentsize = SwapHalf(hdr->e_phentsize);
45 hdr->e_phnum = SwapHalf(hdr->e_phnum);
46 hdr->e_shentsize = SwapHalf(hdr->e_shentsize);
47 hdr->e_shnum = SwapHalf(hdr->e_shnum);
48 hdr->e_shstrndx = SwapHalf(hdr->e_shstrndx);
73 void AdjustElfHeader(Elf32_Ehdr *hdr)
75 switch(hdr->e_ident[EI_DATA])
79 SwapElfHeader(hdr);
83 SwapElfHeader(hdr);
88 void AdjustSectionHeader(Elf32_Ehdr *hdr, Elf32_Shdr *shdr)
90 switch(hdr->e_ident[EI_DATA])
103 void AdjustElfSymbols(Elf32_Ehdr *hdr, Elf32_Sym *elf_symbols, int num_entries)
105 if (hdr->e_ident[EI_DATA] == ELFDATA2LSB && LittleEndian())
107 if (hdr->e_ident[EI_DATA] == ELFDATA2MSB && !LittleEndian())
116 Elf32_Ehdr *hdr = new Elf32_Ehdr;
117 int rval = fread(hdr, sizeof(Elf32_Ehdr), 1, fobj);
119 delete hdr;
122 if (hdr->e_ident[EI_MAG0] != 0x7f || hdr->e_ident[EI_MAG1] != 'E' ||
123 hdr->e_ident[EI_MAG2] != 'L' || hdr->e_ident[EI_MAG3] != 'F') {
124 delete hdr;
127 AdjustElfHeader(hdr);
128 return hdr;
131 Elf32_Shdr *ReadSectionHeaders(Elf32_Ehdr *hdr, FILE *f)
134 unsigned long sz = hdr->e_shnum * hdr->e_shentsize;
135 assert(sizeof(Elf32_Shdr) == hdr->e_shentsize);
136 Elf32_Shdr *shdr = new Elf32_Shdr[hdr->e_shnum];
138 if (fseek(f, hdr->e_shoff, SEEK_SET) != 0)
149 for(i = 0; i < hdr->e_shnum; i++)
150 AdjustSectionHeader(hdr, shdr + i);
156 char *ReadStringTable(Elf32_Ehdr *hdr, Elf32_Shdr *shdr_table, FILE *f)
158 Elf32_Shdr *shdr = shdr_table + hdr->e_shstrndx;
182 Elf32_Shdr *FindSymbolTableSection(Elf32_Ehdr *hdr,
186 for(int ii = 0; ii < hdr->e_shnum; ii++) {
197 Elf32_Shdr *FindSymbolStringTableSection(Elf32_Ehdr *hdr,
201 for(int ii = 0; ii < hdr->e_shnum; ii++) {