mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
changed R_AVR_CALL relocation (but unsure why the old didn't work)
+ defined debug output
This commit is contained in:
parent
c989d425dc
commit
12338bee6d
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: elfloader-avr.c,v 1.4 2006/12/22 17:10:54 barner Exp $
|
* @(#)$Id: elfloader-avr.c,v 1.5 2007/11/16 09:16:31 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -61,12 +61,26 @@
|
|||||||
|
|
||||||
#define ELF32_R_TYPE(info) ((unsigned char)(info))
|
#define ELF32_R_TYPE(info) ((unsigned char)(info))
|
||||||
|
|
||||||
|
#define DEBUG 0
|
||||||
|
#if DEBUG
|
||||||
|
/*#define PRINTF(...) rs232_print_p(RS232_PORT_1, __VA_ARGS__)*/
|
||||||
|
#define PRINTF(...) printf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define PRINTF(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct mmem module_heap;
|
static struct mmem module_heap;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void*
|
void*
|
||||||
elfloader_arch_allocate_ram(int size)
|
elfloader_arch_allocate_ram(int size)
|
||||||
{
|
{
|
||||||
/* Allocate RAM for module (TODO: we leak the memory) */
|
/* Free previously allocated memory */
|
||||||
|
/* TODO Assumes memory address 0 can't be allocated, use flag instead? */
|
||||||
|
if (MMEM_PTR(&module_heap) != 0) {
|
||||||
|
mmem_free(&module_heap);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate RAM for module */
|
||||||
if (mmem_alloc (&module_heap, size) == 0) {
|
if (mmem_alloc (&module_heap, size) == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -166,8 +180,8 @@ elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
|||||||
switch(type) {
|
switch(type) {
|
||||||
case R_AVR_NONE:
|
case R_AVR_NONE:
|
||||||
case R_AVR_32:
|
case R_AVR_32:
|
||||||
rs232_print_p (RS232_PORT_1, PSTR ("elfloader-avr.c: unsupported relocation type: "));
|
PRINTF(PSTR ("elfloader-avr.c: unsupported relocation type: "));
|
||||||
rs232_printf (RS232_PORT_1, "%d\n", type);
|
PRINTF("%d\n", type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_AVR_7_PCREL: { /* 4 */
|
case R_AVR_7_PCREL: { /* 4 */
|
||||||
@ -257,14 +271,20 @@ elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R_AVR_CALL: /* 18 */
|
case R_AVR_CALL: /* 18 */
|
||||||
addr = ((int16_t)addr >> 1);
|
/* old solution:
|
||||||
instr[2] = (int16_t)addr & 0xff;
|
addr = ((int16_t)addr >> 1);
|
||||||
instr[3] = (int16_t)addr >> 8;
|
instr[2] = (int16_t)addr & 0xff;
|
||||||
|
instr[3] = (int16_t)addr >> 8;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* new solution */
|
||||||
|
instr[2] = (u8_t) ((int16_t)addr) & 0xff;
|
||||||
|
instr[3] = ((int16_t)addr) >> 8;
|
||||||
cfs_write(fd, instr, 4);
|
cfs_write(fd, instr, 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rs232_print_p (RS232_PORT_1, PSTR ("Unknown reloation type!\n"));
|
PRINTF(PSTR ("Unknown relocation type!\n"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user