diff -rup xorg-server-1.0.2.org/hw/xfree86/common/compiler.h xorg-server-1.0.2/hw/xfree86/common/compiler.h --- xorg-server-1.0.2.org/hw/xfree86/common/compiler.h 2005-11-08 15:33:28.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/common/compiler.h 2006-07-24 13:45:18.478040744 +0900 @@ -1367,7 +1367,7 @@ do { \ # define write_mem_barrier() /* NOP */ # if !defined(__SUNPRO_C) -# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) +# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) # ifdef GCCUSESGAS /* @@ -1476,7 +1476,7 @@ inl(unsigned short port) # endif /* GCCUSESGAS */ -# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/ +# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */ static __inline__ void outb(unsigned short port, unsigned char val) diff -rup xorg-server-1.0.2.org/hw/xfree86/common/xf86Bus.c xorg-server-1.0.2/hw/xfree86/common/xf86Bus.c --- xorg-server-1.0.2.org/hw/xfree86/common/xf86Bus.c 2006-07-13 16:25:45.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/common/xf86Bus.c 2006-07-24 13:48:28.895092952 +0900 @@ -3066,7 +3066,7 @@ xf86FindPrimaryDevice() } -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) +#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__m32r__) #include "vgaHW.h" #include "compiler.h" #endif @@ -3078,7 +3078,7 @@ static void CheckGenericGA() { /* This needs to be changed for multiple domains */ -#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) +#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__m32r__) IOADDRESS GenericIOBase = VGAHW_GET_IOBASE(); CARD8 CurrentValue, TestValue; diff -rup xorg-server-1.0.2.org/hw/xfree86/loader/elf.h xorg-server-1.0.2/hw/xfree86/loader/elf.h --- xorg-server-1.0.2.org/hw/xfree86/loader/elf.h 2005-07-03 16:01:29.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/loader/elf.h 2006-07-24 13:52:48.592612928 +0900 @@ -460,6 +460,52 @@ extern Elf32_Dyn _DYNAMIC[]; #define R_PPC_SECTOFF_HA 36 #endif +/* M32R relocs. */ +#define R_M32R_NONE 0 +#define R_M32R_16 1 +#define R_M32R_32 2 +#define R_M32R_24 3 +#define R_M32R_10_PCREL 4 +#define R_M32R_18_PCREL 5 +#define R_M32R_26_PCREL 6 +#define R_M32R_HI16_ULO 7 +#define R_M32R_HI16_SLO 8 +#define R_M32R_LO16 9 +#define R_M32R_SDA16 10 +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 + +#define R_M32R_16_RELA 33 +#define R_M32R_32_RELA 34 +#define R_M32R_24_RELA 35 +#define R_M32R_10_PCREL_RELA 36 +#define R_M32R_18_PCREL_RELA 37 +#define R_M32R_26_PCREL_RELA 38 +#define R_M32R_HI16_ULO_RELA 39 +#define R_M32R_HI16_SLO_RELA 40 +#define R_M32R_LO16_RELA 41 +#define R_M32R_SDA16_RELA 42 +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 +#define R_M32R_REL32 45 +#define R_M32R_GOT24 48 +#define R_M32R_26_PLTREL 49 +#define R_M32R_COPY 50 +#define R_M32R_GLOB_DAT 51 +#define R_M32R_JMP_SLOT 52 +#define R_M32R_RELATIVE 53 +#define R_M32R_GOTOFF 54 +#define R_M32R_GOTPC24 55 +#define R_M32R_GOT16_HI_ULO 56 +#define R_M32R_GOT16_HI_SLO 57 +#define R_M32R_GOT16_LO 58 +#define R_M32R_GOTPC_HI_ULO 59 +#define R_M32R_GOTPC_HI_SLO 60 +#define R_M32R_GOTPC_LO 61 +#define R_M32R_GOTOFF_HI_ULO 62 +#define R_M32R_GOTOFF_HI_SLO 63 +#define R_M32R_GOTOFF_LO 64 + /* ARM relocs. */ #define R_ARM_NONE 0 /* No reloc */ #define R_ARM_PC24 1 /* PC relative 26 bit branch */ diff -rup xorg-server-1.0.2.org/hw/xfree86/loader/elfloader.c xorg-server-1.0.2/hw/xfree86/loader/elfloader.c --- xorg-server-1.0.2.org/hw/xfree86/loader/elfloader.c 2006-07-13 16:25:45.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/loader/elfloader.c 2006-07-24 14:21:36.612913912 +0900 @@ -67,6 +67,10 @@ # define ELFDEBUG ErrorF #endif +#if defined(__m32r__) +#include +#endif + #if defined(__ia64__) /* @@ -245,6 +249,28 @@ typedef Elf32_Word Elf_Word; #define ELF_ST_TYPE ELF32_ST_TYPE #define ELF_R_SYM ELF32_R_SYM #define ELF_R_TYPE ELF32_R_TYPE + +# if defined (__m32r__use_got__) +/* + * The GOT is allocated dynamically. We need to keep a list of entries that + * have already been added to the GOT. + * + */ +typedef struct _elf_GOT_Entry { + Elf_Rela *rel; + int offset; + struct _elf_GOT_Entry *next; +} ELFGotEntryRec, *ELFGotEntryPtr; + +typedef struct _elf_GOT { + unsigned int size; + unsigned int nuses; + unsigned char *freeptr; + struct _elf_GOT *next; + unsigned char section[1]; +} ELFGotRec, *ELFGotPtr; +#endif /* __m32r__use_got__ */ + #endif #if defined(__powerpc__) || \ @@ -252,6 +278,7 @@ typedef Elf32_Word Elf_Word; defined(__alpha__) || \ defined(__sparc__) || \ defined(__ia64__) || \ + defined(__m32r__) || \ defined(__amd64__) typedef Elf_Rela Elf_Rel_t; #else @@ -287,13 +314,13 @@ typedef struct { unsigned char *shstraddr; /* Start address of the section header string table */ int shstrndx; /* index of the section header string table */ int shstrsize; /* size of the section header string table */ -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) unsigned char *got; /* Start address of the .got section */ ELFGotEntryPtr got_entries; /* List of entries in the .got section */ int gotndx; /* index of the .got section */ int gotsize; /* actual size of the .got section */ ELFGotPtr shared_got; /* Pointer to ELFGotRec if shared */ -#endif /*(__alpha__) || (__ia64__) */ +#endif /*(__alpha__) || (__ia64__) || (__m32r__use_got__) */ #if defined(__ia64__) ELFOpdPtr opd_entries; /* List of entries in the .opd section */ unsigned char *plt; /* Start address of the .plt section */ @@ -358,7 +385,7 @@ static ELFRelocPtr ELFCollectRelocations static LOOKUP *ELF_GetSymbols(ELFModulePtr, unsigned short **); static void ELFCollectSections(ELFModulePtr, int, int *, int *); -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) static void ElfAddGOT(ELFModulePtr, Elf_Rel_t *); static int ELFCreateGOT(ELFModulePtr, int); #endif @@ -446,6 +473,7 @@ ElfDelayRelocation(ELFModulePtr elffile, defined(__alpha__) || \ defined(__sparc__) || \ defined(__ia64__) || \ + defined(__m32r__) || \ defined(__amd64__) ELFDEBUG(", r_addend 0x%lx", rel->r_addend); # endif @@ -792,7 +820,7 @@ ElfGetPltAddr(ELFModulePtr elffile, int } #endif /* __powerpc__ */ -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) /* * Manage GOT Entries */ @@ -857,7 +885,11 @@ ELFCreateGOT(ELFModulePtr elffile, int m * XXX: Is it REALLY needed to ensure GOT's are non-null? */ # ifdef ELFDEBUG +# if defined(__m32r__) + ELFDEBUG("ELFCreateGOT: %x entries in the GOT\n", elffile->gotsize / 4); +# else ELFDEBUG("ELFCreateGOT: %x entries in the GOT\n", elffile->gotsize / 8); +# endif /* * Hmmm. Someone is getting here without any got entries, but they @@ -868,7 +900,11 @@ ELFCreateGOT(ELFModulePtr elffile, int m _LoaderModuleToName(elffile->module)); # endif if (elffile->gotsize == 0) +# if defined(__m32r__) + elffile->gotsize = 4; +# else elffile->gotsize = 8; +# endif elffile->sections[elffile->gotndx].sh_size = elffile->gotsize; gotsize = elffile->gotsize; @@ -981,7 +1017,7 @@ ELFCreateGOT(ELFModulePtr elffile, int m return TRUE; } -#endif /* defined(__alpha__) || defined(__ia64__) */ +#endif /* defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) */ #if defined(__ia64__) /* @@ -1221,7 +1257,7 @@ Elf_RelocateEntry(ELFModulePtr elffile, #if !defined(__ia64__) unsigned int *dest32; /* address of the 32 bit place being modified */ #endif -#if defined(__powerpc__) || defined(__sparc__) +#if defined(__powerpc__) || defined(__sparc__) || defined(__m32r__) unsigned short *dest16; /* address of the 16 bit place being modified */ #endif #if defined(__sparc__) @@ -1251,6 +1287,7 @@ Elf_RelocateEntry(ELFModulePtr elffile, defined(__alpha__) || \ defined(__sparc__) || \ defined(__ia64__) || \ + defined(__m32r__) || \ defined(__amd64__) ELFDEBUG("%lx", rel->r_addend); # endif @@ -2542,11 +2579,346 @@ Elf_RelocateEntry(ELFModulePtr elffile, #endif /* (__arm__) */ +#if defined(__m32r__) + case R_M32R_NONE: /* 0 */ +#ifdef ELFDEBUG + ELFDEBUG("R_M32R_NONE\n"); +#endif + break; + case R_M32R_32_RELA: + case R_M32R_32: + dest32 = (unsigned int *)(secp + rel->r_offset); + *dest32 += symval + rel->r_addend; +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_32_RELA) + ELFDEBUG("R_M32R_32_RELA dest32=%x\t",dest32); + else + ELFDEBUG("R_M32R_32 dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + break; + + case R_M32R_16_RELA: + case R_M32R_16: + dest16 = (unsigned short *)(secp + rel->r_offset); + *dest16 = (*dest16 + symval + rel->r_addend) & 0xffff; +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_16_RELA) + ELFDEBUG("R_M32R_16_RELA dest16=%x\t",dest16); + else + ELFDEBUG("R_M32R_16 dest16=%x\t",dest16); + ELFDEBUG("*dest16=%x\n",*dest16); +#endif + break; + + case R_M32R_24_RELA: + case R_M32R_24: + { + signed long val; + dest32 = (unsigned int *)(secp + rel->r_offset); + val = *dest32 & 0xffffff; + val += symval + rel->r_addend; + *dest32 = (*dest32 & ~0xffffff) | (val & 0xffffff); +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_24_RELA) + ELFDEBUG("R_M32R_24_RELA dest32=%x\t",dest32); + else + ELFDEBUG("R_M32R_24 dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + } + break; + case R_M32R_HI16_ULO_RELA: + case R_M32R_HI16_ULO: + { + signed long val; + dest32 = (unsigned int *)(secp + rel->r_offset); + val = *dest32 & 0xffff; + val += symval + rel->r_addend; + *dest32 = (*dest32 & ~0xffff) | ((val >> 16) & 0xffff); +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_HI16_ULO_RELA) + ELFDEBUG("R_M32R_HI16_ULO_RELA\t"); + else + ELFDEBUG("R_M32R_HI16_ULO\t"); + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + } + break; + case R_M32R_HI16_SLO_RELA: + case R_M32R_HI16_SLO: + { + signed long val; + dest32 = (unsigned int *)(secp + rel->r_offset); + val = *dest32 & 0xffff; + val += symval + rel->r_addend; + if (val & 0x8000) val += 0x10000; + *dest32 = (*dest32 & ~0xffff) | ((val >> 16) & 0xffff); +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_HI16_SLO_RELA) + ELFDEBUG("R_M32R_HI16_SLO_RELA\t"); + else + ELFDEBUG("R_M32R_HI16_SLO\t"); + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + } + break; + case R_M32R_LO16: + case R_M32R_LO16_RELA: + /*case R_M32R_SDA16: */ + /*case R_M32R_SDA16_RELA: */ + { + signed long val; +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_LO16_RELA) + ELFDEBUG("R_M32R_LO16_RELA\t"); + else if (ELF_R_TYPE(rel->r_info) == R_M32R_SDA16) + ELFDEBUG("R_M32R_SDA16\t"); + else if (ELF_R_TYPE(rel->r_info) == R_M32R_LO16) + ELFDEBUG("R_M32R_LO16\t"); + else + ELFDEBUG("R_M32R_SDA16\t"); +#endif + dest32 = (unsigned int *)(secp + rel->r_offset); + val = *dest32 & 0xffff; + val += symval + rel->r_addend; + *dest32 = (*dest32 & ~0xffff) | (val & 0xffff); +#ifdef ELFDEBUG + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + } + break; + case R_M32R_26_PLTREL: +#if defined(__m32r__use_got__) + /* Fall through */ +#else + FatalError("\nunhandled reloc R_M32R_GOT24\n"); + break; +#endif + case R_M32R_REL32: + dest32 = (unsigned int *)(secp + rel->r_offset); + dest32 += symval + rel->r_addend - (unsigned int)dest32; +#ifdef ELFDEBUG + ELFDEBUG("R_M32R_REL32 dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + break; + + case R_M32R_26_PCREL_RELA: + case R_M32R_26_PCREL: + { + signed long val; +#ifdef ELFDEBUG +#if defined(__m32r__use_got__) + if (ELF_R_TYPE(rel->r_info) == R_M32R_26_PLTREL) + ELFDEBUG("R_M32R_26_PLTREL\t"); + else +#endif + if (ELF_R_TYPE(rel->r_info) == R_M32R_26_PCREL_RELA) + ELFDEBUG("R_M32R_26_PCREL_RELA\t"); + else + ELFDEBUG("R_M32R_26_PCREL\t"); +#endif + dest32 = (unsigned int *)(secp + rel->r_offset); + val = (signed long)(*dest32 & 0xffffff) << 2; + val += symval + rel->r_addend - (unsigned int)dest32; + if (val < -0x2000000 || 0x1fffffc < val) + { +#if defined(__m32r__use_got__) + if (ELF_R_TYPE(rel->r_info) == R_M32R_26_PLTREL) + FatalError( "relocation overflow %lx for R_M32R_26_PLTREL\n", val); + else +#endif + FatalError( "relocation overflow %lx for R_M32R_26_PCREL\n", val); + } + *dest32 = (*dest32 & ~0xffffff) | ((val >> 2) & 0xffffff); +#ifdef ELFDEBUG + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + } + break; + case R_M32R_18_PCREL_RELA: + case R_M32R_18_PCREL: + { + signed long val; +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_18_PCREL_RELA) + ELFDEBUG("R_M32R_18_PCREL_RELA\t"); + else + ELFDEBUG("R_M32R_18_PCREL\t"); +#endif + dest32 = (unsigned int *)(secp + rel->r_offset); + val = (signed long)(*dest32 & 0xffff) << 2; + val += symval + rel->r_addend - (unsigned int)dest32; + if (val < -0x20000 || 0x1fffc < val) + FatalError( "relocation overflow %lx for R_M32R_18_PCREL\n", val); + *dest32 = (*dest32 & ~0xffff) | ((val >> 2) & 0xffff); +#ifdef ELFDEBUG + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + } + break; + case R_M32R_10_PCREL_RELA: + case R_M32R_10_PCREL: + { + signed long val; +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_10_PCREL_RELA) + ELFDEBUG("R_M32R_10_PCREL_RELA\t"); + else + ELFDEBUG("R_M32R_10_PCREL\t"); +#endif + dest16 = (unsigned short *)(secp + rel->r_offset); + val = (signed short)(*dest16 & 0xff) << 2; + val += symval + rel->r_addend - (unsigned int)dest16; + if (val < -0x200 || 0x1fc < val) + FatalError( "relocation overflow %lx for R_M32R_10_PCREL\n", val); + *dest16 = (*dest16 & ~0xff) | ((val >> 2) & 0xffff); +#ifdef ELFDEBUG + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest16=%x\t",dest16); + ELFDEBUG("*dest32=%x\n",*dest16); +#endif + } + break; + + case R_M32R_GOT24: +#if defined(__m32r__use_got__) + { + ELFGotEntryPtr gotent; + dest32 = (unsigned int *)(secp + rel->r_offset); + for (gotent=elffile->got_entries;gotent;gotent=gotent->next) { + if ( ELF_R_SYM(gotent->rel->r_info) == ELF_R_SYM(rel->r_info) && + gotent->rel->r_addend == rel->r_addend ) + break; + } + if (!gotent) + FatalError("\nCould not find GOT entry\n"); + + *(Elf32_Addr *)(elffile->got + gotent->offset) = symval + rel->r_addend; + *dest32 = (*dest32 & ~0xffffff) | (((*dest32 & 0xffffff) + gotent->offset + rel->r_addend) & 0xffffff); +#ifdef ELFDEBUG + ELFDEBUG("R_M32R_GOT24\t"); + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%x\n",*dest32); +#endif + } +#else + FatalError("\nunhandled reloc R_M32R_GOT24\n"); +#endif + break; + +#if 0 /* FIXME */ + +#if defined(__m32r__use_got__) + case R_M32R_GLOB_DAT: + case R_M32R_JMP_SLOT: + dest32 = (unsigned int *)(secp + rel->r_offset); + *dest32 = symval + rel->r_addend; +#ifdef ELFDEBUG + if (ELF_R_TYPE(rel->r_info) == R_M32R_GLOB_DAT) + ELFDEBUG("R_M32R_GLOB_DAT\t"); + else + ELFDEBUG("R_M32R_JMP_SLOT\t"); + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("dest32=%x\n",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + break; + + case R_M32R_RELATIVE: + dest32 = (unsigned int *)(secp + rel->r_offset); + *dest32 = (unsigned int)secp + rel->r_addend; +#ifdef ELFDEBUG + ELFDEBUG("R_M32R_RELATIVE\t"); + ELFDEBUG("%s\t",ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + break; + + case R_M32R_GOTPC24: + assert(elffile->got != 0); + dest32 = (unsigned int *)(secp + rel->r_offset); + *dest32 = (unsigned int)(*dest32 & ~0xffffff) | ((unsigned int)((*dest32 & 0xffffff) + elffile->got - (unsigned int)dest32 + rel->r_addend) & 0xffffff); +#ifdef ELFDEBUG + ELFDEBUG("R_M32R_GOTPC24 dest32=%x\t",dest32); + ELFDEBUG("*dest32=%lx\n",*dest32); +#endif + break; +#endif + +#else /* FIXME */ + case R_M32R_GLOB_DAT: + FatalError("\nunhandled reloc R_M32R_GLOB_DAT\n"); + break; + case R_M32R_JMP_SLOT: + FatalError("\nunhandled reloc R_M32R_JMP_SLOT\n"); + break; + case R_M32R_RELATIVE: + FatalError("\nunhandled reloc R_M32R_RELATIVE\n"); + break; + case R_M32R_GOTPC24: + FatalError("\nunhandled reloc R_M32R_GOTPC24\n"); + break; + case R_M32R_GOT16_HI_ULO: + FatalError("\nunhandled reloc R_M32R_GOT16_HI_ULO\n"); + break; + case R_M32R_GOT16_HI_SLO: + FatalError("\nunhandled reloc R_M32R_GOT16_HI_SLO\n"); + break; + case R_M32R_GOT16_LO: + FatalError("\nunhandled reloc R_M32R_GOT16_LO\n"); + break; + case R_M32R_GOTPC_HI_ULO: + FatalError("\nunhandled reloc R_M32R_GOTPC_HI_ULO\n"); + break; + case R_M32R_GOTPC_HI_SLO: + FatalError("\nunhandled reloc R_M32R_GOTPC_HI_SLO\n"); + break; + case R_M32R_GOTPC_LO: + FatalError("\nunhandled reloc R_M32R_GOTPC_LO\n"); + break; +#endif /* FIXME */ + + case R_M32R_GOTOFF: + FatalError("\nunhandled reloc R_M32R_GOTOFF\n"); + break; + case R_M32R_GOTOFF_HI_ULO: + FatalError("\nunhandled reloc R_M32R_GOTOFF_HI_ULO\n"); + break; + case R_M32R_GOTOFF_HI_SLO: + FatalError("\nunhandled reloc R_M32R_GOTOFF_HI_SLO\n"); + break; + case R_M32R_GOTOFF_LO: + FatalError("\nunhandled reloc R_M32R_GOTOFF_LO\n"); + break; + +#endif /* (__m32r__) */ + default: ErrorF("Elf_RelocateEntry() Unsupported relocation type %d\n", (int)ELF_R_TYPE(rel->r_info)); break; } + +#if defined(__m32r__) + _flush_cache(NULL, 0, 0); +#endif + return 0; } @@ -2588,6 +2960,11 @@ ELFCollectRelocations(elffile, index) } } #endif +#if defined(__m32r__use_got__) + if( ELF_R_TYPE(rel[i].r_info) == R_M32R_GOT24) { + ElfAddGOT(elffile,&rel[i]); + } +#endif tmp = ElfDelayRelocation(elffile, sect->sh_info, &(rel[i])); tmp->next = reloc_head; reloc_head = tmp; @@ -2762,7 +3139,7 @@ ELFCollectSections(ELFModulePtr elffile, int flags = 0; char *name = ElfGetSectionName(elffile, elffile->sections[i].sh_name); -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) if (!strcmp(name, ".got") /*Isn't there a more generic way to do this? */ # if defined(__ia64__) || !strcmp(name, ".plt") || !strcmp(name, ".IA_64.unwind_info") @@ -2925,7 +3302,7 @@ ELFLoadModule(loaderPtr modrec, int elff elffile->sections = (Elf_Shdr *) _LoaderFileToMem(elffd, header->e_shoff, elffile->secsize, "sections"); -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) /* * Need to allocate space for the .got section which will be * fabricated later @@ -2940,11 +3317,11 @@ ELFLoadModule(loaderPtr modrec, int elff elffile->secsize = (header->e_shentsize * header->e_shnum); elffile->sections = xf86loaderrealloc(elffile->sections, elffile->secsize); -#endif /*defined(__alpha__) || defined(__ia64__) */ +#endif /*defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) */ elffile->saddr = xf86loadercalloc(elffile->numsh, sizeof(unsigned char *)); -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) /* * Manually fill in the entry for the .got section so ELFCollectSections() * will be able to find it. @@ -2954,10 +3331,18 @@ ELFLoadModule(loaderPtr modrec, int elff elffile->sections[elffile->gotndx].sh_type = SHT_PROGBITS; elffile->sections[elffile->gotndx].sh_flags = SHF_WRITE | SHF_ALLOC; elffile->sections[elffile->gotndx].sh_size = 0; +#if defined(__m32r__) + elffile->sections[elffile->gotndx].sh_addralign = 4; +#else elffile->sections[elffile->gotndx].sh_addralign = 8; +#endif /* Add room to copy ".got", and maintain alignment */ +#if defined(__m32r__) + SecSize(header->e_shstrndx) += 8; +#else SecSize(header->e_shstrndx) += 8; #endif +#endif #if defined(__ia64__) /* * Manually fill in the entry for the .plt section so ELFCollectSections() @@ -2981,7 +3366,7 @@ ELFLoadModule(loaderPtr modrec, int elff _LoaderFileToMem(elffd, SecOffset(header->e_shstrndx), SecSize(header->e_shstrndx), ".shstrtab"); elffile->shstrndx = header->e_shstrndx; -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) /* * Add the string for the .got section */ @@ -3257,7 +3642,7 @@ ELFUnloadModule(void *modptr) CheckandFree(elffile->plt, elffile->pltsize); # endif #endif -#if defined(__alpha__) || defined(__ia64__) +#if defined(__alpha__) || defined(__ia64__) || defined(__m32r__use_got__) { ELFGotEntryPtr gotent; diff -rup xorg-server-1.0.2.org/hw/xfree86/loader/xf86sym.c xorg-server-1.0.2/hw/xfree86/loader/xf86sym.c --- xorg-server-1.0.2.org/hw/xfree86/loader/xf86sym.c 2005-10-30 18:27:06.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/loader/xf86sym.c 2006-07-24 14:24:42.534649512 +0900 @@ -239,6 +239,35 @@ extern unsigned long ldl_brx(volatile un extern unsigned short ldw_brx(volatile unsigned char *, int); #endif +#if defined(__m32r__) && defined(__linux__) +extern long __addsf3(long, long); +extern long __adddf3(long, long); +extern long __eqsf2(long, long); +extern long __eqdf2(long, long); +extern long __extendsfdf2(long); +extern long __fixsfsi(long); +extern long __fixdfsi(long); +extern long __fixunssfsi(long); +extern long __fixunsdfsi(long); +extern long __floatsisf(long); +extern long __floatsidf(long); +extern long __lesf2(long, long); +extern long __ledf2(long, long); +extern long __ltsf2(long, long); +extern long __ltdf2(long, long); +extern long __gtsf2(long, long); +extern long __gtdf2(long, long); +extern long __gesf2(long, long); +extern long __gedf2(long, long); +extern long __nesf2(long, long); +extern long __nedf2(long, long); +extern long __negsf2(long); +extern long __negdf2(long); +extern long __subsf3(long, long); +extern long __subdf3(long, long); +extern long __truncdfsf2(long); +#endif + /* XFree86 things */ LOOKUP xfree86LookupTab[] = { @@ -1017,7 +1046,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(ldl_u) SYMFUNC(eieio) SYMFUNC(ldl_brx) - SYMFUNC(ldw_brx) + SYMFUNC(dw_brx) SYMFUNC(stl_brx) SYMFUNC(stw_brx) SYMFUNC(ldq_u) @@ -1114,6 +1143,34 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(inw) SYMFUNC(inl) #endif +#if defined(__m32r__) + SYMFUNC(__addsf3) + SYMFUNC(__adddf3) + SYMFUNC(__eqsf2) + SYMFUNC(__eqdf2) + SYMFUNC(__extendsfdf2) + SYMFUNC(__fixsfsi) + SYMFUNC(__fixdfsi) + SYMFUNC(__fixunssfsi) + SYMFUNC(__fixunsdfsi) + SYMFUNC(__floatsisf) + SYMFUNC(__floatsidf) + SYMFUNC(__lesf2) + SYMFUNC(__ledf2) + SYMFUNC(__ltsf2) + SYMFUNC(__ltdf2) + SYMFUNC(__gesf2) + SYMFUNC(__gedf2) + SYMFUNC(__gtsf2) + SYMFUNC(__gtdf2) + SYMFUNC(__nesf2) + SYMFUNC(__nedf2) + SYMFUNC(__negsf2) + SYMFUNC(__negdf2) + SYMFUNC(__subsf3) + SYMFUNC(__subdf3) + SYMFUNC(__truncdfsf2) +#endif #ifdef __FreeBSD__ #if defined(__sparc__) diff -rup xorg-server-1.0.2.org/hw/xfree86/os-support/bus/Pci.c xorg-server-1.0.2/hw/xfree86/os-support/bus/Pci.c --- xorg-server-1.0.2.org/hw/xfree86/os-support/bus/Pci.c 2005-11-09 04:04:56.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/os-support/bus/Pci.c 2006-07-24 14:27:33.025730928 +0900 @@ -248,6 +248,7 @@ PCITAG (*pciFindNextFP)(void) = pciG void pciInit() { +#if !defined(__m32r__) if (pciInitialized) return; @@ -264,6 +265,7 @@ pciInit() if (pciNumBuses <= 0) ARCH_PCI_OS_INIT(); #endif +#endif /* ! __m32r__ */ } PCITAG diff -rup xorg-server-1.0.2.org/hw/xfree86/os-support/bus/Pci.h xorg-server-1.0.2/hw/xfree86/os-support/bus/Pci.h --- xorg-server-1.0.2.org/hw/xfree86/os-support/bus/Pci.h 2005-11-09 04:04:56.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/os-support/bus/Pci.h 2006-07-24 14:28:29.939078784 +0900 @@ -318,6 +318,12 @@ # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif +#elif defined(__m32r__) +# if defined(linux) +# define ARCH_PCI_INIT linuxPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN +# endif #elif defined(__sparc__) || defined(sparc) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit diff -rup xorg-server-1.0.2.org/hw/xfree86/os-support/linux/lnxResource.c xorg-server-1.0.2/hw/xfree86/os-support/linux/lnxResource.c --- xorg-server-1.0.2.org/hw/xfree86/os-support/linux/lnxResource.c 2005-07-03 16:01:32.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/os-support/linux/lnxResource.c 2006-07-24 14:29:17.902787192 +0900 @@ -189,6 +189,7 @@ xf86AccResFromOS(resPtr ret) defined(__sparc__) || \ defined(__mips__) || \ defined(__sh__) || \ + defined(__m32r__) || \ defined(__mc68000__) || \ defined(__arm__) || \ defined(__s390__) || \ diff -rup xorg-server-1.0.2.org/hw/xfree86/os-support/linux/lnx_video.c xorg-server-1.0.2/hw/xfree86/os-support/linux/lnx_video.c --- xorg-server-1.0.2.org/hw/xfree86/os-support/linux/lnx_video.c 2006-07-13 16:25:45.000000000 +0900 +++ xorg-server-1.0.2/hw/xfree86/os-support/linux/lnx_video.c 2006-07-24 14:31:02.077950160 +0900 @@ -569,7 +569,7 @@ xf86EnableIO(void) #endif } close(fd); -#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) +#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) if (ioperm(0, 1024, 1) || iopl(3)) { if (errno == ENODEV) ErrorF("xf86EnableIOPorts: no I/O ports found\n"); @@ -596,7 +596,7 @@ xf86DisableIO(void) #if defined(__powerpc__) munmap(ioBase, 0x20000); ioBase = NULL; -#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) +#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__m32r__) iopl(0); ioperm(0, 1024, 0); #endif @@ -615,12 +615,12 @@ xf86DisableIO(void) Bool xf86DisableInterrupts() { -#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) +#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__m32r__) if (!ExtendedEnabled) if (iopl(3) || ioperm(0, 1024, 1)) return (FALSE); #endif -#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__) +#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__) || defined(__m32r__) #else # ifdef __GNUC__ # if defined(__ia64__) @@ -634,7 +634,7 @@ xf86DisableInterrupts() asm("cli"); # endif #endif -#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) +#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && !defined(__m32r__) if (!ExtendedEnabled) { iopl(0); ioperm(0, 1024, 0); @@ -647,12 +647,12 @@ xf86DisableInterrupts() void xf86EnableInterrupts() { -#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) +#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__m32r__) if (!ExtendedEnabled) if (iopl(3) || ioperm(0, 1024, 1)) return; #endif -#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__) +#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__) || defined(__arm__) || defined(__sh__) || defined(__ia64__) || defined(__hppa__) || defined(__m32r__) #else # ifdef __GNUC__ # if defined(__ia64__) @@ -666,7 +666,7 @@ xf86EnableInterrupts() asm("sti"); # endif #endif -#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) +#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && !defined(__m32r__) if (!ExtendedEnabled) { iopl(0); ioperm(0, 1024, 0); diff -rup xorg-server-1.0.2.org/include/servermd.h xorg-server-1.0.2/include/servermd.h --- xorg-server-1.0.2.org/include/servermd.h 2006-07-13 16:25:47.000000000 +0900 +++ xorg-server-1.0.2/include/servermd.h 2006-07-24 14:32:49.219662144 +0900 @@ -210,6 +210,26 @@ SOFTWARE. #endif /* SuperH */ +#if defined(__m32r__) + +#if defined(__BIG_ENDIAN__) +# define IMAGE_BYTE_ORDER MSBFirst +# define BITMAP_BIT_ORDER MSBFirst +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +#else +# define IMAGE_BYTE_ORDER LSBFirst +# define BITMAP_BIT_ORDER LSBFirst +# define GLYPHPADBYTES 4 +# define GETLEFTBITS_ALIGNMENT 1 +#endif + +#define AVOID_MEMORY_READ +#define FAST_CONSTANT_OFFSET_MODE +#define LARGE_INSTRUCTION_CACHE +#define PLENTIFUL_REGISTERS + +#endif /* __m32r__ */ #if (defined(sun) && (defined(__sparc) || defined(sparc))) || \ (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \