Bugs in previous change, could include 32 bit code on 16 bit builds

This commit is contained in:
dak664 2009-07-16 17:33:50 +00:00
parent 4531d66986
commit c4b4c25e1c

View file

@ -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 <stdio.h>
@ -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);