From 13d121d77203740eaf6fb17a10b0d468c6ba6d51 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Wed, 19 Oct 2016 10:09:11 +0100 Subject: [PATCH] elf: Clean up code duplication and fix a cast 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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/simavr/sim/sim_elf.c b/simavr/sim/sim_elf.c index d73f277..529c2df 100644 --- a/simavr/sim/sim_elf.c +++ b/simavr/sim/sim_elf.c @@ -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) { -- 2.39.5