| /linux/arch/s390/tools/ |
| H A D | relocs.c | 41 static Elf_Ehdr ehdr; variable 82 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf16_to_cpu() 90 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf32_to_cpu() 120 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) in read_ehdr() 122 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) in read_ehdr() 124 if (ehdr.e_ident[EI_CLASS] != ELF_CLASS) in read_ehdr() 126 if (ehdr.e_ident[EI_DATA] != ELF_ENDIAN) in read_ehdr() 128 if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) in read_ehdr() 132 ehdr.e_type = elf_half_to_cpu(ehdr.e_type); in read_ehdr() 133 ehdr.e_machine = elf_half_to_cpu(ehdr.e_machine); in read_ehdr() [all …]
|
| /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() 73 const Elf_Ehdr *ehdr; in s390_elf_load() local 79 ehdr = (Elf_Ehdr *)kernel; in s390_elf_load() 81 if (ehdr->e_type != ET_EXEC || in s390_elf_load() 82 ehdr->e_ident[EI_CLASS] != ELFCLASS64 || in s390_elf_load() 83 !elf_check_arch(ehdr)) in s390_elf_load() [all …]
|
| /linux/arch/mips/boot/tools/ |
| H A D | relocs.c | 14 static Elf_Ehdr ehdr; variable 97 sec_strtab = secs[ehdr.e_shstrndx].strtab; in sec_name() 98 if (shndx < ehdr.e_shnum) in sec_name() 113 for (i = 0; i < ehdr.e_shnum; i++) in sec_lookup() 164 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf16_to_cpu() 172 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf32_to_cpu() 180 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in cpu_to_elf32() 192 if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) in elf64_to_cpu() 208 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) in read_ehdr() 211 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) in read_ehdr() [all …]
|
| /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 | tracepoint-update.c | 34 Elf_Ehdr *ehdr; member 74 #define for_each_shdr_str(len, ehdr, sec) \ argument 75 for (const char *str = (void *)(ehdr) + shdr_offset(sec), \ 83 Elf_Ehdr *ehdr = etrace->ehdr; in make_trace_array() local 95 for_each_shdr_str(len, ehdr, check_data_sec) { in make_trace_array() 119 Elf_Ehdr *ehdr = etrace->ehdr; in check_tracepoints() local 130 for_each_shdr_str(len, ehdr, tracepoint_data_sec) { in check_tracepoints() 156 Elf_Ehdr *ehdr = addr; in process_tracepoints() local 166 shdr_start = (Elf_Shdr *)((char *)ehdr + ehdr_shoff(ehdr)); in process_tracepoints() 167 shentsize = ehdr_shentsize(ehdr); in process_tracepoints() [all …]
|
| H A D | elf-parse.c | 57 Elf_Ehdr *ehdr = addr; in elf_parse() local 60 switch (ehdr->e32.e_ident[EI_DATA]) { in elf_parse() 77 ehdr->e32.e_ident[EI_DATA], fname); in elf_parse() 81 if (memcmp(ELFMAG, ehdr->e32.e_ident, SELFMAG) != 0 || in elf_parse() 82 ehdr->e32.e_ident[EI_VERSION] != EV_CURRENT) { in elf_parse() 87 type = elf_parser.r2(&ehdr->e32.e_type); in elf_parse() 93 switch (ehdr->e32.e_ident[EI_CLASS]) { in elf_parse() 115 if (elf_parser.r2(&ehdr->e32.e_ehsize) != sizeof(Elf32_Ehdr) || in elf_parse() 116 elf_parser.r2(&ehdr->e32.e_shentsize) != sizeof(Elf32_Shdr)) { in elf_parse() 145 if (elf_parser.r2(&ehdr->e64.e_ehsize) != sizeof(Elf64_Ehdr) || in elf_parse() [all …]
|
| H A D | sorttable.c | 353 Elf_Ehdr *ehdr; member 360 static int fill_relocs(void *ptr, uint64_t size, Elf_Ehdr *ehdr, uint64_t start_loc) in fill_relocs() argument 369 shdr_start = (Elf_Shdr *)((char *)ehdr + ehdr_shoff(ehdr)); in fill_relocs() 370 shentsize = ehdr_shentsize(ehdr); in fill_relocs() 372 shnum = ehdr_shnum(ehdr); in fill_relocs() 383 rel = (void *)ehdr + shdr_offset(shdr); in fill_relocs() 417 static void replace_relocs(void *ptr, uint64_t size, Elf_Ehdr *ehdr, uint64_t start_loc) in replace_relocs() argument 424 shdr_start = (Elf_Shdr *)((char *)ehdr + ehdr_shoff(ehdr)); in replace_relocs() 425 shentsize = ehdr_shentsize(ehdr); in replace_relocs() 427 shnum = ehdr_shnum(ehdr); in replace_relocs() [all …]
|
| H A D | elf-parse.h | 32 uint64_t (*ehdr_shoff)(Elf_Ehdr *ehdr); 33 uint16_t (*ehdr_shstrndx)(Elf_Ehdr *ehdr); 34 uint16_t (*ehdr_shentsize)(Elf_Ehdr *ehdr); 35 uint16_t (*ehdr_shnum)(Elf_Ehdr *ehdr); 60 static inline uint64_t ehdr64_shoff(Elf_Ehdr *ehdr) in ehdr64_shoff() argument 62 return elf_parser.r8(&ehdr->e64.e_shoff); in ehdr64_shoff() 65 static inline uint64_t ehdr32_shoff(Elf_Ehdr *ehdr) in ehdr32_shoff() argument 67 return elf_parser.r(&ehdr->e32.e_shoff); in ehdr32_shoff() 70 static inline uint64_t ehdr_shoff(Elf_Ehdr *ehdr) in ehdr_shoff() argument 72 return elf_parser.ehdr_shoff(ehdr); in ehdr_shoff() [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 …]
|
| /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 …]
|
| /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() 101 if (ehdr->reply_code == REP82_ERROR_FILTERED_BY_HYPERVISOR && in convert_error() 102 ehdr->type == TYPE86_RSP_CODE) { in convert_error() 111 ehdr->reply_code, apfs); in convert_error() 115 ehdr->reply_code); in convert_error() 126 if (ehdr->reply_code == REP82_ERROR_TRANSPORT_FAIL && in convert_error() 127 ehdr->type == TYPE86_RSP_CODE) { in convert_error() 136 __func__, card, queue, ehdr->reply_code, apfs); in convert_error() 140 ehdr->reply_code); in convert_error() [all …]
|
| /linux/arch/x86/tools/ |
| H A D | relocs.c | 14 static Elf_Ehdr ehdr; variable 348 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) in read_ehdr() 350 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) in read_ehdr() 352 if (ehdr.e_ident[EI_CLASS] != ELF_CLASS) in read_ehdr() 354 if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) in read_ehdr() 356 if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) in read_ehdr() 360 ehdr.e_type = elf_half_to_cpu(ehdr.e_type); in read_ehdr() 361 ehdr.e_machine = elf_half_to_cpu(ehdr.e_machine); in read_ehdr() 362 ehdr.e_version = elf_word_to_cpu(ehdr.e_version); in read_ehdr() 363 ehdr.e_entry = elf_addr_to_cpu(ehdr.e_entry); in read_ehdr() [all …]
|
| /linux/tools/perf/util/ |
| H A D | symbol-elf.c | 57 GElf_Ehdr *ehdr; in elf_getphdrnum() local 59 ehdr = gelf_getehdr(elf, &gehdr); in elf_getphdrnum() 60 if (!ehdr) in elf_getphdrnum() 63 *dst = ehdr->e_phnum; in elf_getphdrnum() 216 GElf_Ehdr ehdr; in filename__has_section() local 228 if (gelf_getehdr(elf, &ehdr) == NULL) in filename__has_section() 231 found = !!elf_section_by_name(elf, &ehdr, &shdr, sec, NULL); in filename__has_section() 329 static bool addend_may_be_ifunc(GElf_Ehdr *ehdr, struct rel_info *ri) in addend_may_be_ifunc() argument 331 return ehdr->e_machine == EM_X86_64 && ri->is_rela && in addend_may_be_ifunc() 335 static bool get_ifunc_name(Elf *elf, struct dso *dso, GElf_Ehdr *ehdr, in get_ifunc_name() argument [all …]
|
| /linux/arch/arm64/kernel/pi/ |
| H A D | relacheck.c | 24 static Elf64_Ehdr *ehdr; variable 66 ehdr = mmap(0, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); in main() 67 if (ehdr == MAP_FAILED) { in main() 72 swap = ehdr->e_ident[EI_DATA] != HOST_ORDER; in main() 73 shdr = (void *)ehdr + swab_elfxword(ehdr->e_shoff); in main() 74 strtab = (void *)ehdr + in main() 75 swab_elfxword(shdr[swab_elfhword(ehdr->e_shstrndx)].sh_offset); in main() 77 for (int i = 0; i < swab_elfhword(ehdr->e_shnum); i++) { in main() 105 rela = (void *)ehdr + swab_elfxword(shdr[i].sh_offset); in main()
|
| /linux/lib/ |
| H A D | buildid.c | 208 const Elf32_Ehdr *ehdr; in get_build_id_32() local 212 ehdr = freader_fetch(r, 0, sizeof(Elf32_Ehdr)); in get_build_id_32() 213 if (!ehdr) in get_build_id_32() 217 phnum = READ_ONCE(ehdr->e_phnum); in get_build_id_32() 218 phoff = READ_ONCE(ehdr->e_phoff); in get_build_id_32() 244 const Elf64_Ehdr *ehdr; in get_build_id_64() local 249 ehdr = freader_fetch(r, 0, sizeof(Elf64_Ehdr)); in get_build_id_64() 250 if (!ehdr) in get_build_id_64() 254 phnum = READ_ONCE(ehdr->e_phnum); in get_build_id_64() 255 phoff = READ_ONCE(ehdr->e_phoff); in get_build_id_64() [all …]
|
| /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()
|
| /linux/arch/arm64/kvm/hyp/nvhe/ |
| H A D | gen-hyprel.c | 137 Elf64_Ehdr *ehdr; member 205 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var) 279 assert_ge(stat.st_size, sizeof(*elf.ehdr), "%lu"); in init_elf() 280 elf.ehdr = elf_ptr(Elf64_Ehdr, 0); in init_elf() 283 assert_eq(elf.ehdr->e_ident[EI_MAG0], ELFMAG0, "0x%x"); in init_elf() 284 assert_eq(elf.ehdr->e_ident[EI_MAG1], ELFMAG1, "0x%x"); in init_elf() 285 assert_eq(elf.ehdr->e_ident[EI_MAG2], ELFMAG2, "0x%x"); in init_elf() 286 assert_eq(elf.ehdr->e_ident[EI_MAG3], ELFMAG3, "0x%x"); in init_elf() 289 assert_eq(elf.ehdr->e_ident[EI_CLASS], ELFCLASS64, "%u"); in init_elf() 290 assert_eq(elf.ehdr->e_ident[EI_DATA], ELFENDIAN, "%u"); in init_elf() [all …]
|
| /linux/kernel/ |
| H A D | crash_core.c | 179 Elf64_Ehdr *ehdr; in crash_prepare_elf64_headers() local 207 ehdr = (Elf64_Ehdr *)buf; in crash_prepare_elf64_headers() 208 phdr = (Elf64_Phdr *)(ehdr + 1); in crash_prepare_elf64_headers() 209 memcpy(ehdr->e_ident, ELFMAG, SELFMAG); in crash_prepare_elf64_headers() 210 ehdr->e_ident[EI_CLASS] = ELFCLASS64; in crash_prepare_elf64_headers() 211 ehdr->e_ident[EI_DATA] = ELFDATA2LSB; in crash_prepare_elf64_headers() 212 ehdr->e_ident[EI_VERSION] = EV_CURRENT; in crash_prepare_elf64_headers() 213 ehdr->e_ident[EI_OSABI] = ELF_OSABI; in crash_prepare_elf64_headers() 214 memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD); in crash_prepare_elf64_headers() 215 ehdr->e_type = ET_CORE; in crash_prepare_elf64_headers() [all …]
|
| H A D | kexec_file.c | 896 const Elf_Ehdr *ehdr; in kexec_purgatory_setup_kbuf() 901 if (!pi->ehdr) in kexec_purgatory_setup_kbuf() 904 ehdr = pi->ehdr; in kexec_purgatory_setup_kbuf() 905 sechdrs = (void *)ehdr + ehdr->e_shoff; in kexec_purgatory_setup_kbuf() 907 for (i = 0; i < ehdr->e_shnum; i++) { in kexec_purgatory_setup_kbuf() 911 if (sechdrs[i].sh_link >= ehdr->e_shnum) in kexec_purgatory_setup_kbuf() 914 strtab = (void *)ehdr + sechdrs[sechdrs[i].sh_link].sh_offset; in kexec_purgatory_setup_kbuf() 915 syms = (void *)ehdr in kexec_purgatory_setup_kbuf() 1142 const Elf_Ehdr *ehdr; kexec_purgatory_find_symbol() local [all...] |
| /linux/arch/riscv/kernel/ |
| H A D | kexec_elf.c | 24 static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, in riscv_kexec_elf_load() argument 36 for (i = 0; i < ehdr->e_phnum; i++) { in riscv_kexec_elf_load() 64 struct elfhdr *ehdr, struct kexec_elf_info *elf_info, in elf_find_pbase() argument 74 for (i = 0; i < ehdr->e_phnum; i++) { in elf_find_pbase() 104 image->start = ehdr->e_entry - lowest_vaddr + kbuf.mem; in elf_find_pbase() 117 struct elfhdr ehdr; in elf_kexec_load() local 120 ret = kexec_build_elf_info(kernel_buf, kernel_len, &ehdr, &elf_info); in elf_kexec_load() 124 ret = elf_find_pbase(image, kernel_len, &ehdr, &elf_info, in elf_kexec_load() 130 ret = riscv_kexec_elf_load(image, &ehdr, &elf_info, in elf_kexec_load()
|
| /linux/arch/arm/kernel/ |
| H A D | vdso.c | 89 static void * __init find_section(Elf32_Ehdr *ehdr, const char *name, in find_section() argument 97 sechdrs = (void *)ehdr + ehdr->e_shoff; in find_section() 98 secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset; in find_section() 101 for (i = 1; i < ehdr->e_shnum; i++) { in find_section() 105 return (void *)ehdr + sechdrs[i].sh_offset; in find_section() 145 static void __init patch_vdso(void *ehdr) in patch_vdso() argument 150 .hdr = ehdr, in patch_vdso()
|
| /linux/arch/x86/boot/compressed/ |
| H A D | misc.c | 284 Elf64_Ehdr ehdr; in parse_elf() local 287 Elf32_Ehdr ehdr; in parse_elf() 293 memcpy(&ehdr, output, sizeof(ehdr)); in parse_elf() 294 if (ehdr.e_ident[EI_MAG0] != ELFMAG0 || in parse_elf() 295 ehdr.e_ident[EI_MAG1] != ELFMAG1 || in parse_elf() 296 ehdr.e_ident[EI_MAG2] != ELFMAG2 || in parse_elf() 297 ehdr.e_ident[EI_MAG3] != ELFMAG3) in parse_elf() 302 phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); in parse_elf() 306 memcpy(phdrs, output + ehdr.e_phoff, sizeof(*phdrs) * ehdr.e_phnum); in parse_elf() 308 for (i = 0; i < ehdr.e_phnum; i++) { in parse_elf() [all …]
|
| /linux/net/ethtool/ |
| H A D | tsinfo.c | 300 void *ehdr = NULL; in ethnl_tsinfo_prepare_dump() local 302 ehdr = ethnl_dump_put(skb, cb, in ethnl_tsinfo_prepare_dump() 304 if (!ehdr) in ethnl_tsinfo_prepare_dump() 313 return ehdr; in ethnl_tsinfo_prepare_dump() 320 void *ehdr) in ethnl_tsinfo_end_dump() argument 336 genlmsg_end(skb, ehdr); in ethnl_tsinfo_end_dump() 349 void *ehdr = NULL; in ethnl_tsinfo_dump_one_phydev() local 357 ehdr = ethnl_tsinfo_prepare_dump(skb, dev, reply_data, cb); in ethnl_tsinfo_dump_one_phydev() 358 if (IS_ERR(ehdr)) in ethnl_tsinfo_dump_one_phydev() 359 return PTR_ERR(ehdr); in ethnl_tsinfo_dump_one_phydev() [all …]
|
| /linux/fs/proc/ |
| H A D | vmcore.c | 1216 Elf64_Ehdr ehdr; in parse_crash_elf64_headers() local 1222 rc = elfcorehdr_read((char *)&ehdr, sizeof(Elf64_Ehdr), &addr); in parse_crash_elf64_headers() 1227 if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0 || in parse_crash_elf64_headers() 1228 (ehdr.e_type != ET_CORE) || in parse_crash_elf64_headers() 1229 !vmcore_elf64_check_arch(&ehdr) || in parse_crash_elf64_headers() 1230 ehdr.e_ident[EI_CLASS] != ELFCLASS64 || in parse_crash_elf64_headers() 1231 ehdr.e_ident[EI_VERSION] != EV_CURRENT || in parse_crash_elf64_headers() 1232 ehdr.e_version != EV_CURRENT || in parse_crash_elf64_headers() 1233 ehdr.e_ehsize != sizeof(Elf64_Ehdr) || in parse_crash_elf64_headers() 1234 ehdr.e_phentsize != sizeof(Elf64_Phdr) || in parse_crash_elf64_headers() [all …]
|