static void bswap_phdr(struct elf_phdr *phdr) { bswap32s(&phdr->p_type); /* Segment type */ bswaptls(&phdr->p_offset); /* Segment file offset */ bswaptls(&phdr->p_vaddr); /* Segment virtual address */ bswaptls(&phdr->p_paddr); /* Segment physical address */ bswaptls(&phdr->p_filesz); /* Segment size in file */ bswaptls(&phdr->p_memsz); /* Segment size in memory */ bswap32s(&phdr->p_flags); /* Segment flags */ bswaptls(&phdr->p_align); /* Segment alignment */ }
static void bswap_shdr(struct elf_shdr *shdr) { bswap32s(&shdr->sh_name); bswap32s(&shdr->sh_type); bswaptls(&shdr->sh_flags); bswaptls(&shdr->sh_addr); bswaptls(&shdr->sh_offset); bswaptls(&shdr->sh_size); bswap32s(&shdr->sh_link); bswap32s(&shdr->sh_info); bswaptls(&shdr->sh_addralign); bswaptls(&shdr->sh_entsize); }
static void bswap_sym(struct elf_sym *sym) { bswap32s(&sym->st_name); bswaptls(&sym->st_value); bswaptls(&sym->st_size); bswap16s(&sym->st_shndx); }
/* Swap from UUID format endian (BE) to the opposite or vice versa. */ void qemu_uuid_bswap(QemuUUID *uuid) { assert(QEMU_PTR_IS_ALIGNED(uuid, sizeof(uint32_t))); bswap32s(&uuid->fields.time_low); bswap16s(&uuid->fields.time_mid); bswap16s(&uuid->fields.time_high_and_version); }
static void bswap_ehdr(struct elfhdr *ehdr) { bswap16s(&ehdr->e_type); /* Object file type */ bswap16s(&ehdr->e_machine); /* Architecture */ bswap32s(&ehdr->e_version); /* Object file version */ bswaptls(&ehdr->e_entry); /* Entry point virtual address */ bswaptls(&ehdr->e_phoff); /* Program header table file offset */ bswaptls(&ehdr->e_shoff); /* Section header table file offset */ bswap32s(&ehdr->e_flags); /* Processor-specific flags */ bswap16s(&ehdr->e_ehsize); /* ELF header size in bytes */ bswap16s(&ehdr->e_phentsize); /* Program header table entry size */ bswap16s(&ehdr->e_phnum); /* Program header table entry count */ bswap16s(&ehdr->e_shentsize); /* Section header table entry size */ bswap16s(&ehdr->e_shnum); /* Section header table entry count */ bswap16s(&ehdr->e_shstrndx); /* Section header string table index */ }
static void bswap_ahdr(struct exec *e) { bswap32s(&e->a_info); bswap32s(&e->a_text); bswap32s(&e->a_data); bswap32s(&e->a_bss); bswap32s(&e->a_syms); bswap32s(&e->a_entry); bswap32s(&e->a_trsize); bswap32s(&e->a_drsize); }
static void ppc_gdb_swap_register(uint8_t *mem_buf, int n, int len) { if (len == 4) { bswap32s((uint32_t *)mem_buf); } else if (len == 8) { bswap64s((uint64_t *)mem_buf); } else { g_assert_not_reached(); } }
static void bswap_uboot_header(uboot_image_header_t *hdr) { #ifndef WORDS_BIGENDIAN bswap32s(&hdr->ih_magic); bswap32s(&hdr->ih_hcrc); bswap32s(&hdr->ih_time); bswap32s(&hdr->ih_size); bswap32s(&hdr->ih_load); bswap32s(&hdr->ih_ep); bswap32s(&hdr->ih_dcrc); #endif }
/* We need to present the registers to gdb in the "current" memory ordering. For user-only mode we get this for free; TARGET_WORDS_BIGENDIAN is set to the proper ordering for the binary, and cannot be changed. For system mode, TARGET_WORDS_BIGENDIAN is always set, and we must check the current mode of the chip to see if we're running in little-endian. */ void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len) { #ifndef CONFIG_USER_ONLY if (!msr_le) { /* do nothing */ } else if (len == 4) { bswap32s((uint32_t *)mem_buf); } else if (len == 8) { bswap64s((uint64_t *)mem_buf); } else { g_assert_not_reached(); } #endif }
/* Change UUID from little endian (IPRT = VirtualBox format) to big endian * format (network byte order, standard, see RFC 4122) and vice versa. */ static void uuid_convert(uuid_t uuid) { bswap32s((uint32_t *)&uuid[0]); bswap16s((uint16_t *)&uuid[4]); bswap16s((uint16_t *)&uuid[6]); }