Commit 4d01510fc5bc4a0fecb9830817be186342f343f3
authorMichel Pollet <buserror@gmail.com>
Sat, 13 Jun 2015 20:27:35 +0000 (21:27 +0100)
committerMichel Pollet <buserror@gmail.com>
Sat, 13 Jun 2015 20:27:35 +0000 (21:27 +0100)
Allows loading a bootloader ELF as well as .hex with the right starting
PC

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/sim/sim_elf.c

index a0a49eeac3280f15c9234925981d2fcb3c297a93..33a60ae4ae703395e78c3b912d50b54ed2b9d5fb 100644 (file)
@@ -296,6 +296,9 @@ int elf_read_firmware(const char * file, elf_firmware_t * firmware)
                                                ELF32_ST_TYPE(sym.st_info) == STT_OBJECT) {
                                        const char * name = elf_strptr(elf, shdr.sh_link, sym.st_name);
 
+                                       // if its a bootloader, this symbol will be the entry point we need
+                                       if (!strcmp(name, "__vectors"))
+                                               firmware->flashbase = sym.st_value;
                                        avr_symbol_t * s = malloc(sizeof(avr_symbol_t) + strlen(name) + 1);
                                        strcpy((char*)s->symbol, name);
                                        s->addr = sym.st_value;
@@ -332,8 +335,9 @@ 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",
+                               (unsigned int)data_text->d_size, firmware->flashbase);
                offset += data_text->d_size;
-               AVR_LOG(NULL, LOG_TRACE, "Loaded %u .text\n", (unsigned int)data_text->d_size);
        }
        if (data_data) {
        //      hdump("data", data_data->d_buf, data_data->d_size);