Commit 13d121d77203740eaf6fb17a10b0d468c6ba6d51
authorMichel Pollet <michel.pollet@bp.renesas.com>
Wed, 19 Oct 2016 09:09:11 +0000 (10:09 +0100)
committerMichel Pollet <michel.pollet@bp.renesas.com>
Wed, 19 Oct 2016 09:09:11 +0000 (10:09 +0100)
Use the helper function elf_copy_section() to get rid of some code
duplication and use the correct printf() type so that there is no cast
necessary.

Conflicts:
simavr/sim/sim_elf.c

simavr/sim/sim_elf.c

index d73f27788f022b324a010591f180c297f1195b46..529c2dfb11077a82e73f15b3f348b63aa06e9dfd 100644 (file)
@@ -362,22 +362,19 @@ int elf_read_firmware(const char * file, elf_firmware_t * firmware)
        if (data_text) {
        //      hdump("code", data_text->d_buf, data_text->d_size);
                memcpy(firmware->flash + offset, data_text->d_buf, data_text->d_size);
-               AVR_LOG(NULL, LOG_TRACE, "Loaded %u .text at address 0x%x\n",
+               AVR_LOG(NULL, LOG_TRACE, "Loaded %zu .text at address 0x%x\n",
                                (unsigned int)data_text->d_size, firmware->flashbase);
                offset += data_text->d_size;
        }
        if (data_data) {
        //      hdump("data", data_data->d_buf, data_data->d_size);
                memcpy(firmware->flash + offset, data_data->d_buf, data_data->d_size);
-               AVR_LOG(NULL, LOG_TRACE, "Loaded %u .data\n", (unsigned int)data_data->d_size);
+               AVR_LOG(NULL, LOG_TRACE, "Loaded %zu .data\n", data_data->d_size);
                offset += data_data->d_size;
                firmware->datasize = data_data->d_size;
        }
        if (data_ee) {
-       //      hdump("eeprom", data_ee->d_buf, data_ee->d_size);
-               firmware->eeprom = malloc(data_ee->d_size);
-               memcpy(firmware->eeprom, data_ee->d_buf, data_ee->d_size);
-               AVR_LOG(NULL, LOG_TRACE, "Loaded %u .eeprom\n", (unsigned int)data_ee->d_size);
+               elf_copy_section(".eeprom", data_ee, &firmware->eeprom);
                firmware->eesize = data_ee->d_size;
        }
        if (data_fuse) {