static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping,

                            int phdr_index, hwaddr offset)

{

    Elf32_Phdr phdr;

    int ret;

    int endian = s->dump_info.d_endian;



    memset(&phdr, 0, sizeof(Elf32_Phdr));

    phdr.p_type = cpu_convert_to_target32(PT_LOAD, endian);

    phdr.p_offset = cpu_convert_to_target32(offset, endian);

    phdr.p_paddr = cpu_convert_to_target32(memory_mapping->phys_addr, endian);

    if (offset == -1) {

        /* When the memory is not stored into vmcore, offset will be -1 */

        phdr.p_filesz = 0;

    } else {

        phdr.p_filesz = cpu_convert_to_target32(memory_mapping->length, endian);

    }

    phdr.p_memsz = cpu_convert_to_target32(memory_mapping->length, endian);

    phdr.p_vaddr = cpu_convert_to_target32(memory_mapping->virt_addr, endian);



    ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);

    if (ret < 0) {

        dump_error(s, "dump: failed to write program header table.\n");

        return -1;

    }



    return 0;

}

static int write_elf32_load(DumpState *s, MemoryMapping *memory_mapping,

                            int phdr_index, hwaddr offset)

{

    Elf32_Phdr phdr;

    int ret;

    int endian = s->dump_info.d_endian;



    memset(&phdr, 0, sizeof(Elf32_Phdr));

    phdr.p_type = cpu_convert_to_target32(PT_LOAD, endian);

    phdr.p_offset = cpu_convert_to_target32(offset, endian);

    phdr.p_paddr = cpu_convert_to_target32(memory_mapping->phys_addr, endian);

    if (offset == -1) {

        

        phdr.p_filesz = 0;

    } else {

        phdr.p_filesz = cpu_convert_to_target32(memory_mapping->length, endian);

    }

    phdr.p_memsz = cpu_convert_to_target32(memory_mapping->length, endian);

    phdr.p_vaddr = cpu_convert_to_target32(memory_mapping->virt_addr, endian);



    ret = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), s);

    if (ret < 0) {

        dump_error(s, "dump: failed to write program header table.\n");

        return -1;

    }



    return 0;

}

static int FUNC_0(DumpState *VAR_0, MemoryMapping *VAR_1,

                            int VAR_2, hwaddr VAR_3)

{

    Elf32_Phdr phdr;

    int VAR_4;

    int VAR_5 = VAR_0->dump_info.d_endian;



    memset(&phdr, 0, sizeof(Elf32_Phdr));

    phdr.p_type = cpu_convert_to_target32(PT_LOAD, VAR_5);

    phdr.p_offset = cpu_convert_to_target32(VAR_3, VAR_5);

    phdr.p_paddr = cpu_convert_to_target32(VAR_1->phys_addr, VAR_5);

    if (VAR_3 == -1) {

        

        phdr.p_filesz = 0;

    } else {

        phdr.p_filesz = cpu_convert_to_target32(VAR_1->length, VAR_5);

    }

    phdr.p_memsz = cpu_convert_to_target32(VAR_1->length, VAR_5);

    phdr.p_vaddr = cpu_convert_to_target32(VAR_1->virt_addr, VAR_5);



    VAR_4 = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), VAR_0);

    if (VAR_4 < 0) {

        dump_error(VAR_0, "dump: failed to write program header table.\n");

        return -1;

    }



    return 0;

}

static int FUNC_0(DumpState *VAR_0, MemoryMapping *VAR_1,
int VAR_2, hwaddr VAR_3)
{ Elf32_Phdr phdr; int VAR_4; int VAR_5 = VAR_0->dump_info.d_endian; memset(&phdr, 0, sizeof(Elf32_Phdr)); phdr.p_type = cpu_convert_to_target32(PT_LOAD, VAR_5); phdr.p_offset = cpu_convert_to_target32(VAR_3, VAR_5); phdr.p_paddr = cpu_convert_to_target32(VAR_1->phys_addr, VAR_5); if (VAR_3 == -1) { phdr.p_filesz = 0; } else { phdr.p_filesz = cpu_convert_to_target32(VAR_1->length, VAR_5); } phdr.p_memsz = cpu_convert_to_target32(VAR_1->length, VAR_5); phdr.p_vaddr = cpu_convert_to_target32(VAR_1->virt_addr, VAR_5); VAR_4 = fd_write_vmcore(&phdr, sizeof(Elf32_Phdr), VAR_0); if (VAR_4 < 0) { dump_error(VAR_0, "dump: failed to write program header table.\n"); return -1; } return 0; }