mirror of https://github.com/rusefi/ChibiOS.git
Still bugs to be fixed.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15321 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
a782af6212
commit
37010bf285
|
@ -225,7 +225,7 @@ int main(void) {
|
|||
* Initializing overlay driver for the directory shared among the sandboxes.
|
||||
* It is seen as "/shared".
|
||||
*/
|
||||
drvOverlayObjectInit(&sb_shared_overlay_driver, (vfs_driver_c *)&fatfs_driver, "shared");
|
||||
drvOverlayObjectInit(&sb_shared_overlay_driver, (vfs_driver_c *)&fatfs_driver, "/shared");
|
||||
ret = drvOverlayRegisterDriver(&sb1_root_overlay_driver,
|
||||
(vfs_driver_c *)&sb_shared_overlay_driver,
|
||||
"shared");
|
||||
|
@ -323,7 +323,9 @@ int main(void) {
|
|||
|
||||
/* Checking for user button, launching test suite if pressed.*/
|
||||
if (palReadLine(LINE_BUTTON)) {
|
||||
ret = sbElfLoadFile((vfs_driver_c *)&sb1_root_overlay_driver, "/bin/app.elf", NULL);
|
||||
static uint8_t loadbuf[1024];
|
||||
static memory_area_t ma = {loadbuf, sizeof (loadbuf)};
|
||||
ret = sbElfLoadFile((vfs_driver_c *)&sb1_root_overlay_driver, "/bin/app.elf", &ma);
|
||||
if (CH_RET_IS_ERROR(ret)) {
|
||||
chSysHalt("ELF");
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ all: app.elf
|
|||
|
||||
-include $(DEPS)
|
||||
|
||||
%.o: %.c
|
||||
%.o: %.c $(MAKEFILE_LIST)
|
||||
@echo " CC $<"
|
||||
@$(CC) -MMD $(CFLAGS) -o $@ -c $<
|
||||
|
||||
|
@ -31,6 +31,9 @@ app.elf: $(OBJS)
|
|||
@$(LD) $(LDFLAGS) -o $@ $^
|
||||
@$(STRIP) -g -o app-striped.elf $@
|
||||
@$(SIZE) --common $@
|
||||
@echo " Creating list..."
|
||||
@$(CROSS)objdump -hpxdSsrt app.elf > app.elf.list
|
||||
@$(CROSS)readelf -atSln app.elf > app.elf.read
|
||||
|
||||
.PHONY: clean all list
|
||||
|
||||
|
|
|
@ -4,8 +4,21 @@ int bssvar;
|
|||
int datavar = 5;
|
||||
const int rodatavar = 18;
|
||||
|
||||
static void foo(void);
|
||||
|
||||
static void xxx(void) {
|
||||
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
||||
foo();
|
||||
|
||||
while (true) {
|
||||
xxx();
|
||||
}
|
||||
}
|
||||
|
||||
static void foo(void) {
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,11 @@
|
|||
/* Special section indices.*/
|
||||
#define SHN_UNDEF 0U
|
||||
|
||||
/* Supported relocation types.*/
|
||||
#define R_ARM_ABS32 2U
|
||||
#define R_ARM_THM_PC22 10U
|
||||
#define R_ARM_THM_JUMP24 30U
|
||||
|
||||
#define ELF32_R_SYM(v) ((v) >> 8)
|
||||
#define ELF32_R_TYPE(v) ((v) & 0xFFU)
|
||||
|
||||
|
@ -268,15 +273,12 @@ yes_it_is_a_goto:
|
|||
static msg_t reloc_entry(elf_load_context_t *ctxp,
|
||||
elf_loadable_info_t *lip,
|
||||
elf32_rel_t *rp) {
|
||||
vfs_offset_t oldoff, symoff;
|
||||
vfs_offset_t symoff;
|
||||
elf_symnum_t symnum;
|
||||
uint8_t *relocation_address;
|
||||
uint32_t relocation_address;
|
||||
msg_t ret;
|
||||
elf32_symbol_t symbol;
|
||||
|
||||
/* Saving current file position.*/
|
||||
oldoff = vfsGetFilePosition(ctxp->fnp);
|
||||
|
||||
/* Checking for a symbol number overflow.*/
|
||||
symnum = (elf_symnum_t)ELF32_R_SYM(rp->r_info);
|
||||
if (symnum > ctxp->symbols_num) {
|
||||
|
@ -302,7 +304,7 @@ static msg_t reloc_entry(elf_load_context_t *ctxp,
|
|||
}
|
||||
|
||||
/* Relocation point address.*/
|
||||
relocation_address = ctxp->map->base + lip->address + symbol.st_value;
|
||||
relocation_address = (uint32_t)ctxp->map->base + lip->address + rp->r_offset;
|
||||
if (!chMemIsAreaWithinX(ctxp->map,
|
||||
(const void *)relocation_address,
|
||||
sizeof (uint32_t))) {
|
||||
|
@ -311,12 +313,15 @@ static msg_t reloc_entry(elf_load_context_t *ctxp,
|
|||
|
||||
/* Handling the various relocation point types.*/
|
||||
switch (ELF32_R_TYPE(rp->r_info)) {
|
||||
|
||||
case R_ARM_ABS32:
|
||||
*((uint32_t *)relocation_address) += (uint32_t)ctxp->map->base + symbol.st_value;
|
||||
break;
|
||||
case R_ARM_THM_PC22:
|
||||
case R_ARM_THM_JUMP24:
|
||||
default:
|
||||
return CH_RET_ENOEXEC;
|
||||
}
|
||||
|
||||
ret = vfsSetFilePosition(ctxp->fnp, oldoff, VFS_SEEK_SET);
|
||||
CH_RETURN_ON_ERROR(ret);
|
||||
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -389,8 +394,10 @@ static msg_t load_relocate_section(elf_load_context_t *ctxp,
|
|||
CH_RETURN_ON_ERROR(ret);
|
||||
}
|
||||
|
||||
if (lip->rel_size > 0U) {
|
||||
ret = reloc_section(ctxp, lip);
|
||||
CH_RETURN_ON_ERROR(ret);
|
||||
}
|
||||
|
||||
return CH_RET_SUCCESS;
|
||||
}
|
||||
|
@ -501,7 +508,7 @@ msg_t sbElfLoad(vfs_file_node_c *fnp, memory_area_t *map) {
|
|||
|
||||
case SHT_REL:
|
||||
if ((sh.sh_flags & SHF_INFO_LINK) != 0U) {
|
||||
elf_secnum_t sn = (elf_secnum_t)sh.sh_link;
|
||||
elf_secnum_t sn = (elf_secnum_t)sh.sh_info;
|
||||
|
||||
if (sn == ctx.loadable_code.section) {
|
||||
/* Executable code section.*/
|
||||
|
@ -547,6 +554,7 @@ msg_t sbElfLoad(vfs_file_node_c *fnp, memory_area_t *map) {
|
|||
/* Ignoring other section types.*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loading phase.*/
|
||||
ret = load_relocate_section(&ctx, &ctx.loadable_code);
|
||||
|
@ -555,7 +563,6 @@ msg_t sbElfLoad(vfs_file_node_c *fnp, memory_area_t *map) {
|
|||
CH_RETURN_ON_ERROR(ret);
|
||||
ret = load_relocate_section(&ctx, &ctx.loadable_const);
|
||||
CH_RETURN_ON_ERROR(ret);
|
||||
}
|
||||
} while (false);
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue