From c4b4c25e1c5f6760e95639ed95eaa65ed5e264b4 Mon Sep 17 00:00:00 2001 From: dak664 Date: Thu, 16 Jul 2009 17:33:50 +0000 Subject: [PATCH] Bugs in previous change, could include 32 bit code on 16 bit builds --- core/loader/elfloader-avr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/core/loader/elfloader-avr.c b/core/loader/elfloader-avr.c index fc7456025..dbebafdcc 100644 --- a/core/loader/elfloader-avr.c +++ b/core/loader/elfloader-avr.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: elfloader-avr.c,v 1.7 2009/07/16 17:17:22 dak664 Exp $ + * @(#)$Id: elfloader-avr.c,v 1.8 2009/07/16 17:33:50 dak664 Exp $ */ #include @@ -102,10 +102,13 @@ elfloader_arch_allocate_rom(int size) /* Eliminate compiler warnings for (non-functional) code when flash requires 32 bit addresses and pointers are 16 bit U*/ #define INCLUDE_APPLICATE_SOURCE 1 #ifdef __GNUC__ -#if (FLASHEND > USHRT_MAX) && (SIZEOF_POINTER__ <= 2) +#if (FLASHEND > USHRT_MAX) && (__SIZEOF_POINTER__ <= 2) #undef INCLUDE_APPLICATE_SOURCE #define INCLUDE_APPLICATE_SOURCE 0 #endif +#if (__SIZEOF_POINTER__ > 2) +#define INCLUDE_32BIT_CODE 1 +#endif #endif #if INCLUDE_APPLICATE_SOURCE @@ -257,7 +260,7 @@ elfloader_arch_relocate(int fd, unsigned int sectionoffset, write_ldi(fd, instr, (unsigned int)addr >> 8); break; -#if INCLUDE_APPLICATE_SOURCE /* 32 bit AVRs */ +#if INCLUDE_32BIT_CODE /* 32 bit AVRs */ case R_AVR_HH8_LDI_NEG: /* 11 */ addr = (char *)(0 - (unsigned int)addr); write_ldi(fd, instr, (unsigned int)addr >> 16); @@ -271,7 +274,7 @@ elfloader_arch_relocate(int fd, unsigned int sectionoffset, write_ldi(fd, instr, (unsigned int)addr >> 9); break; -#if INCLUDE_APPLICATE_SOURCE /* 32 bit AVRs */ +#if INCLUDE_32BIT_CODE /* 32 bit AVRs */ case R_AVR_HH8_LDI_PM: /* 14 */ write_ldi(fd, instr, (unsigned int)addr >> 17); break; @@ -286,7 +289,7 @@ elfloader_arch_relocate(int fd, unsigned int sectionoffset, write_ldi(fd, instr, (unsigned int)addr >> 9); break; -#if INCLUDE_APPLICATE_SOURCE /* 32 bit AVRs */ +#if INCLUDE_32BIT_CODE /* 32 bit AVRs */ case R_AVR_HH8_LDI_PM_NEG: /* 17 */ addr = (char *) (0 - (unsigned int)addr); write_ldi(fd, instr, (unsigned int)addr >> 17);