/openbmc/linux/kernel/ |
H A D | kexec_elf.c | 24 static inline bool elf_is_elf_file(const struct elfhdr *ehdr) in elf_is_elf_file() argument 26 return memcmp(ehdr->e_ident, ELFMAG, SELFMAG) == 0; in elf_is_elf_file() 29 static uint64_t elf64_to_cpu(const struct elfhdr *ehdr, uint64_t value) in elf64_to_cpu() argument 31 if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) in elf64_to_cpu() 33 else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) in elf64_to_cpu() 39 static uint32_t elf32_to_cpu(const struct elfhdr *ehdr, uint32_t value) in elf32_to_cpu() argument 41 if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) in elf32_to_cpu() 43 else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB) in elf32_to_cpu() 49 static uint16_t elf16_to_cpu(const struct elfhdr *ehdr, uint16_t value) in elf16_to_cpu() argument 51 if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB) in elf16_to_cpu() [all …]
|
H A D | kexec_file.c | 819 sechdrs = (void *)pi->ehdr + pi->ehdr->e_shoff; in kexec_purgatory_setup_kbuf() 823 for (i = 0; i < pi->ehdr->e_shnum; i++) { in kexec_purgatory_setup_kbuf() 884 sechdrs_size = array_size(sizeof(Elf_Shdr), pi->ehdr->e_shnum); in kexec_purgatory_setup_sechdrs() 888 memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff, sechdrs_size); in kexec_purgatory_setup_sechdrs() 893 kbuf->image->start = pi->ehdr->e_entry; in kexec_purgatory_setup_sechdrs() 895 for (i = 0; i < pi->ehdr->e_shnum; i++) { in kexec_purgatory_setup_sechdrs() 923 pi->ehdr->e_entry >= sechdrs[i].sh_addr && in kexec_purgatory_setup_sechdrs() 924 pi->ehdr->e_entry < (sechdrs[i].sh_addr in kexec_purgatory_setup_sechdrs() 926 !WARN_ON(kbuf->image->start != pi->ehdr->e_entry)) { in kexec_purgatory_setup_sechdrs() 931 src = (void *)pi->ehdr + sechdrs[i].sh_offset; in kexec_purgatory_setup_sechdrs() [all …]
|
/openbmc/linux/arch/s390/kernel/ |
H A D | kexec_elf.c | 20 const Elf_Ehdr *ehdr; in kexec_file_add_kernel_elf() local 27 ehdr = (Elf_Ehdr *)kernel; in kexec_file_add_kernel_elf() 32 entry = ehdr->e_entry; in kexec_file_add_kernel_elf() 34 phdr = (void *)ehdr + ehdr->e_phoff; in kexec_file_add_kernel_elf() 35 for (i = 0; i < ehdr->e_phnum; i++, phdr++) { in kexec_file_add_kernel_elf() 71 const Elf_Ehdr *ehdr; in s390_elf_load() local 77 ehdr = (Elf_Ehdr *)kernel; in s390_elf_load() 79 if (ehdr->e_type != ET_EXEC || in s390_elf_load() 80 ehdr->e_ident[EI_CLASS] != ELFCLASS64 || in s390_elf_load() 81 !elf_check_arch(ehdr)) in s390_elf_load() [all …]
|
/openbmc/linux/arch/mips/boot/tools/ |
H A D | relocs.c | 14 static Elf_Ehdr ehdr; variable 96 sec_strtab = secs[ehdr.e_shstrndx].strtab; in sec_name() 97 if (shndx < ehdr.e_shnum) in sec_name() 112 for (i = 0; i < ehdr.e_shnum; i++) in sec_lookup() 163 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf16_to_cpu() 171 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf32_to_cpu() 179 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in cpu_to_elf32() 191 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf64_to_cpu() 207 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) in read_ehdr() 210 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) in read_ehdr() [all …]
|
/openbmc/u-boot/cmd/ |
H A D | elf.c | 37 Elf64_Ehdr *ehdr; /* Elf header structure pointer */ in load_elf64_image_phdr() local 41 ehdr = (Elf64_Ehdr *)addr; in load_elf64_image_phdr() 42 phdr = (Elf64_Phdr *)(addr + (ulong)ehdr->e_phoff); in load_elf64_image_phdr() 45 for (i = 0; i < ehdr->e_phnum; ++i) { in load_elf64_image_phdr() 61 if (ehdr->e_machine == EM_PPC64 && (ehdr->e_flags & in load_elf64_image_phdr() 68 uintptr_t addr = ehdr->e_entry; in load_elf64_image_phdr() 73 return ehdr->e_entry; in load_elf64_image_phdr() 78 Elf64_Ehdr *ehdr; /* Elf header structure pointer */ in load_elf64_image_shdr() local 84 ehdr = (Elf64_Ehdr *)addr; in load_elf64_image_shdr() 87 shdr = (Elf64_Shdr *)(addr + (ulong)ehdr->e_shoff + in load_elf64_image_shdr() [all …]
|
/openbmc/linux/tools/perf/util/ |
H A D | symbol-minimal.c | 116 Elf32_Ehdr ehdr; in filename__read_build_id() local 119 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) in filename__read_build_id() 123 ehdr.e_phoff = bswap_32(ehdr.e_phoff); in filename__read_build_id() 124 ehdr.e_phentsize = bswap_16(ehdr.e_phentsize); in filename__read_build_id() 125 ehdr.e_phnum = bswap_16(ehdr.e_phnum); in filename__read_build_id() 128 buf_size = ehdr.e_phentsize * ehdr.e_phnum; in filename__read_build_id() 133 fseek(fp, ehdr.e_phoff, SEEK_SET); in filename__read_build_id() 137 for (i = 0, phdr = buf; i < ehdr.e_phnum; i++, phdr++) { in filename__read_build_id() 167 Elf64_Ehdr ehdr; in filename__read_build_id() local 170 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) in filename__read_build_id() [all …]
|
H A D | symbol-elf.c | 70 GElf_Ehdr *ehdr; in elf_getphdrnum() local 72 ehdr = gelf_getehdr(elf, &gehdr); in elf_getphdrnum() 73 if (!ehdr) in elf_getphdrnum() 76 *dst = ehdr->e_phnum; in elf_getphdrnum() 229 GElf_Ehdr ehdr; in filename__has_section() local 241 if (gelf_getehdr(elf, &ehdr) == NULL) in filename__has_section() 244 found = !!elf_section_by_name(elf, &ehdr, &shdr, sec, NULL); in filename__has_section() 396 static bool addend_may_be_ifunc(GElf_Ehdr *ehdr, struct rel_info *ri) in addend_may_be_ifunc() argument 398 return ehdr->e_machine == EM_X86_64 && ri->is_rela && in addend_may_be_ifunc() 402 static bool get_ifunc_name(Elf *elf, struct dso *dso, GElf_Ehdr *ehdr, in get_ifunc_name() argument [all …]
|
/openbmc/linux/scripts/ |
H A D | recordmcount.h | 211 static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) in get_shnum() argument 213 if (shdr0 && !ehdr->e_shnum) in get_shnum() 216 return w2(ehdr->e_shnum); in get_shnum() 219 static void set_shnum(Elf_Ehdr *ehdr, Elf_Shdr *shdr0, unsigned int new_shnum) in set_shnum() argument 222 ehdr->e_shnum = 0; in set_shnum() 225 ehdr->e_shnum = w2(new_shnum); in set_shnum() 228 static int get_shstrndx(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0) in get_shstrndx() argument 230 if (ehdr->e_shstrndx != SHN_XINDEX) in get_shstrndx() 231 return w2(ehdr->e_shstrndx); in get_shstrndx() 236 static void find_symtab(Elf_Ehdr *const ehdr, Elf_Shdr const *shdr0, in find_symtab() argument [all …]
|
H A D | sorttable.c | 271 Elf32_Ehdr *ehdr = addr; in do_file() local 274 switch (ehdr->e_ident[EI_DATA]) { in do_file() 293 ehdr->e_ident[EI_DATA], fname); in do_file() 297 if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 || in do_file() 298 (r2(&ehdr->e_type) != ET_EXEC && r2(&ehdr->e_type) != ET_DYN) || in do_file() 299 ehdr->e_ident[EI_VERSION] != EV_CURRENT) { in do_file() 304 switch (r2(&ehdr->e_machine)) { in do_file() 327 r2(&ehdr->e_machine), fname); in do_file() 331 switch (ehdr->e_ident[EI_CLASS]) { in do_file() 333 if (r2(&ehdr->e_ehsize) != sizeof(Elf32_Ehdr) || in do_file() [all …]
|
H A D | sorttable.h | 208 Elf_Ehdr *ehdr; member 221 unsigned char *start_loc = (void *)emloc->ehdr + offset; in sort_mcount_loc() 264 static int do_sort(Elf_Ehdr *ehdr, in do_sort() argument 269 Elf_Shdr *s, *shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff)); in do_sort() 300 shstrndx = r2(&ehdr->e_shstrndx); in do_sort() 303 secstrings = (const char *)ehdr + _r(&shdr[shstrndx].sh_offset); in do_sort() 305 shnum = r2(&ehdr->e_shnum); in do_sort() 323 relocs = (void *)ehdr + _r(&s->sh_offset); in do_sort() 327 symtab_shndx = (Elf32_Word *)((const char *)ehdr + in do_sort() 334 mstruct.ehdr = ehdr; in do_sort() [all …]
|
H A D | recordmcount.c | 514 Elf32_Ehdr *ehdr; in do_file() local 517 ehdr = mmap_file(fname); in do_file() 518 if (!ehdr) in do_file() 524 switch (ehdr->e_ident[EI_DATA]) { in do_file() 528 ehdr->e_ident[EI_DATA], fname); in do_file() 557 if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 || in do_file() 558 w2(ehdr->e_type) != ET_REL || in do_file() 559 ehdr->e_ident[EI_VERSION] != EV_CURRENT) { in do_file() 565 switch (w2(ehdr->e_machine)) { in do_file() 568 w2(ehdr->e_machine), fname); in do_file() [all …]
|
/openbmc/linux/drivers/remoteproc/ |
H A D | remoteproc_coredump.c | 239 void *ehdr; in rproc_coredump() local 275 ehdr = data; in rproc_coredump() 277 memset(ehdr, 0, elf_size_of_hdr(class)); in rproc_coredump() 279 elf_hdr_init_ident(ehdr, class); in rproc_coredump() 281 elf_hdr_set_e_type(class, ehdr, ET_CORE); in rproc_coredump() 282 elf_hdr_set_e_machine(class, ehdr, rproc->elf_machine); in rproc_coredump() 283 elf_hdr_set_e_version(class, ehdr, EV_CURRENT); in rproc_coredump() 284 elf_hdr_set_e_entry(class, ehdr, rproc->bootaddr); in rproc_coredump() 285 elf_hdr_set_e_phoff(class, ehdr, elf_size_of_hdr(class)); in rproc_coredump() 286 elf_hdr_set_e_ehsize(class, ehdr, elf_size_of_hdr(class)); in rproc_coredump() [all …]
|
H A D | remoteproc_elf_loader.c | 46 struct elf32_hdr *ehdr; local 62 ehdr = (struct elf32_hdr *)fw->data; 64 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) { 69 class = ehdr->e_ident[EI_CLASS]; 82 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) { 84 if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) { 163 const void *ehdr, *phdr; local 170 ehdr = elf_data; 171 phnum = elf_hdr_get_e_phnum(class, ehdr); 172 phdr = elf_data + elf_hdr_get_e_phoff(class, ehdr); [all …]
|
/openbmc/linux/drivers/soc/qcom/ |
H A D | mdt_loader.c | 82 const struct elf32_hdr *ehdr; in qcom_mdt_get_size() local 87 ehdr = (struct elf32_hdr *)fw->data; in qcom_mdt_get_size() 88 phdrs = (struct elf32_phdr *)(ehdr + 1); in qcom_mdt_get_size() 90 for (i = 0; i < ehdr->e_phnum; i++) { in qcom_mdt_get_size() 130 const struct elf32_hdr *ehdr; in qcom_mdt_read_metadata() local 139 ehdr = (struct elf32_hdr *)fw->data; in qcom_mdt_read_metadata() 140 phdrs = (struct elf32_phdr *)(ehdr + 1); in qcom_mdt_read_metadata() 142 if (ehdr->e_phnum < 2) in qcom_mdt_read_metadata() 148 for (i = 1; i < ehdr->e_phnum; i++) { in qcom_mdt_read_metadata() 210 const struct elf32_hdr *ehdr; in qcom_mdt_pas_init() local [all …]
|
/openbmc/qemu/include/hw/ |
H A D | elf_ops.h.inc | 1 static void glue(bswap_ehdr, SZ)(struct elfhdr *ehdr) 3 bswap16s(&ehdr->e_type); /* Object file type */ 4 bswap16s(&ehdr->e_machine); /* Architecture */ 5 bswap32s(&ehdr->e_version); /* Object file version */ 6 bswapSZs(&ehdr->e_entry); /* Entry point virtual address */ 7 bswapSZs(&ehdr->e_phoff); /* Program header table file offset */ 8 bswapSZs(&ehdr->e_shoff); /* Section header table file offset */ 9 bswap32s(&ehdr->e_flags); /* Processor-specific flags */ 10 bswap16s(&ehdr->e_ehsize); /* ELF header size in bytes */ 11 bswap16s(&ehdr->e_phentsize); /* Program header table entry size */ [all …]
|
/openbmc/qemu/contrib/elf2dmp/ |
H A D | qemu_elf.c | 26 Elf64_Ehdr *ehdr = map; in elf64_getphdr() local 27 Elf64_Phdr *phdr = (void *)((uint8_t *)map + ehdr->e_phoff); in elf64_getphdr() 34 Elf64_Ehdr *ehdr = map; in elf_getphdrnum() local 36 return ehdr->e_phnum; in elf_getphdrnum() 134 Elf64_Ehdr *ehdr = qe->map; in check_ehdr() local 142 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) { in check_ehdr() 147 if (ehdr->e_ident[EI_CLASS] != ELFCLASS64 || in check_ehdr() 148 ehdr->e_ident[EI_DATA] != ELFDATA2LSB) { in check_ehdr() 153 if (ehdr->e_ident[EI_VERSION] != EV_CURRENT) { in check_ehdr() 158 if (ehdr->e_machine != EM_X86_64) { in check_ehdr() [all …]
|
/openbmc/linux/arch/x86/tools/ |
H A D | relocs.c | 14 static Elf_Ehdr ehdr; variable 368 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) { in read_ehdr() 372 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) { in read_ehdr() 375 if (ehdr.e_ident[EI_CLASS] != ELF_CLASS) { in read_ehdr() 378 if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) { in read_ehdr() 381 if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) { in read_ehdr() 385 ehdr.e_type = elf_half_to_cpu(ehdr.e_type); in read_ehdr() 386 ehdr.e_machine = elf_half_to_cpu(ehdr.e_machine); in read_ehdr() 387 ehdr.e_version = elf_word_to_cpu(ehdr.e_version); in read_ehdr() 388 ehdr.e_entry = elf_addr_to_cpu(ehdr.e_entry); in read_ehdr() [all …]
|
/openbmc/linux/lib/ |
H A D | buildid.c | 78 Elf32_Ehdr *ehdr = (Elf32_Ehdr *)page_addr; in get_build_id_32() local 87 if (ehdr->e_phoff != sizeof(Elf32_Ehdr)) in get_build_id_32() 90 phnum = READ_ONCE(ehdr->e_phnum); in get_build_id_32() 111 Elf64_Ehdr *ehdr = (Elf64_Ehdr *)page_addr; in get_build_id_64() local 120 if (ehdr->e_phoff != sizeof(Elf64_Ehdr)) in get_build_id_64() 123 phnum = READ_ONCE(ehdr->e_phnum); in get_build_id_64() 151 Elf32_Ehdr *ehdr; in build_id_parse() local 170 ehdr = (Elf32_Ehdr *)page_addr; in build_id_parse() 173 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) in build_id_parse() 177 if (ehdr->e_type != ET_EXEC && ehdr->e_type != ET_DYN) in build_id_parse() [all …]
|
/openbmc/qemu/linux-user/ |
H A D | gen-vdso-elfn.c.inc | 10 static void elfN(bswap_ehdr)(ElfN(Ehdr) *ehdr) 12 bswaps(&ehdr->e_type); /* Object file type */ 13 bswaps(&ehdr->e_machine); /* Architecture */ 14 bswaps(&ehdr->e_version); /* Object file version */ 15 bswaps(&ehdr->e_entry); /* Entry point virtual address */ 16 bswaps(&ehdr->e_phoff); /* Program header table file offset */ 17 bswaps(&ehdr->e_shoff); /* Section header table file offset */ 18 bswaps(&ehdr->e_flags); /* Processor-specific flags */ 19 bswaps(&ehdr->e_ehsize); /* ELF header size in bytes */ 20 bswaps(&ehdr->e_phentsize); /* Program header table entry size */ [all …]
|
/openbmc/linux/drivers/s390/crypto/ |
H A D | zcrypt_error.h | 81 struct error_hdr *ehdr = reply->msg; in convert_error() local 85 switch (ehdr->reply_code) { in convert_error() 102 __func__, card, queue, ehdr->reply_code); in convert_error() 113 if (ehdr->reply_code == REP82_ERROR_TRANSPORT_FAIL && in convert_error() 114 ehdr->type == TYPE86_RSP_CODE) { in convert_error() 123 __func__, card, queue, ehdr->reply_code, apfs); in convert_error() 127 ehdr->reply_code); in convert_error() 133 __func__, card, queue, ehdr->reply_code); in convert_error()
|
/openbmc/linux/arch/mips/vdso/ |
H A D | genvdso.h | 9 const ELF(Ehdr) *ehdr = vdso; in FUNC() 15 shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff); in FUNC() 16 sh_count = swap_uint16(ehdr->e_shnum); in FUNC() 17 sh_entsize = swap_uint16(ehdr->e_shentsize); in FUNC() 19 shdr = shdrs + (sh_entsize * swap_uint16(ehdr->e_shstrndx)); in FUNC() 60 const ELF(Ehdr) *ehdr = vdso; in FUNC() 69 shdrs = vdso + FUNC(swap_uint)(ehdr->e_shoff); in FUNC() 70 sh_count = swap_uint16(ehdr->e_shnum); in FUNC() 71 sh_entsize = swap_uint16(ehdr->e_shentsize); in FUNC() 87 flags = swap_uint32(ehdr->e_flags); in FUNC()
|
/openbmc/linux/arch/arm64/kvm/hyp/nvhe/ |
H A D | gen-hyprel.c | 134 Elf64_Ehdr *ehdr; member 202 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var) 276 assert_ge(stat.st_size, sizeof(*elf.ehdr), "%lu"); in init_elf() 277 elf.ehdr = elf_ptr(Elf64_Ehdr, 0); in init_elf() 280 assert_eq(elf.ehdr->e_ident[EI_MAG0], ELFMAG0, "0x%x"); in init_elf() 281 assert_eq(elf.ehdr->e_ident[EI_MAG1], ELFMAG1, "0x%x"); in init_elf() 282 assert_eq(elf.ehdr->e_ident[EI_MAG2], ELFMAG2, "0x%x"); in init_elf() 283 assert_eq(elf.ehdr->e_ident[EI_MAG3], ELFMAG3, "0x%x"); in init_elf() 286 assert_eq(elf.ehdr->e_ident[EI_CLASS], ELFCLASS64, "%u"); in init_elf() 287 assert_eq(elf.ehdr->e_ident[EI_DATA], ELFENDIAN, "%u"); in init_elf() [all …]
|
/openbmc/linux/arch/parisc/boot/compressed/ |
H A D | misc.c | 236 Elf64_Ehdr ehdr; in parse_elf() local 239 Elf32_Ehdr ehdr; in parse_elf() 245 memcpy(&ehdr, output, sizeof(ehdr)); in parse_elf() 246 if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || in parse_elf() 247 ehdr.e_ident[EI_MAG1] != ELFMAG1 || in parse_elf() 248 ehdr.e_ident[EI_MAG2] != ELFMAG2 || in parse_elf() 249 ehdr.e_ident[EI_MAG3] != ELFMAG3) { in parse_elf() 258 phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); in parse_elf() 262 memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); in parse_elf() 264 for (i = 0; i < ehdr.e_phnum; i++) { in parse_elf()
|
/openbmc/linux/tools/testing/selftests/powerpc/ptrace/ |
H A D | core-pkey.c | 195 static int check_core_file(struct shared_info *info, Elf64_Ehdr *ehdr, in check_core_file() argument 202 void *p = ehdr, *note; in check_core_file() 205 ret = memcmp(ehdr->e_ident, ELFMAG, SELFMAG); in check_core_file() 208 FAIL_IF(ehdr->e_type != ET_CORE); in check_core_file() 209 FAIL_IF(ehdr->e_machine != EM_PPC64); in check_core_file() 210 FAIL_IF(ehdr->e_phoff == 0 || ehdr->e_phnum == 0); in check_core_file() 216 phdr_size = sizeof(*phdr) * ehdr->e_phnum; in check_core_file() 219 FAIL_IF(ehdr->e_phoff + phdr_size < ehdr->e_phoff); in check_core_file() 220 FAIL_IF(ehdr->e_phoff + phdr_size > core_size); in check_core_file() 223 for (phdr = p + ehdr->e_phoff; in check_core_file() [all …]
|
/openbmc/linux/arch/x86/boot/compressed/ |
H A D | misc.c | 283 Elf64_Ehdr ehdr; in parse_elf() local 286 Elf32_Ehdr ehdr; in parse_elf() 292 memcpy(&ehdr, output, sizeof(ehdr)); in parse_elf() 293 if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || in parse_elf() 294 ehdr.e_ident[EI_MAG1] != ELFMAG1 || in parse_elf() 295 ehdr.e_ident[EI_MAG2] != ELFMAG2 || in parse_elf() 296 ehdr.e_ident[EI_MAG3] != ELFMAG3) in parse_elf() 301 phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); in parse_elf() 305 memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); in parse_elf() 307 for (i = 0; i < ehdr.e_phnum; i++) { in parse_elf() [all …]
|