diff options
Diffstat (limited to 'hw/xfree86/loader')
25 files changed, 6551 insertions, 6101 deletions
diff --git a/hw/xfree86/loader/aout.h b/hw/xfree86/loader/aout.h index 2e58f2cab..cd7807531 100644 --- a/hw/xfree86/loader/aout.h +++ b/hw/xfree86/loader/aout.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/aout.h,v 1.7 2002/05/31 18:46:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/aout.h,v 1.8 2003/10/15 16:29:02 dawes Exp $ */ /* * Borrowed from NetBSD's exec_aout.h @@ -41,8 +41,8 @@ #include <ctype.h> /* OS/2 EMX has ntohl in this file */ -#ifdef __UNIXOS2__ -#include <sys/param.h> +#ifdef __UNIXOS2__ +#include <sys/param.h> #endif #define __LDPGSZ 4096U @@ -54,44 +54,44 @@ * a.out header */ typedef struct AOUT_exec { - unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */ - unsigned long a_text; /* text segment size */ - unsigned long a_data; /* initialized data size */ - unsigned long a_bss; /* uninitialized data size */ - unsigned long a_syms; /* symbol table size */ - unsigned long a_entry; /* entry point */ - unsigned long a_trsize; /* text relocation size */ - unsigned long a_drsize; /* data relocation size */ + unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */ + unsigned long a_text; /* text segment size */ + unsigned long a_data; /* initialized data size */ + unsigned long a_bss; /* uninitialized data size */ + unsigned long a_syms; /* symbol table size */ + unsigned long a_entry; /* entry point */ + unsigned long a_trsize; /* text relocation size */ + unsigned long a_drsize; /* data relocation size */ } AOUTHDR; /* a_magic */ -#define OMAGIC 0407 /* old impure format */ -#define NMAGIC 0410 /* read-only text */ -#define ZMAGIC 0413 /* demand load format */ -#define QMAGIC 0314 /* "compact" demand load format; deprecated */ +#define OMAGIC 0407 /* old impure format */ +#define NMAGIC 0410 /* read-only text */ +#define ZMAGIC 0413 /* demand load format */ +#define QMAGIC 0314 /* "compact" demand load format; deprecated */ /* * a_mid - keep sorted in numerical order for sanity's sake * ensure that: 0 < mid < 0x3ff */ -#define MID_ZERO 0 /* unknown - implementation dependent */ -#define MID_SUN010 1 /* sun 68010/68020 binary */ -#define MID_SUN020 2 /* sun 68020-only binary */ -#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */ -#define MID_HP200 200 /* hp200 (68010) BSD binary */ -#define MID_I386 134 /* i386 BSD binary */ -#define MID_M68K 135 /* m68k BSD binary with 8K page sizes */ -#define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */ -#define MID_NS32532 137 /* ns32532 */ -#define MID_SPARC 138 /* sparc */ -#define MID_PMAX 139 /* pmax */ -#define MID_VAX 140 /* vax */ -#define MID_ALPHA 141 /* Alpha BSD binary */ -#define MID_MIPS 142 /* big-endian MIPS */ -#define MID_ARM6 143 /* ARM6 */ -#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ -#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ -#define MID_HPUX800 0x20B /* hp800 HP-UX binary */ +#define MID_ZERO 0 /* unknown - implementation dependent */ +#define MID_SUN010 1 /* sun 68010/68020 binary */ +#define MID_SUN020 2 /* sun 68020-only binary */ +#define MID_PC386 100 /* 386 PC binary. (so quoth BFD) */ +#define MID_HP200 200 /* hp200 (68010) BSD binary */ +#define MID_I386 134 /* i386 BSD binary */ +#define MID_M68K 135 /* m68k BSD binary with 8K page sizes */ +#define MID_M68K4K 136 /* m68k BSD binary with 4K page sizes */ +#define MID_NS32532 137 /* ns32532 */ +#define MID_SPARC 138 /* sparc */ +#define MID_PMAX 139 /* pmax */ +#define MID_VAX 140 /* vax */ +#define MID_ALPHA 141 /* Alpha BSD binary */ +#define MID_MIPS 142 /* big-endian MIPS */ +#define MID_ARM6 143 /* ARM6 */ +#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ +#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ +#define MID_HPUX800 0x20B /* hp800 HP-UX binary */ /* * a_flags @@ -179,19 +179,19 @@ typedef struct AOUT_exec { #define AOUT_STROFF(ex) \ (AOUT_SYMOFF(ex) + (ex)->a_syms) - /* Relocation format. */ struct relocation_info_i386 { - int r_address; /* offset in text or data segment */ - unsigned int r_symbolnum : 24, /* ordinal number of add symbol */ - r_pcrel : 1, /* 1 if value should be pc-relative */ - r_length : 2, /* log base 2 of value's width */ - r_extern : 1, /* 1 if need to add symbol to value */ - r_baserel : 1, /* linkage table relative */ - r_jmptable : 1, /* relocate to jump table */ - r_relative : 1, /* load address relative */ - r_copy : 1; /* run time copy */ + int r_address; /* offset in text or data segment */ + unsigned int r_symbolnum:24, /* ordinal number of add symbol */ + r_pcrel:1, /* 1 if value should be pc-relative */ + r_length:2, /* log base 2 of value's width */ + r_extern:1, /* 1 if need to add symbol to value */ + r_baserel:1, /* linkage table relative */ + r_jmptable:1, /* relocate to jump table */ + r_relative:1, /* load address relative */ + r_copy:1; /* run time copy */ }; + #define relocation_info relocation_info_i386 /* @@ -200,33 +200,32 @@ struct relocation_info_i386 { */ typedef struct AOUT_nlist { union { - char *n_name; /* symbol name (in memory) */ - long n_strx; /* file string table offset (on disk) */ + char *n_name; /* symbol name (in memory) */ + long n_strx; /* file string table offset (on disk) */ } n_un; - -#define AOUT_UNDF 0x00 /* undefined */ -#define AOUT_ABS 0x02 /* absolute address */ -#define AOUT_TEXT 0x04 /* text segment */ -#define AOUT_DATA 0x06 /* data segment */ -#define AOUT_BSS 0x08 /* bss segment */ -#define AOUT_INDR 0x0a /* alias definition */ -#define AOUT_SIZE 0x0c /* pseudo type, defines a symbol's size */ -#define AOUT_COMM 0x12 /* common reference */ -#define AOUT_FN 0x1e /* file name (AOUT_EXT on) */ -#define AOUT_WARN 0x1e /* warning message (AOUT_EXT off) */ - -#define AOUT_EXT 0x01 /* external (global) bit, OR'ed in */ -#define AOUT_TYPE 0x1e /* mask for all the type bits */ - unsigned char n_type; /* type defines */ - - char n_other; /* spare */ -#define n_hash n_desc /* used internally by ld(1); XXX */ - short n_desc; /* used by stab entries */ - unsigned long n_value; /* address/value of the symbol */ +#define AOUT_UNDF 0x00 /* undefined */ +#define AOUT_ABS 0x02 /* absolute address */ +#define AOUT_TEXT 0x04 /* text segment */ +#define AOUT_DATA 0x06 /* data segment */ +#define AOUT_BSS 0x08 /* bss segment */ +#define AOUT_INDR 0x0a /* alias definition */ +#define AOUT_SIZE 0x0c /* pseudo type, defines a symbol's size */ +#define AOUT_COMM 0x12 /* common reference */ +#define AOUT_FN 0x1e /* file name (AOUT_EXT on) */ +#define AOUT_WARN 0x1e /* warning message (AOUT_EXT off) */ + +#define AOUT_EXT 0x01 /* external (global) bit, OR'ed in */ +#define AOUT_TYPE 0x1e /* mask for all the type bits */ + unsigned char n_type; /* type defines */ + + char n_other; /* spare */ +#define n_hash n_desc /* used internally by ld(1); XXX */ + short n_desc; /* used by stab entries */ + unsigned long n_value; /* address/value of the symbol */ } AOUT_nlist; -#define AOUT_FORMAT "%08x" /* namelist value format; XXX */ -#define AOUT_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */ +#define AOUT_FORMAT "%08x" /* namelist value format; XXX */ +#define AOUT_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */ #endif diff --git a/hw/xfree86/loader/aoutloader.c b/hw/xfree86/loader/aoutloader.c index 98e657dca..f77b3d73c 100644 --- a/hw/xfree86/loader/aoutloader.c +++ b/hw/xfree86/loader/aoutloader.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/aoutloader.c,v 1.17 2001/11/16 16:47:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/aoutloader.c,v 1.20 2003/10/15 17:46:00 dawes Exp $ */ /* * @@ -52,10 +52,13 @@ #include "loader.h" #include "aoutloader.h" -/* -#define AOUTDEBUG ErrorF -*/ +#ifndef LOADERDEBUG +#define LOADERDEBUG 0 +#endif +#if LOADERDEBUG +#define AOUTDEBUG ErrorF +#endif #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) @@ -67,22 +70,22 @@ */ typedef struct { - int handle; - int module; - int fd; - loader_funcs *funcs; - AOUTHDR *header;/* file header */ - unsigned char *text; /* Start address of the text section */ - unsigned int textsize; /* Size of the text section */ - unsigned char *data; /* Start address of the data section */ - unsigned int datasize; /* Size of the data section */ - unsigned char *bss; /* Start address of the bss data */ - unsigned int bsssize; /* Size of the bss section */ - struct relocation_info *txtrel; /* Start address of the text relocation table */ - struct relocation_info *datarel; /* Start address of the data relocation table */ - AOUT_nlist *symtab; /* Start address of the symbol table */ - unsigned char *strings; /* Start address of the string table */ - unsigned long strsize; /* size of string table */ + int handle; + int module; + int fd; + loader_funcs *funcs; + AOUTHDR *header; /* file header */ + unsigned char *text; /* Start address of the text section */ + unsigned int textsize; /* Size of the text section */ + unsigned char *data; /* Start address of the data section */ + unsigned int datasize; /* Size of the data section */ + unsigned char *bss; /* Start address of the bss data */ + unsigned int bsssize; /* Size of the bss section */ + struct relocation_info *txtrel; /* Start address of the text relocation table */ + struct relocation_info *datarel; /* Start address of the data relocation table */ + AOUT_nlist *symtab; /* Start address of the symbol table */ + unsigned char *strings; /* Start address of the string table */ + unsigned long strsize; /* size of string table */ unsigned char *common; /* Start address of the common data */ unsigned long comsize; /* size of common data */ } AOUTModuleRec, *AOUTModulePtr; @@ -121,10 +124,12 @@ static void *AOUTGetSymbolValue(AOUTModulePtr, int); static AOUTCommonPtr AOUTAddCommon(struct AOUT_nlist *, int); static LOOKUP *AOUTCreateCommon(AOUTModulePtr); static LOOKUP *AOUT_GetSymbols(AOUTModulePtr); -static AOUTRelocPtr AOUTDelayRelocation(AOUTModulePtr, int, struct relocation_info_i386 *); +static AOUTRelocPtr AOUTDelayRelocation(AOUTModulePtr, int, + struct relocation_info_i386 *); static AOUTRelocPtr AOUTCollectRelocations(AOUTModulePtr); static void AOUT_Relocate(unsigned long *, unsigned long, int); -static AOUTRelocPtr AOUT_RelocateEntry(AOUTModulePtr, int, struct relocation_info_i386 *); +static AOUTRelocPtr AOUT_RelocateEntry(AOUTModulePtr, int, + struct relocation_info_i386 *); /* * Return 1 if the symbol in item belongs to aoutfile @@ -133,6 +138,7 @@ static int AOUTHashCleanOut(void *voidptr, itemPtr item) { AOUTModulePtr aoutfile = (AOUTModulePtr) voidptr; + return (aoutfile->handle == item->handle); } @@ -140,8 +146,8 @@ AOUTHashCleanOut(void *voidptr, itemPtr item) * Manage listResolv */ static AOUTRelocPtr -AOUTDelayRelocation(AOUTModulePtr aoutfile, int type, - struct relocation_info *rel) +AOUTDelayRelocation(AOUTModulePtr aoutfile, int type, + struct relocation_info *rel) { AOUTRelocPtr reloc; @@ -158,8 +164,6 @@ AOUTDelayRelocation(AOUTModulePtr aoutfile, int type, reloc->next = 0; return reloc; } - - /* * Manage listCOMMON @@ -170,8 +174,8 @@ AOUTAddCommon(struct AOUT_nlist *sym, int index) { AOUTCommonPtr common; - if ((common = xf86loadermalloc(sizeof (AOUTCommonRec))) == NULL) { - ErrorF( "AOUTAddCommon() Unable to allocate memory\n" ); + if ((common = xf86loadermalloc(sizeof(AOUTCommonRec))) == NULL) { + ErrorF("AOUTAddCommon() Unable to allocate memory\n"); return 0; } common->sym = sym; @@ -183,8 +187,8 @@ AOUTAddCommon(struct AOUT_nlist *sym, int index) static LOOKUP * AOUTCreateCommon(AOUTModulePtr aoutfile) { - int numsyms = 0, size = 0, l = 0; - int offset = 0; + int numsyms = 0, size = 0, l = 0; + int offset = 0; AOUTCommonPtr common; LOOKUP *lookup; @@ -194,46 +198,47 @@ AOUTCreateCommon(AOUTModulePtr aoutfile) common = listCOMMON; for (common = listCOMMON; common; common = common->next) { /* Ensure long word alignment */ - if( (common->sym->n_value & (sizeof(long)-1)) != 0 ) - common->sym->n_value = (common->sym->n_value + (sizeof(long)-1)) - & ~(sizeof(long)-1); + if ((common->sym->n_value & (sizeof(long) - 1)) != 0) + common->sym->n_value = (common->sym->n_value + (sizeof(long) - 1)) + & ~(sizeof(long) - 1); /* accumulate the sizes */ size += common->sym->n_value; numsyms++; - } /* while */ + } /* while */ #ifdef AOUTDEBUG AOUTDEBUG("AOUTCreateCommon() %d entries (%d bytes) of COMMON data\n", - numsyms, size ); + numsyms, size); #endif - - if ((lookup = xf86loadermalloc((numsyms+1)*sizeof(LOOKUP))) == NULL) { - ErrorF( "AOUTCreateCommon() Unable to allocate memory\n" ); - return NULL; + + if ((lookup = xf86loadermalloc((numsyms + 1) * sizeof(LOOKUP))) == NULL) { + ErrorF("AOUTCreateCommon() Unable to allocate memory\n"); + return NULL; } - + aoutfile->comsize = size; - if ((aoutfile->common = xf86loadercalloc(1,size)) == NULL) { - ErrorF( "AOUTCreateCommon() Unable to allocate memory\n" ); - return NULL; + if ((aoutfile->common = xf86loadercalloc(1, size)) == NULL) { + ErrorF("AOUTCreateCommon() Unable to allocate memory\n"); + return NULL; } - + while (listCOMMON) { - common = listCOMMON; - lookup[l].symName= AOUTGetSymbolName(aoutfile, common->sym); - lookup[l].offset = (funcptr)(aoutfile->common+offset); + common = listCOMMON; + lookup[l].symName = AOUTGetSymbolName(aoutfile, common->sym); + lookup[l].offset = (funcptr) (aoutfile->common + offset); #ifdef AOUTDEBUG - AOUTDEBUG("Adding %x %s\n", lookup[l].offset, lookup[l].symName ); + AOUTDEBUG("Adding %p %s\n", (void *)lookup[l].offset, + lookup[l].symName); #endif - listCOMMON = common->next; - offset += common->sym->n_value; - xf86loaderfree(common); - l++; - } /* while */ + listCOMMON = common->next; + offset += common->sym->n_value; + xf86loaderfree(common); + l++; + } /* while */ /* listCOMMON == NULL */ - lookup[l].symName=NULL; /* Terminate the list */ + lookup[l].symName = NULL; /* Terminate the list */ return lookup; } @@ -244,7 +249,7 @@ AOUTCreateCommon(AOUTModulePtr aoutfile) static char * AOUTGetString(AOUTModulePtr aoutfile, int index) { - char *symname = (char *) &(aoutfile->strings[index]); + char *symname = (char *)&(aoutfile->strings[index]); if (symname[0] == '_') { symname++; @@ -252,20 +257,21 @@ AOUTGetString(AOUTModulePtr aoutfile, int index) return symname; } + /* * Return the name of a symbol */ static char * AOUTGetSymbolName(AOUTModulePtr aoutfile, struct AOUT_nlist *sym) { - char *symname = AOUTGetString(aoutfile,sym->n_un.n_strx); + char *symname = AOUTGetString(aoutfile, sym->n_un.n_strx); char *name; - name=xf86loadermalloc(strlen(symname)+1); + name = xf86loadermalloc(strlen(symname) + 1); if (!name) FatalError("AOUTGetSymbolName: Out of memory\n"); - strcpy(name,symname); + strcpy(name, symname); return name; } @@ -276,13 +282,13 @@ AOUTGetSymbolName(AOUTModulePtr aoutfile, struct AOUT_nlist *sym) static void * AOUTGetSymbolValue(AOUTModulePtr aoutfile, int index) { - void *symval = NULL; /* value of the indicated symbol */ - itemPtr symbol = NULL; /* name/value of symbol */ + void *symval = NULL; /* value of the indicated symbol */ + itemPtr symbol = NULL; /* name/value of symbol */ char *name = NULL; name = AOUTGetSymbolName(aoutfile, aoutfile->symtab + index); - if( name ) + if (name) symbol = LoaderHashFind(name); if (symbol) @@ -292,7 +298,6 @@ AOUTGetSymbolValue(AOUTModulePtr aoutfile, int index) return symval; } - /* * Perform the actual relocation */ @@ -300,28 +305,27 @@ static void AOUT_Relocate(unsigned long *destl, unsigned long val, int pcrel) { #ifdef AOUTDEBUG - AOUTDEBUG("AOUT_Relocate %p : %08x %s", - destl, *destl, pcrel == 1 ? "rel" : "abs"); + AOUTDEBUG("AOUT_Relocate %p : %08lx %s", + (void *)destl, *destl, pcrel == 1 ? "rel" : "abs"); #endif if (pcrel) { /* relative to PC */ - *destl = val - ((unsigned long)destl + sizeof(long)); + *destl = val - ((unsigned long)destl + sizeof(long)); } else { *destl += val; } #ifdef AOUTDEBUG - AOUTDEBUG(" -> %08x\n", *destl); + AOUTDEBUG(" -> %08lx\n", *destl); #endif } - /* * Fix the relocation for text or data section */ static AOUTRelocPtr AOUT_RelocateEntry(AOUTModulePtr aoutfile, int type, - struct relocation_info *rel) + struct relocation_info *rel) { AOUTHDR *header = aoutfile->header; AOUT_nlist *symtab = aoutfile->symtab; @@ -330,22 +334,23 @@ AOUT_RelocateEntry(AOUTModulePtr aoutfile, int type, unsigned long *destl; /* address of the location to be modified */ symnum = rel->r_symbolnum; -#ifdef AOUTDEBUG +#ifdef AOUTDEBUG { - char *name; - if (rel->r_extern) { - AOUTDEBUG("AOUT_RelocateEntry: extern %s\n", - name=AOUTGetSymbolName(aoutfile, symtab+symnum)); - xf86loaderfree(name); - } else { - AOUTDEBUG("AOUT_RelocateEntry: intern\n"); - } - AOUTDEBUG(" pcrel: %d", rel->r_pcrel); - AOUTDEBUG(" length: %d", rel->r_length); - AOUTDEBUG(" baserel: %d", rel->r_baserel); - AOUTDEBUG(" jmptable: %d", rel->r_jmptable); - AOUTDEBUG(" relative: %d", rel->r_relative); - AOUTDEBUG(" copy: %d\n", rel->r_copy); + char *name; + + if (rel->r_extern) { + AOUTDEBUG("AOUT_RelocateEntry: extern %s\n", + name = AOUTGetSymbolName(aoutfile, symtab + symnum)); + xf86loaderfree(name); + } else { + AOUTDEBUG("AOUT_RelocateEntry: intern\n"); + } + AOUTDEBUG(" pcrel: %d", rel->r_pcrel); + AOUTDEBUG(" length: %d", rel->r_length); + AOUTDEBUG(" baserel: %d", rel->r_baserel); + AOUTDEBUG(" jmptable: %d", rel->r_jmptable); + AOUTDEBUG(" relative: %d", rel->r_relative); + AOUTDEBUG(" copy: %d\n", rel->r_copy); } #endif /* AOUTDEBUG */ @@ -356,15 +361,15 @@ AOUT_RelocateEntry(AOUTModulePtr aoutfile, int type, * First find the address to modify */ switch (type) { - case AOUT_TEXT: + case AOUT_TEXT: /* Check that the relocation offset is in the text segment */ if (rel->r_address > header->a_text) { ErrorF("AOUT_RelocateEntry(): " "text relocation out of text section\n"); - } + } destl = (unsigned long *)(aoutfile->text + rel->r_address); break; - case AOUT_DATA: + case AOUT_DATA: /* Check that the relocation offset is in the data segment */ if (rel->r_address > header->a_data) { ErrorF("AOUT_RelocateEntry():" @@ -372,10 +377,10 @@ AOUT_RelocateEntry(AOUTModulePtr aoutfile, int type, } destl = (unsigned long *)(aoutfile->data + rel->r_address); break; - default: + default: ErrorF("AOUT_RelocateEntry(): unknown section type %d\n", type); return 0; - } /* switch */ + } /* switch */ /* * Now handle the relocation @@ -385,70 +390,70 @@ AOUT_RelocateEntry(AOUTModulePtr aoutfile, int type, symval = AOUTGetSymbolValue(aoutfile, symnum); if (symval != 0) { /* we've got the value */ - AOUT_Relocate(destl, (unsigned long) symval, rel->r_pcrel); + AOUT_Relocate(destl, (unsigned long)symval, rel->r_pcrel); return 0; } else { /* The symbol should be undefined */ switch (symtab[symnum].n_type & AOUT_TYPE) { - case AOUT_UNDF: + case AOUT_UNDF: #ifdef AOUTDEBUG AOUTDEBUG(" extern AOUT_UNDEF\n"); #endif /* Add this relocation back to the global list */ - return AOUTDelayRelocation(aoutfile,type,rel); + return AOUTDelayRelocation(aoutfile, type, rel); - default: + default: ErrorF("AOUT_RelocateEntry():" - " impossible intern relocation type: %d\n", + " impossible intern relocation type: %d\n", symtab[symnum].n_type); return 0; - } /* switch */ + } /* switch */ } } else { /* intern */ switch (rel->r_symbolnum) { - case AOUT_TEXT: + case AOUT_TEXT: #ifdef AOUTDEBUG AOUTDEBUG(" AOUT_TEXT\n"); #endif /* Only absolute intern text relocations need to be handled */ - if (rel->r_pcrel == 0) - AOUT_Relocate(destl, (unsigned long)aoutfile->text, + if (rel->r_pcrel == 0) + AOUT_Relocate(destl, (unsigned long)aoutfile->text, rel->r_pcrel); return 0; - case AOUT_DATA: + case AOUT_DATA: #ifdef AOUTDEBUG AOUTDEBUG(" AOUT_DATA\n"); #endif - if (rel->r_pcrel == 0) + if (rel->r_pcrel == 0) AOUT_Relocate(destl, (unsigned long)aoutfile->data - header->a_text, rel->r_pcrel); else ErrorF("AOUT_RelocateEntry(): " "don't know how to handle data pc-relative reloc\n"); - + return 0; - case AOUT_BSS: + case AOUT_BSS: #ifdef AOUTDEBUG AOUTDEBUG(" AOUT_BSS\n"); #endif if (rel->r_pcrel == 0) AOUT_Relocate(destl, (unsigned long)aoutfile->bss - - header->a_text - header->a_data, + - header->a_text - header->a_data, rel->r_pcrel); else ErrorF("AOUT_RelocateEntry(): " "don't know how to handle bss pc-relative reloc\n"); - + return 0; - default: + default: ErrorF("AOUT_RelocateEntry():" " unknown intern relocation type: %d\n", rel->r_symbolnum); return 0; - } /* switch */ + } /* switch */ } -} /* AOUT_RelocateEntry */ - +} /* AOUT_RelocateEntry */ + static AOUTRelocPtr AOUTCollectRelocations(AOUTModulePtr aoutfile) { @@ -460,7 +465,7 @@ AOUTCollectRelocations(AOUTModulePtr aoutfile) /* Text relocations */ if (aoutfile->text != NULL && aoutfile->txtrel != NULL) { - nreloc = header->a_trsize/sizeof(struct relocation_info); + nreloc = header->a_trsize / sizeof(struct relocation_info); for (i = 0; i < nreloc; i++) { rel = aoutfile->txtrel + i; @@ -469,28 +474,28 @@ AOUTCollectRelocations(AOUTModulePtr aoutfile) tmp->next = reloc_head; reloc_head = tmp; } - } /* for */ + } /* for */ } /* Data relocations */ if (aoutfile->data != NULL && aoutfile->datarel != NULL) { - nreloc = header->a_drsize/sizeof(struct relocation_info); - + nreloc = header->a_drsize / sizeof(struct relocation_info); + for (i = 0; i < nreloc; i++) { rel = aoutfile->datarel + i; tmp = AOUTDelayRelocation(aoutfile, AOUT_DATA, rel); tmp->next = reloc_head; reloc_head = tmp; - } /* for */ + } /* for */ } return reloc_head; -} /* AOUTCollectRelocations */ +} /* AOUTCollectRelocations */ /* * AOUT_GetSymbols() * * add the symbols to the loader's symbol table */ -static LOOKUP * +static LOOKUP * AOUT_GetSymbols(AOUTModulePtr aoutfile) { int fd = aoutfile->fd; @@ -501,11 +506,11 @@ AOUT_GetSymbols(AOUTModulePtr aoutfile) LOOKUP *lookup, *lookup_common; AOUTCommonPtr tmp; - aoutfile->symtab = (AOUT_nlist *)_LoaderFileToMem(fd, - AOUT_SYMOFF(header), - header->a_syms, - "symbols"); - nsyms = header->a_syms/sizeof(AOUT_nlist); + aoutfile->symtab = (AOUT_nlist *) _LoaderFileToMem(fd, + AOUT_SYMOFF(header), + header->a_syms, + "symbols"); + nsyms = header->a_syms / sizeof(AOUT_nlist); lookup = xf86loadermalloc(nsyms * sizeof(LOOKUP)); if (lookup == NULL) { ErrorF("AOUT_GetSymbols(): can't allocate memory\n"); @@ -513,17 +518,16 @@ AOUT_GetSymbols(AOUTModulePtr aoutfile) } for (i = 0, l = 0; i < nsyms; i++) { s = aoutfile->symtab + i; - soff=s->n_un.n_strx; - if (soff == 0 || (s->n_type & AOUT_STAB) != 0) + soff = s->n_un.n_strx; + if (soff == 0 || (s->n_type & AOUT_STAB) != 0) continue; - symname=AOUTGetSymbolName(aoutfile,s); + symname = AOUTGetSymbolName(aoutfile, s); #ifdef AOUTDEBUG - AOUTDEBUG("AOUT_GetSymbols(): %s %02x %02x %08x\n", - symname, s->n_type, - s->n_other, s->n_value); + AOUTDEBUG("AOUT_GetSymbols(): %s %02x %02x %08lx\n", + symname, s->n_type, s->n_other, s->n_value); #endif switch (s->n_type & AOUT_TYPE) { - case AOUT_UNDF: + case AOUT_UNDF: if (s->n_value != 0) { if (!LoaderHashFind(symname)) { #ifdef AOUTDEBUG @@ -542,51 +546,54 @@ AOUT_GetSymbols(AOUTModulePtr aoutfile) } xf86loaderfree(symname); break; - case AOUT_TEXT: + case AOUT_TEXT: if (s->n_type & AOUT_EXT) { lookup[l].symName = symname; /* text symbols start at 0 */ - lookup[l].offset = (funcptr)(aoutfile->text + s->n_value); + lookup[l].offset = (funcptr) (aoutfile->text + s->n_value); #ifdef AOUTDEBUG - AOUTDEBUG("Adding text %s %08x\n", symname, lookup[l].offset); + AOUTDEBUG("Adding text %s %p\n", symname, + (void *)lookup[l].offset); #endif l++; } else { xf86loaderfree(symname); } break; - case AOUT_DATA : + case AOUT_DATA: if (s->n_type & AOUT_EXT) { lookup[l].symName = symname; /* data symbols are following text */ - lookup[l].offset = (funcptr)(aoutfile->data + - s->n_value - header->a_text); + lookup[l].offset = (funcptr) (aoutfile->data + + s->n_value - header->a_text); #ifdef AOUTDEBUG - AOUTDEBUG("Adding data %s %08x\n", symname, lookup[l].offset); + AOUTDEBUG("Adding data %s %p\n", symname, + (void *)lookup[l].offset); #endif l++; } else { xf86loaderfree(symname); } break; - case AOUT_BSS: + case AOUT_BSS: if (s->n_type & AOUT_EXT) { lookup[l].symName = symname; /* bss symbols follow both text and data */ - lookup[l].offset = (funcptr)(aoutfile->bss + s->n_value - - (header->a_data - + header->a_text)); + lookup[l].offset = (funcptr) (aoutfile->bss + s->n_value + - (header->a_data + + header->a_text)); #ifdef AOUTDEBUG - AOUTDEBUG("Adding bss %s %08x\n", symname, lookup[l].offset); + AOUTDEBUG("Adding bss %s %p\n", symname, + (void *)lookup[l].offset); #endif l++; } else { xf86loaderfree(symname); } break; - case AOUT_FN: + case AOUT_FN: #ifdef AOUTDEBUG - if (n->n_type& AOUT_EXT) { + if (s->n_type & AOUT_EXT) { AOUTDEBUG("Ignoring AOUT_FN %s\n", symname); } else { AOUTDEBUG("Ignoring AOUT_WARN %s\n", symname); @@ -594,68 +601,66 @@ AOUT_GetSymbols(AOUTModulePtr aoutfile) #endif xf86loaderfree(symname); break; - default: - ErrorF("Unknown symbol type %x\n", s->n_type & AOUT_TYPE); - xf86loaderfree(symname); - } /* switch */ - } /* for */ + default: + ErrorF("Unknown symbol type %x\n", s->n_type & AOUT_TYPE); + xf86loaderfree(symname); + } /* switch */ + } /* for */ lookup[l].symName = NULL; - + lookup_common = AOUTCreateCommon(aoutfile); if (lookup_common) { LOOKUP *p; - for (i = 0, p = lookup_common; p->symName; i++, p++) - ; - memcpy(&(lookup[l]), lookup_common, i * sizeof (LOOKUP)); + for (i = 0, p = lookup_common; p->symName; i++, p++) ; + memcpy(&(lookup[l]), lookup_common, i * sizeof(LOOKUP)); xf86loaderfree(lookup_common); l += i; lookup[l].symName = NULL; } return lookup; -} /* AOUT_GetSymbols */ +} /* AOUT_GetSymbols */ /* * Public API for the a.out implementation of the loader */ void * -AOUTLoadModule(loaderPtr modrec, - int aoutfd, - LOOKUP **ppLookup) +AOUTLoadModule(loaderPtr modrec, int aoutfd, LOOKUP ** ppLookup) { AOUTModulePtr aoutfile = NULL; AOUTHDR *header; AOUTRelocPtr reloc, tail; - void *v; + void *v; #ifdef AOUTDEBUG AOUTDEBUG("AOUTLoadModule(%s, %d, %d)\n", modrec->name, modrec->handle, aoutfd); #endif - if ((aoutfile=xf86loadercalloc(1,sizeof(AOUTModuleRec))) == NULL ) { - ErrorF( "Unable to allocate AOUTModuleRec\n" ); + if ((aoutfile = xf86loadercalloc(1, sizeof(AOUTModuleRec))) == NULL) { + ErrorF("Unable to allocate AOUTModuleRec\n"); return NULL; } - aoutfile->handle=modrec->handle; - aoutfile->module=modrec->module; - aoutfile->fd=aoutfd; - v=aoutfile->funcs=modrec->funcs; + aoutfile->handle = modrec->handle; + aoutfile->module = modrec->module; + aoutfile->fd = aoutfd; + v = aoutfile->funcs = modrec->funcs; /* * Get the a.out header */ - aoutfile->header=(AOUTHDR *)_LoaderFileToMem(aoutfd,0,sizeof(AOUTHDR), - "header"); - header= (AOUTHDR *)aoutfile->header; + aoutfile->header = + (AOUTHDR *) _LoaderFileToMem(aoutfd, 0, sizeof(AOUTHDR), + "header"); + header = (AOUTHDR *) aoutfile->header; /* * Load the 6 other sections */ /* text */ if (header->a_text != 0) { - aoutfile->text = _LoaderFileToMem(aoutfile->fd, + aoutfile->text = _LoaderFileToMem(aoutfile->fd, AOUT_TXTOFF(header), header->a_text, "text"); aoutfile->textsize = header->a_text; @@ -689,13 +694,13 @@ AOUTLoadModule(loaderPtr modrec, /* Data Relocations */ if (header->a_drsize != 0) { aoutfile->datarel = _LoaderFileToMem(aoutfile->fd, - AOUT_DRELOFF(header), - header->a_drsize, "datarel"); + AOUT_DRELOFF(header), + header->a_drsize, "datarel"); } else { aoutfile->datarel = NULL; } /* String table */ - _LoaderFileRead(aoutfile->fd, AOUT_STROFF(header), + _LoaderFileRead(aoutfile->fd, AOUT_STROFF(header), &(aoutfile->strsize), sizeof(int)); if (aoutfile->strsize != 0) { aoutfile->strings = _LoaderFileToMem(aoutfile->fd, @@ -711,8 +716,7 @@ AOUTLoadModule(loaderPtr modrec, reloc = AOUTCollectRelocations(aoutfile); if (reloc) { - for (tail = reloc; tail->next; tail = tail->next) - ; + for (tail = reloc; tail->next; tail = tail->next) ; tail->next = _LoaderGetRelocations(v)->aout_reloc; _LoaderGetRelocations(v)->aout_reloc = reloc; } @@ -721,8 +725,7 @@ AOUTLoadModule(loaderPtr modrec, } void -AOUTResolveSymbols(mod) -void *mod; +AOUTResolveSymbols(void *mod) { AOUTRelocPtr newlist, p, tmp; @@ -731,7 +734,7 @@ void *mod; #endif newlist = 0; - for (p = _LoaderGetRelocations(mod)->aout_reloc; p; ) { + for (p = _LoaderGetRelocations(mod)->aout_reloc; p;) { tmp = AOUT_RelocateEntry(p->file, p->type, p->rel); if (tmp) { /* Failed to relocate. Keep it in the list. */ @@ -743,11 +746,10 @@ void *mod; xf86loaderfree(tmp); } _LoaderGetRelocations(mod)->aout_reloc = newlist; -} /* AOUTResolveSymbols */ +} /* AOUTResolveSymbols */ int -AOUTCheckForUnresolved(mod) -void *mod; +AOUTCheckForUnresolved(void *mod) { int symnum; AOUTRelocPtr crel; @@ -763,18 +765,20 @@ void *mod; while (crel) { if (crel->type == AOUT_TEXT) { /* Attempt to make unresolved text references - point to a default function */ - AOUT_Relocate((unsigned long *)(crel->file->text - + crel->rel->r_address) , - (unsigned long)LoaderDefaultFunc, + * point to a default function */ + AOUT_Relocate((unsigned long *)(crel->file->text + + crel->rel->r_address), + (unsigned long)LoaderDefaultFunc, crel->rel->r_pcrel); } symnum = crel->rel->r_symbolnum; - name=AOUTGetSymbolName(crel->file, crel->file->symtab + symnum); - flag = _LoaderHandleUnresolved(name, - _LoaderHandleToName(crel->file->handle)); + name = AOUTGetSymbolName(crel->file, crel->file->symtab + symnum); + flag = _LoaderHandleUnresolved(name, + _LoaderHandleToName(crel->file-> + handle)); xf86loaderfree(name); - if (flag) fatalsym = 1; + if (flag) + fatalsym = 1; crel = crel->next; } return fatalsym; @@ -783,8 +787,9 @@ void *mod; void AOUTUnloadModule(void *modptr) { - AOUTModulePtr aoutfile = (AOUTModulePtr)modptr; + AOUTModulePtr aoutfile = (AOUTModulePtr) modptr; AOUTRelocPtr relptr, *prevptr; + #ifdef AOUTDEBUG AOUTDEBUG("AOUTUnLoadModule(0x%p)\n", modptr); #endif @@ -793,8 +798,8 @@ AOUTUnloadModule(void *modptr) * Delete any unresolved relocations */ - relptr=_LoaderGetRelocations(aoutfile->funcs)->aout_reloc; - prevptr=&(_LoaderGetRelocations(aoutfile->funcs)->aout_reloc); + relptr = _LoaderGetRelocations(aoutfile->funcs)->aout_reloc; + prevptr = &(_LoaderGetRelocations(aoutfile->funcs)->aout_reloc); while (relptr) { if (relptr->file == aoutfile) { @@ -805,19 +810,19 @@ AOUTUnloadModule(void *modptr) prevptr = &(relptr->next); relptr = relptr->next; } - } /* while */ - + } /* while */ + /* clean the symbols table */ LoaderHashTraverse((void *)aoutfile, AOUTHashCleanOut); #define CheckandFree(ptr,size) if(ptr) _LoaderFreeFileMem((ptr),(size)) - CheckandFree(aoutfile->strings,aoutfile->strsize); - CheckandFree(aoutfile->symtab,aoutfile->header->a_syms); - CheckandFree(aoutfile->datarel,aoutfile->header->a_drsize); - CheckandFree(aoutfile->txtrel,aoutfile->header->a_trsize); - CheckandFree(aoutfile->data,aoutfile->header->a_data); - CheckandFree(aoutfile->text,aoutfile->header->a_text); + CheckandFree(aoutfile->strings, aoutfile->strsize); + CheckandFree(aoutfile->symtab, aoutfile->header->a_syms); + CheckandFree(aoutfile->datarel, aoutfile->header->a_drsize); + CheckandFree(aoutfile->txtrel, aoutfile->header->a_trsize); + CheckandFree(aoutfile->data, aoutfile->header->a_data); + CheckandFree(aoutfile->text, aoutfile->header->a_text); /* Free allocated sections */ if (aoutfile->bss != NULL) { xf86loaderfree(aoutfile->bss); @@ -838,21 +843,20 @@ AOUTUnloadModule(void *modptr) char * AOUTAddressToSection(void *modptr, unsigned long address) { - AOUTModulePtr aoutfile = (AOUTModulePtr)modptr; - - if( address >= (unsigned long)aoutfile->text && - address <= (unsigned long)aoutfile->text+aoutfile->textsize ) { - return "text"; - } - if( address >= (unsigned long)aoutfile->data && - address <= (unsigned long)aoutfile->data+aoutfile->datasize ) { - return "data"; - } - if( address >= (unsigned long)aoutfile->bss && - address <= (unsigned long)aoutfile->bss+aoutfile->bsssize ) { - return "bss"; - } + AOUTModulePtr aoutfile = (AOUTModulePtr) modptr; + + if (address >= (unsigned long)aoutfile->text && + address <= (unsigned long)aoutfile->text + aoutfile->textsize) { + return "text"; + } + if (address >= (unsigned long)aoutfile->data && + address <= (unsigned long)aoutfile->data + aoutfile->datasize) { + return "data"; + } + if (address >= (unsigned long)aoutfile->bss && + address <= (unsigned long)aoutfile->bss + aoutfile->bsssize) { + return "bss"; + } return NULL; } - diff --git a/hw/xfree86/loader/aoutloader.h b/hw/xfree86/loader/aoutloader.h index 2714b140f..b0e156319 100644 --- a/hw/xfree86/loader/aoutloader.h +++ b/hw/xfree86/loader/aoutloader.h @@ -19,13 +19,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/aoutloader.h,v 1.3 1998/09/20 14:41:03 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/aoutloader.h,v 1.4 2003/10/15 16:29:02 dawes Exp $ */ #ifndef _AOUTLOADER_H #define _AOUTLOADER_H extern void *AOUTLoadModule(loaderPtr, int, LOOKUP **); extern void AOUTResolveSymbols(void *); extern int AOUTCheckForUnresolved(void *); -extern char *AOUTAddressToSection(void *,unsigned long); +extern char *AOUTAddressToSection(void *, unsigned long); extern void AOUTUnloadModule(void *); #endif diff --git a/hw/xfree86/loader/ar.h b/hw/xfree86/loader/ar.h index 4dbc97901..956b810a0 100644 --- a/hw/xfree86/loader/ar.h +++ b/hw/xfree86/loader/ar.h @@ -1,5 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/ar.h,v 1.3 1998/07/25 16:56:12 dawes Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/ar.h,v 1.4 2003/10/15 16:29:02 dawes Exp $ */ #ifndef _AR_H #define _AR_H @@ -10,13 +9,13 @@ #if !(defined(__powerpc__) && defined(Lynx)) struct ar_hdr { - char ar_name[16], - ar_date[12], - ar_uid[6], - ar_gid[6], - ar_mode[8], - ar_size[10], - ar_fmag[2]; + char ar_name[16]; + char ar_date[12]; + char ar_uid[6]; + char ar_gid[6]; + char ar_mode[8]; + char ar_size[10]; + char ar_fmag[2]; }; #else @@ -25,35 +24,31 @@ struct ar_hdr { #define SAIAMAG 8 #define AIAFMAG "`\n" -struct fl_hdr /* archive fixed length header - printable ascii */ -{ - char fl_magic[SAIAMAG]; /* Archive file magic string */ - char fl_memoff[12]; /* Offset to member table */ - char fl_gstoff[12]; /* Offset to global symbol table */ - char fl_fstmoff[12]; /* Offset to first archive member */ - char fl_lstmoff[12]; /* Offset to last archive member */ - char fl_freeoff[12]; /* Offset to first mem on free list */ +struct fl_hdr { /* archive fixed length header - printable ascii */ + char fl_magic[SAIAMAG]; /* Archive file magic string */ + char fl_memoff[12]; /* Offset to member table */ + char fl_gstoff[12]; /* Offset to global symbol table */ + char fl_fstmoff[12]; /* Offset to first archive member */ + char fl_lstmoff[12]; /* Offset to last archive member */ + char fl_freeoff[12]; /* Offset to first mem on free list */ }; #define FL_HDR struct fl_hdr #define FL_HSZ sizeof(FL_HDR) - -struct ar_hdr /* archive file member header - printable ascii */ -{ - char ar_size[12]; /* file member size - decimal */ - char ar_nxtmem[12]; /* pointer to next member - decimal */ - char ar_prvmem[12]; /* pointer to previous member - decimal */ - char ar_date[12]; /* file member date - decimal */ - char ar_uid[12]; /* file member user id - decimal */ - char ar_gid[12]; /* file member group id - decimal */ - char ar_mode[12]; /* file member mode - octal */ - char ar_namlen[4]; /* file member name length - decimal */ - union - { - char an_name[2]; /* variable length member name */ - char an_fmag[2]; /* AIAFMAG - string to end header */ - } _ar_name; /* and variable length name */ +struct ar_hdr { /* archive file member header - printable ascii */ + char ar_size[12]; /* file member size - decimal */ + char ar_nxtmem[12]; /* pointer to next member - decimal */ + char ar_prvmem[12]; /* pointer to previous member - decimal */ + char ar_date[12]; /* file member date - decimal */ + char ar_uid[12]; /* file member user id - decimal */ + char ar_gid[12]; /* file member group id - decimal */ + char ar_mode[12]; /* file member mode - octal */ + char ar_namlen[4]; /* file member name length - decimal */ + union { + char an_name[2]; /* variable length member name */ + char an_fmag[2]; /* AIAFMAG - string to end header */ + } _ar_name; /* and variable length name */ }; #define ar_name _ar_name.an_name @@ -74,4 +69,3 @@ struct ar_hdr /* archive file member header - printable ascii */ #endif /* !__powerpc__ && Lynx */ #endif /* _AR_H */ - diff --git a/hw/xfree86/loader/coff.h b/hw/xfree86/loader/coff.h index cebf5e179..52553278e 100644 --- a/hw/xfree86/loader/coff.h +++ b/hw/xfree86/loader/coff.h @@ -1,5 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coff.h,v 1.5 1998/07/25 16:56:12 dawes Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coff.h,v 1.6 2003/10/15 16:29:02 dawes Exp $ */ /* This file was implemented from the information in the book Understanding and Using COFF @@ -20,7 +19,7 @@ #ifndef _COFF_H #define _COFF_H -#define E_SYMNMLEN 8 /* Number of characters in a symbol name */ +#define E_SYMNMLEN 8 /* Number of characters in a symbol name */ /* * Intel 386/486 */ @@ -29,15 +28,14 @@ * FILE HEADER */ -typedef struct COFF_filehdr -{ - unsigned short f_magic; /* magic number */ - unsigned short f_nscns; /* number of sections */ - long f_timdat; /* time & date stamp */ - long f_symptr; /* file pointer to symtab */ - long f_nsyms; /* number of symtab entries */ - unsigned short f_opthdr; /* sizeof(optional hdr) */ - unsigned short f_flags; /* flags */ +typedef struct COFF_filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + long f_timdat; /* time & date stamp */ + long f_symptr; /* file pointer to symtab */ + long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ } FILHDR; #define FILHSZ sizeof(FILHDR) @@ -46,18 +44,17 @@ typedef struct COFF_filehdr * SECTION HEADER */ -typedef struct COFF_scnhdr -{ - char s_name[8]; /* section name */ - long s_paddr; /* physical address */ - long s_vaddr; /* virtual address */ - long s_size; /* section size */ - long s_scnptr; /* raw data for section */ - long s_relptr; /* relocation */ - long s_lnnoptr; /* line numbers */ - unsigned short s_nreloc; /* number of relocation entries */ - unsigned short s_nlnno; /* number of line number entries*/ - long s_flags; /* flags */ +typedef struct COFF_scnhdr { + char s_name[8]; /* section name */ + long s_paddr; /* physical address */ + long s_vaddr; /* virtual address */ + long s_size; /* section size */ + long s_scnptr; /* raw data for section */ + long s_relptr; /* relocation */ + long s_lnnoptr; /* line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries */ + long s_flags; /* flags */ } SCNHDR; #define COFF_SCNHDR struct COFF_scnhdr @@ -68,41 +65,36 @@ typedef struct COFF_scnhdr * the optional COFF header as used by Linux COFF */ -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes */ - char dsize[4]; /* initialized data */ - char bsize[4]; /* uninitialized data */ - char entry[4]; /* entry point */ - char text_start[4]; /* base of text */ - char data_start[4]; /* base of data */ +typedef struct { + char magic[2]; /* type of file */ + char vstamp[2]; /* version stamp */ + char tsize[4]; /* text size in bytes */ + char dsize[4]; /* initialized data */ + char bsize[4]; /* uninitialized data */ + char entry[4]; /* entry point */ + char text_start[4]; /* base of text */ + char data_start[4]; /* base of data */ } AOUTHDR; - /* * SYMBOLS */ -typedef struct COFF_syment -{ - union - { - char _n_name[E_SYMNMLEN]; /* Symbol name (first 8 chars) */ - struct - { - long _n_zeroes; /* Leading zeros */ - long _n_offset; /* Offset for a header section */ +typedef struct COFF_syment { + union { + char _n_name[E_SYMNMLEN]; /* Symbol name (first 8 chars) */ + struct { + long _n_zeroes; /* Leading zeros */ + long _n_offset; /* Offset for a header section */ } _n_n; - char *_n_nptr[2]; /* allows for overlaying */ - } _n; - - long n_value; /* address of the segment */ - short n_scnum; /* Section number */ - unsigned short n_type; /* Type of section */ - char n_sclass; /* Loader class */ - char n_numaux; /* Number of aux entries following */ + char *_n_nptr[2]; /* allows for overlaying */ + } _n; + + long n_value; /* address of the segment */ + short n_scnum; /* Section number */ + unsigned short n_type; /* Type of section */ + char n_sclass; /* Loader class */ + char n_numaux; /* Number of aux entries following */ } SYMENT; #define n_name _n._n_name @@ -110,8 +102,8 @@ typedef struct COFF_syment #define n_zeroes _n._n_n._n_zeroes #define n_offset _n._n_n._n_offset -#define COFF_E_SYMNMLEN 8 /* characters in a short symbol name */ -#define COFF_E_FILNMLEN 14 /* characters in a file name */ +#define COFF_E_SYMNMLEN 8 /* characters in a short symbol name */ +#define COFF_E_FILNMLEN 14 /* characters in a file name */ #define COFF_E_DIMNUM 4 /* array dimensions in aux entry */ #define SYMNMLEN COFF_E_SYMNMLEN #define SYMESZ 18 /* not really sizeof(SYMENT) due to padding */ @@ -131,62 +123,59 @@ typedef struct COFF_syment * AUX Entries */ typedef struct COFF_auxent { - long x_scnlen; - long x_parmhash; - unsigned short x_snhash; - unsigned char x_smtyp; - unsigned char x_smclas; - long x_stab; - unsigned short x_snstab; + long x_scnlen; + long x_parmhash; + unsigned short x_snhash; + unsigned char x_smtyp; + unsigned char x_smclas; + long x_stab; + unsigned short x_snstab; } AUXENT; /* Auxillary Symbol type values */ -#define XTY_ER 0 /* Enternal Reference */ -#define XTY_SD 1 /* csect section definition */ -#define XTY_LD 2 /* Label definition */ -#define XTY_CM 3 /* common csect definition */ +#define XTY_ER 0 /* Enternal Reference */ +#define XTY_SD 1 /* csect section definition */ +#define XTY_LD 2 /* Label definition */ +#define XTY_CM 3 /* common csect definition */ /* Auxillary Symbol storage mapping class values */ -#define XMC_PR 0 /* Program code */ -#define XMC_RO 1 /* Read-only constant */ -#define XMC_DB 2 /* Debug dictionary */ -#define XMC_TC 3 /* TOC entry */ -#define XMC_UA 4 /* Unclassified */ -#define XMC_RW 5 /* Read/write data */ -#define XMC_GL 6 /* Global linkage */ -#define XMC_XO 7 /* Extended operation */ -#define XMC_SV 8 /* Supervisor call descriptor */ -#define XMC_BS 9 /* BSS class */ -#define XMC_DS 10 /* Function descriptor csect */ -#define XMC_UC 11 /* Unnamed FORTRAN comon */ -#define XMC_TI 12 /* Reserved */ -#define XMC_TB 13 /* Reserved */ -#define XMC_TC0 15 /* TOC anchor */ -#define XMC_TD 16 /* Scalar data entry in TOC */ +#define XMC_PR 0 /* Program code */ +#define XMC_RO 1 /* Read-only constant */ +#define XMC_DB 2 /* Debug dictionary */ +#define XMC_TC 3 /* TOC entry */ +#define XMC_UA 4 /* Unclassified */ +#define XMC_RW 5 /* Read/write data */ +#define XMC_GL 6 /* Global linkage */ +#define XMC_XO 7 /* Extended operation */ +#define XMC_SV 8 /* Supervisor call descriptor */ +#define XMC_BS 9 /* BSS class */ +#define XMC_DS 10 /* Function descriptor csect */ +#define XMC_UC 11 /* Unnamed FORTRAN comon */ +#define XMC_TI 12 /* Reserved */ +#define XMC_TB 13 /* Reserved */ +#define XMC_TC0 15 /* TOC anchor */ +#define XMC_TD 16 /* Scalar data entry in TOC */ /* * RELOCATION DIRECTIVES */ -typedef struct COFF_reloc -{ - long r_vaddr; /* Virtual address of item */ - long r_symndx; /* Symbol index in the symtab */ +typedef struct COFF_reloc { + long r_vaddr; /* Virtual address of item */ + long r_symndx; /* Symbol index in the symtab */ #if defined(__powerpc__) - union - { - unsigned short _r_type; /* old style coff relocation type */ - struct - { - char _r_rsize; /* sign and reloc bit len */ - char _r_rtype; /* toc relocation type */ + union { + unsigned short _r_type; /* old style coff relocation type */ + struct { + char _r_rsize; /* sign and reloc bit len */ + char _r_rtype; /* toc relocation type */ } _r_r; - } _r; -#define r_otype _r._r_type /* old style reloc - original name */ + } _r; +#define r_otype _r._r_type /* old style reloc - original name */ #define r_rsize _r._r_r._r_rsize /* extract sign and bit len */ #define r_type _r._r_r._r_rtype /* extract toc relocation type */ #else - unsigned short r_type; /* Relocation type */ + unsigned short r_type; /* Relocation type */ #endif } RELOC; @@ -222,7 +211,7 @@ typedef struct COFF_reloc #define R_REL 0x02 /* A(sym-*) Relative to self */ #define R_TOC 0x03 /* A(sym-TOC) Relative to TOC */ #define R_TRL 0x12 /* A(sym-TOC) TOC Relative indirect load. */ - /* modifiable instruction */ + /* modifiable instruction */ #define R_TRLA 0x13 /* A(sym-TOC) TOC Rel load address. modifiable inst */ #define R_GL 0x05 /* A(external TOC of sym) Global Linkage */ #define R_TCL 0x06 /* A(local TOC of sym) Local object TOC address */ diff --git a/hw/xfree86/loader/coffloader.c b/hw/xfree86/loader/coffloader.c index 7a1ef28ad..b2fbfcf14 100644 --- a/hw/xfree86/loader/coffloader.c +++ b/hw/xfree86/loader/coffloader.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coffloader.c,v 1.18 2002/09/16 18:06:10 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coffloader.c,v 1.21 2003/10/15 17:40:15 dawes Exp $ */ /* * @@ -48,63 +48,66 @@ #include "coffloader.h" #include "compiler.h" -/* -#ifndef LDTEST + +#ifndef LOADERDEBUG +#define LOADERDEBUG 0 +#endif + +#if LOADERDEBUG #define COFFDEBUG ErrorF #endif -*/ /* * This structure contains all of the information about a module * that has been loaded. */ -typedef struct { - int handle; - long module; /* Id of the module used to find inter module calls */ - int fd; - loader_funcs *funcs; - FILHDR *header; /* file header */ - AOUTHDR *optheader; /* optional file header */ - unsigned short numsh; - SCNHDR *sections; /* Start address of the section table */ - int secsize; /* size of the section table */ - unsigned char **saddr;/* Start addresss of the sections table */ - unsigned char **reladdr;/* Start addresss of the relocation table */ - unsigned char *strtab; /* Start address of the string table */ - int strsize; /* size of the string table */ - unsigned char *text; /* Start address of the .text section */ - int txtndx; /* index of the .text section */ - long txtaddr; /* offset of the .text section */ - int txtsize; /* size of the .text section */ - int txtrelsize; /* size of the .rel.text section */ - unsigned char *data; /* Start address of the .data section */ - int datndx; /* index of the .data section */ - long dataddr; /* offset of the .data section */ - int datsize; /* size of the .data section */ - int datrelsize; /* size of the .rel.data section */ - unsigned char *bss; /* Start address of the .bss section */ - int bssndx; /* index of the .bss section */ - long bssaddr; /* offset of the .bss section */ - int bsssize; /* size of the .bss section */ - SYMENT *symtab; /* Start address of the .symtab section */ - int symndx; /* index of the .symtab section */ - int symsize; /* size of the .symtab section */ - unsigned char *common; /* Start address of the .common section */ - int comsize; /* size of the .common section */ - long toc; /* Offset of the TOC csect */ - unsigned char *tocaddr; /* Address of the TOC csect */ - } COFFModuleRec, *COFFModulePtr; +typedef struct { + int handle; + long module; /* Id of the module used to find inter module calls */ + int fd; + loader_funcs *funcs; + FILHDR *header; /* file header */ + AOUTHDR *optheader; /* optional file header */ + unsigned short numsh; + SCNHDR *sections; /* Start address of the section table */ + int secsize; /* size of the section table */ + unsigned char **saddr; /* Start addresss of the sections table */ + unsigned char **reladdr; /* Start addresss of the relocation table */ + unsigned char *strtab; /* Start address of the string table */ + int strsize; /* size of the string table */ + unsigned char *text; /* Start address of the .text section */ + int txtndx; /* index of the .text section */ + long txtaddr; /* offset of the .text section */ + int txtsize; /* size of the .text section */ + int txtrelsize; /* size of the .rel.text section */ + unsigned char *data; /* Start address of the .data section */ + int datndx; /* index of the .data section */ + long dataddr; /* offset of the .data section */ + int datsize; /* size of the .data section */ + int datrelsize; /* size of the .rel.data section */ + unsigned char *bss; /* Start address of the .bss section */ + int bssndx; /* index of the .bss section */ + long bssaddr; /* offset of the .bss section */ + int bsssize; /* size of the .bss section */ + SYMENT *symtab; /* Start address of the .symtab section */ + int symndx; /* index of the .symtab section */ + int symsize; /* size of the .symtab section */ + unsigned char *common; /* Start address of the .common section */ + int comsize; /* size of the .common section */ + long toc; /* Offset of the TOC csect */ + unsigned char *tocaddr; /* Address of the TOC csect */ +} COFFModuleRec, *COFFModulePtr; /* * If any relocation is unable to be satisfied, then put it on a list * to try later after more modules have been loaded. */ typedef struct _coff_reloc { - COFFModulePtr file; - RELOC *rel; - int secndx; - struct _coff_reloc *next; + COFFModulePtr file; + RELOC *rel; + int secndx; + struct _coff_reloc *next; } COFFRelocRec; /* @@ -116,10 +119,10 @@ typedef struct _coff_reloc { */ typedef struct _coff_COMMON { - SYMENT *sym; - int index; - struct _coff_COMMON *next; - } COFFCommonRec; + SYMENT *sym; + int index; + struct _coff_COMMON *next; +} COFFCommonRec; static COFFCommonPtr listCOMMON = NULL; @@ -140,36 +143,30 @@ static COFFRelocPtr COFFCollectRelocations(COFFModulePtr); * Utility Functions */ - static int -COFFhashCleanOut(voidptr, item) -void *voidptr; -itemPtr item ; +COFFhashCleanOut(void *voidptr, itemPtr item) { - COFFModulePtr module = (COFFModulePtr) voidptr; - return ( module->handle == item->handle ) ; -} + COFFModulePtr module = (COFFModulePtr) voidptr; + return (module->handle == item->handle); +} /* * Manage listResolv */ static COFFRelocPtr -COFFDelayRelocation(cofffile,secndx,rel) -COFFModulePtr cofffile; -int secndx; -RELOC *rel; +COFFDelayRelocation(COFFModulePtr cofffile, int secndx, RELOC *rel) { COFFRelocPtr reloc; if ((reloc = xf86loadermalloc(sizeof(COFFRelocRec))) == NULL) { - ErrorF( "COFFDelayRelocation() Unable to allocate memory!!!!\n" ); + ErrorF("COFFDelayRelocation() Unable to allocate memory!!!!\n"); return 0; } - reloc->file=cofffile; - reloc->secndx=secndx; - reloc->rel=rel; + reloc->file = cofffile; + reloc->secndx = secndx; + reloc->rel = rel; reloc->next = 0; return reloc; @@ -180,83 +177,80 @@ RELOC *rel; */ static COFFCommonPtr -COFFAddCOMMON(sym,index) -SYMENT *sym; -int index; +COFFAddCOMMON(SYMENT *sym, int index) { COFFCommonPtr common; if ((common = xf86loadermalloc(sizeof(COFFCommonRec))) == NULL) { - ErrorF( "COFFAddCOMMON() Unable to allocate memory!!!!\n" ); + ErrorF("COFFAddCOMMON() Unable to allocate memory!!!!\n"); return 0; } - common->sym=sym; - common->index=index; - common->next=0; + common->sym = sym; + common->index = index; + common->next = 0; return common; } static LOOKUP * -COFFCreateCOMMON(cofffile) -COFFModulePtr cofffile; +COFFCreateCOMMON(COFFModulePtr cofffile) { - int numsyms=0,size=0,l=0; - int offset=0; - LOOKUP *lookup; + int numsyms = 0, size = 0, l = 0; + int offset = 0; + LOOKUP *lookup; COFFCommonPtr common; if (listCOMMON == NULL) return NULL; - common=listCOMMON; + common = listCOMMON; for (common = listCOMMON; common; common = common->next) { /* Ensure long word alignment */ - if( common->sym->n_value != 2 - && common->sym->n_value != 1) /* But not for short and char ;-)(mr)*/ - if( common->sym->n_value%4 != 0 ) - common->sym->n_value+= 4-(common->sym->n_value%4); + if (common->sym->n_value != 2 && common->sym->n_value != 1) /* But not for short and char ;-)(mr) */ + if (common->sym->n_value % 4 != 0) + common->sym->n_value += 4 - (common->sym->n_value % 4); /* accumulate the sizes */ - size+=common->sym->n_value; + size += common->sym->n_value; numsyms++; } #ifdef COFFDEBUG COFFDEBUG("COFFCreateCOMMON() %d entries (%d bytes) of COMMON data\n", - numsyms, size ); + numsyms, size); #endif - if ((lookup = xf86loadermalloc((numsyms+1)*sizeof(LOOKUP))) == NULL) { - ErrorF( "COFFCreateCOMMON() Unable to allocate memory!!!!\n" ); - return NULL; + if ((lookup = xf86loadermalloc((numsyms + 1) * sizeof(LOOKUP))) == NULL) { + ErrorF("COFFCreateCOMMON() Unable to allocate memory!!!!\n"); + return NULL; } - cofffile->comsize=size; - if ((cofffile->common = xf86loadercalloc(1,size)) == NULL) { - ErrorF( "COFFCreateCOMMON() Unable to allocate memory!!!!\n" ); - return NULL; + cofffile->comsize = size; + if ((cofffile->common = xf86loadercalloc(1, size)) == NULL) { + ErrorF("COFFCreateCOMMON() Unable to allocate memory!!!!\n"); + return NULL; } /* Traverse the common list and create a lookup table with all the * common symbols. Destroy the common list in the process. * See also ResolveSymbols. */ - while(listCOMMON) { - common=listCOMMON; - lookup[l].symName=COFFGetSymbolName(cofffile,common->index); - lookup[l].offset=(funcptr)(cofffile->common+offset); + while (listCOMMON) { + common = listCOMMON; + lookup[l].symName = COFFGetSymbolName(cofffile, common->index); + lookup[l].offset = (funcptr) (cofffile->common + offset); #ifdef COFFDEBUG - COFFDEBUG("Adding %x %s\n", lookup[l].offset, lookup[l].symName ); + COFFDEBUG("Adding %p %s\n", (void *)lookup[l].offset, + lookup[l].symName); #endif - listCOMMON=common->next; - offset+=common->sym->n_value; - xf86loaderfree(common); - l++; + listCOMMON = common->next; + offset += common->sym->n_value; + xf86loaderfree(common); + l++; } /* listCOMMON == NULL */ - lookup[l].symName=NULL; /* Terminate the list */ + lookup[l].symName = NULL; /* Terminate the list */ return lookup; } @@ -268,68 +262,62 @@ COFFModulePtr cofffile; * Get symbol name */ static char * -COFFGetSymbolName(cofffile, index) -COFFModulePtr cofffile; -int index; +COFFGetSymbolName(COFFModulePtr cofffile, int index) { - char *name; - SYMENT *sym; + char *name; + SYMENT *sym; - sym=(SYMENT *)(((unsigned char *)cofffile->symtab)+(index*SYMESZ)); + sym = (SYMENT *) (((unsigned char *)cofffile->symtab) + (index * SYMESZ)); #ifdef COFFDEBUG - COFFDEBUG("COFFGetSymbolName(%x,%x) %x",cofffile, index, sym->n_zeroes ); + COFFDEBUG("COFFGetSymbolName(%p,%x) %lx", (void *)cofffile, index, + sym->n_zeroes); #endif name = xf86loadermalloc(sym->n_zeroes ? SYMNMLEN + 1 - : strlen((const char *)&cofffile->strtab[(int)sym->n_offset-4]) + 1); + : strlen((const char *)&cofffile-> + strtab[(int)sym->n_offset - 4]) + 1); if (!name) FatalError("COFFGetSymbolName: Out of memory\n"); - if( sym->n_zeroes ) - { - strncpy(name,sym->n_name,SYMNMLEN); - name[SYMNMLEN]='\000'; - } - else { - strcpy(name, (const char *)&cofffile->strtab[(int)sym->n_offset-4]); - } + if (sym->n_zeroes) { + strncpy(name, sym->n_name, SYMNMLEN); + name[SYMNMLEN] = '\000'; + } else { + strcpy(name, (const char *)&cofffile->strtab[(int)sym->n_offset - 4]); + } #ifdef COFFDEBUG - COFFDEBUG(" %s\n", name ); + COFFDEBUG(" %s\n", name); #endif return name; } static SYMENT * -COFFGetSymbol(file, index) -COFFModulePtr file; -int index; +COFFGetSymbol(COFFModulePtr file, int index) { - return (SYMENT *)(((unsigned char *)file->symtab)+(index*SYMESZ)); + return (SYMENT *) (((unsigned char *)file->symtab) + (index * SYMESZ)); } static unsigned char * -COFFGetSymbolValue(cofffile, index) -COFFModulePtr cofffile; -int index; +COFFGetSymbolValue(COFFModulePtr cofffile, int index) { - unsigned char *symval=0; /* value of the indicated symbol */ + unsigned char *symval = 0; /* value of the indicated symbol */ itemPtr symbol; /* name/value of symbol */ - char *symname; + char *symname; - symname=COFFGetSymbolName(cofffile, index); + symname = COFFGetSymbolName(cofffile, index); #ifdef COFFDEBUG - COFFDEBUG("COFFGetSymbolValue() for %s=", symname ); + COFFDEBUG("COFFGetSymbolValue() for %s=", symname); #endif symbol = LoaderHashFind(symname); - if( symbol ) - symval=(unsigned char *)symbol->address; + if (symbol) + symval = (unsigned char *)symbol->address; #ifdef COFFDEBUG - COFFDEBUG("%x\n", symval ); + COFFDEBUG("%p\n", symval); #endif xf86loaderfree(symname); @@ -343,22 +331,20 @@ int index; * same module as the calling function. */ static unsigned char * -COFFGetSymbolGlinkValue(cofffile, index) -COFFModulePtr cofffile; -int index; +COFFGetSymbolGlinkValue(COFFModulePtr cofffile, int index) { - unsigned char *symval=0; /* value of the indicated symbol */ + unsigned char *symval = 0; /* value of the indicated symbol */ itemPtr symbol; /* name/value of symbol */ - char *name; + char *name; - name=COFFGetSymbolName(cofffile, index); + name = COFFGetSymbolName(cofffile, index); #ifdef COFFDEBUG - COFFDEBUG("COFFGetSymbolGlinkValue() for %s=", name ); + COFFDEBUG("COFFGetSymbolGlinkValue() for %s=", name); #endif - symbol = LoaderHashFind(name+1); /* Eat the '.' so we get the - Function descriptor instead */ + symbol = LoaderHashFind(name + 1); /* Eat the '.' so we get the + * Function descriptor instead */ /* Here we are building up a glink function that will change the TOC * pointer before calling a function that resides in a different module. @@ -373,26 +359,27 @@ int index; 7 00000018 4e800420 bctr # branch to it */ - if( symbol ) { - symval=(unsigned char *)&symbol->code.glink; + if (symbol) { + symval = (unsigned char *)&symbol->code.glink; #ifdef COFFDEBUG - COFFDEBUG("%x\n", symval ); - COFFDEBUG("glink_%s=%x\n", name,symval ); -#endif - symbol->code.glink[ 0]=0x3d80; /* lis r12 */ - symbol->code.glink[ 1]=((unsigned long)symbol->address&0xffff0000)>>16; - symbol->code.glink[ 2]=0x618c; /* ori r12 */ - symbol->code.glink[ 3]=((unsigned long)symbol->address&0x0000ffff); - symbol->code.glink[ 4]=0x9041; /* st r2,20(r1) */ - symbol->code.glink[ 5]=0x0014; - symbol->code.glink[ 6]=0x804c; /* l r2,0(r12) */ - symbol->code.glink[ 7]=0x0000; - symbol->code.glink[ 8]=0x7c49; /* mtctr r2 */ - symbol->code.glink[ 9]=0x03a6; - symbol->code.glink[10]=0x804c; /* l r2,4(r12) */ - symbol->code.glink[11]=0x0004; - symbol->code.glink[12]=0x4e80; /* bctr */ - symbol->code.glink[13]=0x0420; + COFFDEBUG("%x\n", symval); + COFFDEBUG("glink_%s=%x\n", name, symval); +#endif + symbol->code.glink[0] = 0x3d80; /* lis r12 */ + symbol->code.glink[1] = + ((unsigned long)symbol->address & 0xffff0000) >> 16; + symbol->code.glink[2] = 0x618c; /* ori r12 */ + symbol->code.glink[3] = ((unsigned long)symbol->address & 0x0000ffff); + symbol->code.glink[4] = 0x9041; /* st r2,20(r1) */ + symbol->code.glink[5] = 0x0014; + symbol->code.glink[6] = 0x804c; /* l r2,0(r12) */ + symbol->code.glink[7] = 0x0000; + symbol->code.glink[8] = 0x7c49; /* mtctr r2 */ + symbol->code.glink[9] = 0x03a6; + symbol->code.glink[10] = 0x804c; /* l r2,4(r12) */ + symbol->code.glink[11] = 0x0004; + symbol->code.glink[12] = 0x4e80; /* bctr */ + symbol->code.glink[13] = 0x0420; ppc_flush_icache(&symbol->code.glink[0]); ppc_flush_icache(&symbol->code.glink[12]); } @@ -406,17 +393,15 @@ int index; * Fix all of the relocation for the given section. */ static COFFRelocPtr -COFF_RelocateEntry(cofffile, secndx, rel) -COFFModulePtr cofffile; -int secndx; /* index of the target section */ -RELOC *rel; +COFF_RelocateEntry(COFFModulePtr cofffile, int secndx, RELOC *rel) { - SYMENT *symbol; /* value of the indicated symbol */ + SYMENT *symbol; /* value of the indicated symbol */ unsigned long *dest32; /* address of the place being modified */ + #if defined(__powerpc__) unsigned short *dest16; /* address of the place being modified */ - itemPtr symitem; /* symbol structure from has table */ - char *name; + itemPtr symitem; /* symbol structure from has table */ + char *name; #endif unsigned char *symval; /* value of the indicated symbol */ @@ -431,386 +416,401 @@ RELOC *rel; */ #ifdef COFFDEBUG - COFFDEBUG("%x %d %o ", - rel->r_vaddr,rel->r_symndx,rel->r_type ); + COFFDEBUG("%lx %ld %o ", (unsigned long)rel->r_vaddr, + rel->r_symndx, rel->r_type); #if defined(__powerpc__) COFFDEBUG("[%x %x %x] ", - RELOC_RSIGN(*rel), RELOC_RFIXUP(*rel), RELOC_RLEN(*rel)); + RELOC_RSIGN(*rel), RELOC_RFIXUP(*rel), RELOC_RLEN(*rel)); #endif #endif - symbol=COFFGetSymbol(cofffile,rel->r_symndx); + symbol = COFFGetSymbol(cofffile, rel->r_symndx); #ifdef COFFDEBUG - COFFDEBUG("%d %x %d-%d\n", symbol->n_sclass, symbol->n_value, symbol->n_scnum, secndx ); + COFFDEBUG("%d %lx %d-%d\n", symbol->n_sclass, symbol->n_value, + symbol->n_scnum, secndx); #endif /* * Check to see if the relocation offset is part of the .text segment. * If not, we must change the offset to be relative to the .data section * which is NOT contiguous. - */ - switch(secndx+1) { /* change the bias */ + */ + switch (secndx + 1) { /* change the bias */ case N_TEXT: - if( (long)rel->r_vaddr < cofffile->txtaddr || - (long)rel->r_vaddr > (long)(cofffile->txtaddr+cofffile->txtsize) ) { - FatalError("Relocation against N_TEXT not in .text section\n"); + if ((long)rel->r_vaddr < cofffile->txtaddr || + (long)rel->r_vaddr > + (long)(cofffile->txtaddr + cofffile->txtsize)) { + FatalError("Relocation against N_TEXT not in .text section\n"); } - dest32=(unsigned long *)((long)(cofffile->saddr[secndx])+ - ((unsigned char *)rel->r_vaddr-cofffile->txtaddr)); + dest32 = (unsigned long *)((long)(cofffile->saddr[secndx]) + + ((unsigned char *)rel->r_vaddr - + cofffile->txtaddr)); break; case N_DATA: - if( (long)rel->r_vaddr < cofffile->dataddr || - (long)rel->r_vaddr > (long)(cofffile->dataddr+cofffile->datsize) ) { - FatalError("Relocation against N_DATA not in .data section\n"); + if ((long)rel->r_vaddr < cofffile->dataddr || + (long)rel->r_vaddr > + (long)(cofffile->dataddr + cofffile->datsize)) { + FatalError("Relocation against N_DATA not in .data section\n"); } - dest32=(unsigned long *)((long)(cofffile->saddr[secndx])+ - ((unsigned char *)rel->r_vaddr-cofffile->dataddr)); + dest32 = (unsigned long *)((long)(cofffile->saddr[secndx]) + + ((unsigned char *)rel->r_vaddr - + cofffile->dataddr)); break; case N_BSS: - if( (long)rel->r_vaddr < cofffile->bssaddr || - (long)rel->r_vaddr > (long)(cofffile->bssaddr+cofffile->bsssize) ) { - FatalError("Relocation against N_TEXT not in .bss section\n"); + if ((long)rel->r_vaddr < cofffile->bssaddr || + (long)rel->r_vaddr > + (long)(cofffile->bssaddr + cofffile->bsssize)) { + FatalError("Relocation against N_TEXT not in .bss section\n"); } - dest32=(unsigned long *)((long)(cofffile->saddr[secndx])+ - ((unsigned char *)rel->r_vaddr-cofffile->bssaddr)); + dest32 = (unsigned long *)((long)(cofffile->saddr[secndx]) + + ((unsigned char *)rel->r_vaddr - + cofffile->bssaddr)); break; default: - FatalError("Relocation against unknown section %d\n", secndx ); + FatalError("Relocation against unknown section %d\n", secndx); } - if( symbol->n_sclass == 0 ) - { - symval=(unsigned char *)(symbol->n_value+(*dest32)-symbol->n_type); + if (symbol->n_sclass == 0) { + symval = (unsigned char *)(symbol->n_value + (*dest32) - + symbol->n_type); #ifdef COFFDEBUG - COFFDEBUG( "symbol->n_sclass==0\n" ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); + COFFDEBUG("symbol->n_sclass==0\n"); + COFFDEBUG("dest32=%p\t", (void *)dest32); + COFFDEBUG("symval=%p\t", symval); + COFFDEBUG("*dest32=%8.8lx\t", *dest32); #endif - *dest32=(unsigned long)symval; - return 0; - } + *dest32 = (unsigned long)symval; + return 0; + } - switch( rel->r_type ) - { + switch (rel->r_type) { #if defined(i386) - case R_DIR32: - symval=COFFGetSymbolValue(cofffile, rel->r_symndx); - if( symval ) { + case R_DIR32: + symval = COFFGetSymbolValue(cofffile, rel->r_symndx); + if (symval) { #ifdef COFFDEBUG - char *namestr; - COFFDEBUG( "R_DIR32 %s\n", - namestr=COFFGetSymbolName(cofffile,rel->r_symndx) ); - xf86loaderfree(namestr); - COFFDEBUG( "txtsize=%x\t", cofffile->txtsize ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)(symval+(*dest32)-symbol->n_value); - } else { - switch( symbol->n_scnum ) { - case N_UNDEF: + char *namestr; + + COFFDEBUG("R_DIR32 %s\n", + namestr = COFFGetSymbolName(cofffile, rel->r_symndx)); + xf86loaderfree(namestr); + COFFDEBUG("txtsize=%x\t", cofffile->txtsize); + COFFDEBUG("dest32=%p\t", (void *)dest32); + COFFDEBUG("symval=%p\t", symval); + COFFDEBUG("*dest32=%8.8lx\t", *dest32); +#endif + *dest32 = (unsigned long)(symval + (*dest32) - symbol->n_value); + } else { + switch (symbol->n_scnum) { + case N_UNDEF: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_UNDEF\n" ); + COFFDEBUG("R_DIR32 N_UNDEF\n"); #endif - return COFFDelayRelocation(cofffile,secndx,rel); - case N_ABS: + return COFFDelayRelocation(cofffile, secndx, rel); + case N_ABS: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_ABS\n" ); + COFFDEBUG("R_DIR32 N_ABS\n"); #endif - return 0; - case N_DEBUG: + return 0; + case N_DEBUG: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_DEBUG\n" ); + COFFDEBUG("R_DIR32 N_DEBUG\n"); #endif - return 0; - case N_COMMENT: + return 0; + case N_COMMENT: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_COMMENT\n" ); + COFFDEBUG("R_DIR32 N_COMMENT\n"); #endif - return 0; - case N_TEXT: + return 0; + case N_TEXT: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_TEXT\n" ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)((*dest32)+ - (unsigned long)(cofffile->saddr[N_TEXT-1])); - break; - case N_DATA: + COFFDEBUG("R_DIR32 N_TEXT\n"); + COFFDEBUG("dest32=%p\t", (void *)dest32); + COFFDEBUG("symval=%p\t", symval); + COFFDEBUG("*dest32=%8.8lx\t", *dest32); +#endif + *dest32 = (unsigned long)((*dest32) + + (unsigned long)(cofffile-> + saddr[N_TEXT - 1])); + break; + case N_DATA: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_DATA\n" ); - COFFDEBUG( "txtsize=%x\t", cofffile->txtsize ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)((*dest32)+ - ((unsigned long)(cofffile->saddr[N_DATA-1]))- - cofffile->dataddr); - break; - case N_BSS: + COFFDEBUG("R_DIR32 N_DATA\n"); + COFFDEBUG("txtsize=%x\t", cofffile->txtsize); + COFFDEBUG("dest32=%p\t", (void *)dest32); + COFFDEBUG("symval=%p\t", symval); + COFFDEBUG("*dest32=%8.8lx\t", *dest32); +#endif + *dest32 = (unsigned long)((*dest32) + + ((unsigned long)(cofffile-> + saddr[N_DATA - + 1])) - + cofffile->dataddr); + break; + case N_BSS: #ifdef COFFDEBUG - COFFDEBUG( "R_DIR32 N_BSS\n" ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)((*dest32)+ - (unsigned long)(cofffile->saddr[N_BSS-1])- - (cofffile->bssaddr)); - break; - default: - ErrorF("R_DIR32 with unexpected section %d\n", - symbol->n_scnum ); - } - + COFFDEBUG("R_DIR32 N_BSS\n"); + COFFDEBUG("dest32=%p\t", (void *)dest32); + COFFDEBUG("symval=%p\t", symval); + COFFDEBUG("*dest32=%8.8lx\t", *dest32); +#endif + *dest32 = (unsigned long)((*dest32) + + (unsigned long)(cofffile-> + saddr[N_BSS - 1]) - + (cofffile->bssaddr)); + break; + default: + ErrorF("R_DIR32 with unexpected section %d\n", + symbol->n_scnum); } + + } #ifdef COFFDEBUG - COFFDEBUG( "*dest32=%8.8x\n", *dest32 ); + COFFDEBUG("*dest32=%8.8lx\n", *dest32); #endif + break; + case R_PCRLONG: + if (symbol->n_scnum == N_TEXT) break; - case R_PCRLONG: - if( symbol->n_scnum == N_TEXT ) - break; - symval=COFFGetSymbolValue(cofffile, rel->r_symndx); + symval = COFFGetSymbolValue(cofffile, rel->r_symndx); #ifdef COFFDEBUG - COFFDEBUG( "R_PCRLONG "); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); + COFFDEBUG("R_PCRLONG "); + COFFDEBUG("dest32=%p\t", (void *)dest32); + COFFDEBUG("symval=%p\t", symval); + COFFDEBUG("*dest32=%8.8lx\t", *dest32); #endif - if( symval == 0 ) { + if (symval == 0) { #ifdef COFFDEBUG - char *name; - COFFDEBUG( "***Unable to resolve symbol %s\n", - name=COFFGetSymbolName(cofffile,rel->r_symndx) ); - xf86loaderfree(name); + char *name; + + COFFDEBUG("***Unable to resolve symbol %s\n", + name = COFFGetSymbolName(cofffile, rel->r_symndx)); + xf86loaderfree(name); #endif - return COFFDelayRelocation(cofffile,secndx,rel); - } - *dest32=(unsigned long)(symval-((long)dest32+sizeof(long))); + return COFFDelayRelocation(cofffile, secndx, rel); + } + *dest32 = (unsigned long)(symval - ((long)dest32 + sizeof(long))); #ifdef COFFDEBUG - COFFDEBUG( "*dest32=%8.8x\n", *dest32 ); + COFFDEBUG("*dest32=%8.8lx\n", *dest32); #endif - break; - case R_ABS: - /* - * Nothing to really do here. - * Usually, a dummy relocation for .file - */ - break; + break; + case R_ABS: + /* + * Nothing to really do here. + * Usually, a dummy relocation for .file + */ + break; #endif /* i386 */ #if defined(__powerpc__) - case R_POS: - /* - * Positive Relocation - */ - if( RELOC_RLEN(*rel) != 0x1f ) - FatalError("R_POS with size != 32 bits" ); - symval=COFFGetSymbolValue(cofffile, rel->r_symndx); - if( symval ) { + case R_POS: + /* + * Positive Relocation + */ + if (RELOC_RLEN(*rel) != 0x1f) + FatalError("R_POS with size != 32 bits"); + symval = COFFGetSymbolValue(cofffile, rel->r_symndx); + if (symval) { #ifdef COFFDEBUG - COFFDEBUG( "R_POS "); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); + COFFDEBUG("R_POS "); + COFFDEBUG("dest32=%x\t", dest32); + COFFDEBUG("symval=%x\t", symval); + COFFDEBUG("*dest32=%8.8x\t", *dest32); #endif - *dest32=(unsigned long)(symval+(*dest32)-symbol->n_value); - ppc_flush_icache(dest32); - } else { - switch( symbol->n_scnum ) { - case N_UNDEF: + *dest32 = (unsigned long)(symval + (*dest32) - symbol->n_value); + ppc_flush_icache(dest32); + } else { + switch (symbol->n_scnum) { + case N_UNDEF: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_UNDEF\n" ); + COFFDEBUG("R_POS N_UNDEF\n"); #endif - return COFFDelayRelocation(cofffile,secndx,rel); - case N_ABS: + return COFFDelayRelocation(cofffile, secndx, rel); + case N_ABS: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_ABS\n" ); + COFFDEBUG("R_POS N_ABS\n"); #endif - return 0; - case N_DEBUG: + return 0; + case N_DEBUG: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_DEBUG\n" ); + COFFDEBUG("R_POS N_DEBUG\n"); #endif - return 0; - case N_COMMENT: + return 0; + case N_COMMENT: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_COMMENT\n" ); + COFFDEBUG("R_POS N_COMMENT\n"); #endif - return 0; - case N_TEXT: + return 0; + case N_TEXT: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_TEXT\n" ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)((*dest32)+ - ((unsigned long)(cofffile->saddr[N_TEXT-1]))- - cofffile->txtaddr); - ppc_flush_icache(dest32); - break; - case N_DATA: + COFFDEBUG("R_POS N_TEXT\n"); + COFFDEBUG("dest32=%x\t", dest32); + COFFDEBUG("symval=%x\t", symval); + COFFDEBUG("*dest32=%8.8x\t", *dest32); +#endif + *dest32 = (unsigned long)((*dest32) + + ((unsigned long)(cofffile-> + saddr[N_TEXT - + 1])) - + cofffile->txtaddr); + ppc_flush_icache(dest32); + break; + case N_DATA: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_DATA\n" ); - COFFDEBUG( "txtsize=%x\t", cofffile->txtsize ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)((*dest32)+ - ((unsigned long)(cofffile->saddr[N_DATA-1]))- - cofffile->dataddr); - ppc_flush_icache(dest32); - break; - case N_BSS: + COFFDEBUG("R_POS N_DATA\n"); + COFFDEBUG("txtsize=%x\t", cofffile->txtsize); + COFFDEBUG("dest32=%x\t", dest32); + COFFDEBUG("symval=%x\t", symval); + COFFDEBUG("*dest32=%8.8x\t", *dest32); +#endif + *dest32 = (unsigned long)((*dest32) + + ((unsigned long)(cofffile-> + saddr[N_DATA - + 1])) - + cofffile->dataddr); + ppc_flush_icache(dest32); + break; + case N_BSS: #ifdef COFFDEBUG - COFFDEBUG( "R_POS N_BSS\n" ); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - *dest32=(unsigned long)((*dest32)+ - (unsigned long)(cofffile->saddr[N_BSS-1])- - (cofffile->bssaddr)); - ppc_flush_icache(dest32); - break; - default: - ErrorF("R_POS with unexpected section %d\n", - symbol->n_scnum ); - } + COFFDEBUG("R_POS N_BSS\n"); + COFFDEBUG("dest32=%x\t", dest32); + COFFDEBUG("symval=%x\t", symval); + COFFDEBUG("*dest32=%8.8x\t", *dest32); +#endif + *dest32 = (unsigned long)((*dest32) + + (unsigned long)(cofffile-> + saddr[N_BSS - 1]) - + (cofffile->bssaddr)); + ppc_flush_icache(dest32); + break; + default: + ErrorF("R_POS with unexpected section %d\n", symbol->n_scnum); } + } #ifdef COFFDEBUG - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); - COFFDEBUG( "\n" ); + COFFDEBUG("*dest32=%8.8x\t", *dest32); + COFFDEBUG("\n"); #endif - break; - case R_TOC: - /* - * Relative to TOC - */ - { - dest16=(unsigned short *)dest32; - if( RELOC_RLEN(*rel) != 0x0f ) - FatalError("R_TOC with size != 16 bits" ); + break; + case R_TOC: + /* + * Relative to TOC + */ + { + dest16 = (unsigned short *)dest32; + if (RELOC_RLEN(*rel) != 0x0f) + FatalError("R_TOC with size != 16 bits"); #ifdef COFFDEBUG - COFFDEBUG( "R_TOC "); - COFFDEBUG( "dest16=%x\t", dest16 ); - COFFDEBUG( "symbol=%x\t", symbol ); - COFFDEBUG( "symbol->n_value=%x\t", symbol->n_value ); - COFFDEBUG( "cofffile->toc=%x\t", cofffile->toc ); - COFFDEBUG( "*dest16=%8.8x\t", *dest16 ); -#endif - *dest16=(unsigned long)((symbol->n_value-cofffile->toc)); + COFFDEBUG("R_TOC "); + COFFDEBUG("dest16=%x\t", dest16); + COFFDEBUG("symbol=%x\t", symbol); + COFFDEBUG("symbol->n_value=%x\t", symbol->n_value); + COFFDEBUG("cofffile->toc=%x\t", cofffile->toc); + COFFDEBUG("*dest16=%8.8x\t", *dest16); +#endif + *dest16 = (unsigned long)((symbol->n_value - cofffile->toc)); ppc_flush_icache(dest16); - } + } #ifdef COFFDEBUG - COFFDEBUG( "*dest16=%8.8x\t", *dest16 ); - COFFDEBUG( "\n" ); + COFFDEBUG("*dest16=%8.8x\t", *dest16); + COFFDEBUG("\n"); #endif - break; - case R_BR: - /* - * Branch relative to self, non-modifiable - */ - - if( RELOC_RLEN(*rel) != 0x19 ) - FatalError("R_BR with size != 24 bits" ); - name = COFFGetSymbolName(cofffile, rel->r_symndx); + break; + case R_BR: + /* + * Branch relative to self, non-modifiable + */ + + if (RELOC_RLEN(*rel) != 0x19) + FatalError("R_BR with size != 24 bits"); + name = COFFGetSymbolName(cofffile, rel->r_symndx); + symitem = LoaderHashFind(name); + if (symitem == 0) { + name++; symitem = LoaderHashFind(name); - if( symitem == 0 ) { - name++; - symitem = LoaderHashFind(name); - } - if( symitem && cofffile->module != symitem->module ) { + } + if (symitem && cofffile->module != symitem->module) { #ifdef COFFDEBUG - COFFDEBUG("Symbol module %d != file module %d\n", - symitem->module, cofffile->module ); + COFFDEBUG("Symbol module %d != file module %d\n", + symitem->module, cofffile->module); #endif - symval=COFFGetSymbolGlinkValue(cofffile, rel->r_symndx); - } - else - symval=COFFGetSymbolValue(cofffile, rel->r_symndx); - if( symval == 0 ) { + symval = COFFGetSymbolGlinkValue(cofffile, rel->r_symndx); + } else + symval = COFFGetSymbolValue(cofffile, rel->r_symndx); + if (symval == 0) { #ifdef COFFDEBUG - char *name; - COFFDEBUG( "***Unable to resolve symbol %s\n", - name=COFFGetSymbolName(cofffile,rel->r_symndx) ); - xf86loaderfree(name); + char *name; + + COFFDEBUG("***Unable to resolve symbol %s\n", + name = COFFGetSymbolName(cofffile, rel->r_symndx)); + xf86loaderfree(name); #endif - return COFFDelayRelocation(cofffile,secndx,rel); - } + return COFFDelayRelocation(cofffile, secndx, rel); + } #ifdef COFFDEBUG - COFFDEBUG( "R_BR "); - COFFDEBUG( "dest32=%x\t", dest32 ); - COFFDEBUG( "symval=%x\t", symval ); - COFFDEBUG( "*dest32=%8.8x\t", *dest32 ); -#endif - { - unsigned long val; - val=((unsigned long)symval-(unsigned long)dest32); + COFFDEBUG("R_BR "); + COFFDEBUG("dest32=%x\t", dest32); + COFFDEBUG("symval=%x\t", symval); + COFFDEBUG("*dest32=%8.8x\t", *dest32); +#endif + { + unsigned long val; + + val = ((unsigned long)symval - (unsigned long)dest32); #ifdef COFFDEBUG - COFFDEBUG( "val=%8.8x\n", val ); + COFFDEBUG("val=%8.8x\n", val); #endif - val = val>>2; - if( (val & 0x3f000000) != 0x3f000000 && - (val & 0x3f000000) != 0x00000000 ) { - FatalError( "R_BR offset %x too large\n", val<<2 ); - break; - } - val &= 0x00ffffff; + val = val >> 2; + if ((val & 0x3f000000) != 0x3f000000 && + (val & 0x3f000000) != 0x00000000) { + FatalError("R_BR offset %x too large\n", val << 2); + break; + } + val &= 0x00ffffff; #ifdef COFFDEBUG - COFFDEBUG( "val=%8.8x\n", val ); -#endif - /* - * The address part contains the offset to the beginning - * of the .text section. Disreguard this since we have - * calculated the correct offset already. - */ - (*dest32)=((*dest32)&0xfc000003)|(val<<2); + COFFDEBUG("val=%8.8x\n", val); +#endif + /* + * The address part contains the offset to the beginning + * of the .text section. Disreguard this since we have + * calculated the correct offset already. + */ + (*dest32) = ((*dest32) & 0xfc000003) | (val << 2); #ifdef COFFDEBUG - COFFDEBUG( "*dest32=%8.8x\n", *dest32 ); + COFFDEBUG("*dest32=%8.8x\n", *dest32); #endif - if( cofffile->module != symitem->module ) { - (*++dest32)=0x80410014; /* lwz r2,20(r1) */ - } - ppc_flush_icache(--dest32); + if (cofffile->module != symitem->module) { + (*++dest32) = 0x80410014; /* lwz r2,20(r1) */ } + ppc_flush_icache(--dest32); + } - break; + break; #endif /* __powerpc__ */ - default: - ErrorF( - "COFF_RelocateEntry() Unsupported relocation type %o\n", - rel->r_type ); - break; - } + default: + ErrorF("COFF_RelocateEntry() Unsupported relocation type %o\n", + rel->r_type); + break; + } return 0; } static COFFRelocPtr -COFFCollectRelocations(cofffile) -COFFModulePtr cofffile; +COFFCollectRelocations(COFFModulePtr cofffile) { - unsigned short i,j; - RELOC *rel; - SCNHDR *sec; + unsigned short i, j; + RELOC *rel; + SCNHDR *sec; COFFRelocPtr reloc_head = NULL; COFFRelocPtr tmp; - for(i=0; i<cofffile->numsh; i++ ) { - if( cofffile->saddr[i] == NULL ) - continue; /* Section not loaded!! */ - sec=&(cofffile->sections[i]); - for(j=0;j<sec->s_nreloc;j++) { - rel=(RELOC *)(cofffile->reladdr[i]+(j*RELSZ)); - tmp = COFFDelayRelocation(cofffile,i,rel); + for (i = 0; i < cofffile->numsh; i++) { + if (cofffile->saddr[i] == NULL) + continue; /* Section not loaded!! */ + sec = &(cofffile->sections[i]); + for (j = 0; j < sec->s_nreloc; j++) { + rel = (RELOC *) (cofffile->reladdr[i] + (j * RELSZ)); + tmp = COFFDelayRelocation(cofffile, i, rel); tmp->next = reloc_head; reloc_head = tmp; } @@ -826,199 +826,191 @@ COFFModulePtr cofffile; */ static LOOKUP * -COFF_GetSymbols(cofffile) -COFFModulePtr cofffile; +COFF_GetSymbols(COFFModulePtr cofffile) { - SYMENT *sym; - AUXENT *aux=NULL; - int i, l, numsyms; - LOOKUP *lookup, *lookup_common, *p; - char *symname; + SYMENT *sym; + AUXENT *aux = NULL; + int i, l, numsyms; + LOOKUP *lookup, *lookup_common, *p; + char *symname; /* * Load the symbols into memory */ - numsyms=cofffile->header->f_nsyms; + numsyms = cofffile->header->f_nsyms; #ifdef COFFDEBUG - COFFDEBUG("COFF_GetSymbols(): %d symbols\n", numsyms ); + COFFDEBUG("COFF_GetSymbols(): %d symbols\n", numsyms); #endif - cofffile->symsize=(numsyms*SYMESZ); - cofffile->symtab=(SYMENT *)_LoaderFileToMem(cofffile->fd,cofffile->header->f_symptr, - (numsyms*SYMESZ),"symbols"); + cofffile->symsize = (numsyms * SYMESZ); + cofffile->symtab = + (SYMENT *) _LoaderFileToMem(cofffile->fd, + cofffile->header->f_symptr, + (numsyms * SYMESZ), "symbols"); - if ((lookup = xf86loadermalloc((numsyms+1)*sizeof(LOOKUP))) == NULL) + if ((lookup = xf86loadermalloc((numsyms + 1) * sizeof(LOOKUP))) == NULL) return NULL; - for(i=0,l=0; i<numsyms; i++) - { - sym=(SYMENT *)(((unsigned char *)cofffile->symtab)+(i*SYMESZ)); - symname=COFFGetSymbolName(cofffile,i); - if( sym->n_numaux > 0 ) - aux=(AUXENT *)(((unsigned char *)cofffile->symtab)+((i+1)*SYMESZ)); - else - aux=NULL; + for (i = 0, l = 0; i < numsyms; i++) { + sym = (SYMENT *) (((unsigned char *)cofffile->symtab) + (i * SYMESZ)); + symname = COFFGetSymbolName(cofffile, i); + if (sym->n_numaux > 0) + aux = (AUXENT *) (((unsigned char *)cofffile->symtab) + + ((i + 1) * SYMESZ)); + else + aux = NULL; #ifdef COFFDEBUG - COFFDEBUG("\t%d %d %x %x %d %d %s\n", - i, sym->n_scnum, sym->n_value, sym->n_type, - sym->n_sclass, sym->n_numaux, symname ); - if( aux ) - COFFDEBUG("aux=\t%d %x %x %x %x %x %x\n", - aux->x_scnlen, aux->x_parmhash, aux->x_snhash, - aux->x_smtyp, aux->x_smclas, aux->x_stab, - aux->x_snstab ); -#endif - i+=sym->n_numaux; - /* - * check for TOC csect before discarding C_HIDEXT below - */ - if( aux && aux->x_smclas == XMC_TC0 ) { - if( sym->n_scnum != N_DATA ) - FatalError("TOC not in N_DATA section"); - cofffile->toc=sym->n_value; - cofffile->tocaddr=(cofffile->saddr[sym->n_scnum-1]+ - sym->n_value-(cofffile->dataddr)); + COFFDEBUG("\t%d %d %lx %x %d %d %s\n", + i, sym->n_scnum, sym->n_value, sym->n_type, + sym->n_sclass, sym->n_numaux, symname); + if (aux) + COFFDEBUG("aux=\t%ld %lx %x %x %x %lx %x\n", + aux->x_scnlen, aux->x_parmhash, aux->x_snhash, + aux->x_smtyp, aux->x_smclas, aux->x_stab, + aux->x_snstab); +#endif + i += sym->n_numaux; + /* + * check for TOC csect before discarding C_HIDEXT below + */ + if (aux && aux->x_smclas == XMC_TC0) { + if (sym->n_scnum != N_DATA) + FatalError("TOC not in N_DATA section"); + cofffile->toc = sym->n_value; + cofffile->tocaddr = (cofffile->saddr[sym->n_scnum - 1] + + sym->n_value - (cofffile->dataddr)); #ifdef COFFDEBUG - COFFDEBUG("TOC=%x\n", cofffile->toc ); - COFFDEBUG("TOCaddr=%x\n", cofffile->tocaddr ); + COFFDEBUG("TOC=%lx\n", cofffile->toc); + COFFDEBUG("TOCaddr=%p\n", cofffile->tocaddr); #endif - continue; - } - if( sym->n_sclass == C_HIDEXT ) { + continue; + } + if (sym->n_sclass == C_HIDEXT) { /* && aux && !(aux->x_smclas == XMC_DS && aux->x_smtyp == XTY_SD) ) ) { */ #ifdef COFFDEBUG - COFFDEBUG("Skipping C_HIDEXT class symbol %s\n", symname ); + COFFDEBUG("Skipping C_HIDEXT class symbol %s\n", symname); #endif - continue; - } - switch( sym->n_scnum ) - { - case N_UNDEF: - if( sym->n_value != 0 ) { - char *name; - COFFCommonPtr tmp; - - name = COFFGetSymbolName(cofffile,i); + continue; + } + switch (sym->n_scnum) { + case N_UNDEF: + if (sym->n_value != 0) { + char *name; + COFFCommonPtr tmp; + + name = COFFGetSymbolName(cofffile, i); #ifdef COFFDEBUG - COFFDEBUG("Adding COMMON space for %s\n", name); -#endif - if(!LoaderHashFind(name)) { - tmp = COFFAddCOMMON(sym,i); - if (tmp) { - tmp->next = listCOMMON; - listCOMMON = tmp; - } - } - xf86loaderfree(name); + COFFDEBUG("Adding COMMON space for %s\n", name); +#endif + if (!LoaderHashFind(name)) { + tmp = COFFAddCOMMON(sym, i); + if (tmp) { + tmp->next = listCOMMON; + listCOMMON = tmp; } - xf86loaderfree(symname); - break; - case N_ABS: - case N_DEBUG: - case N_COMMENT: + } + xf86loaderfree(name); + } + xf86loaderfree(symname); + break; + case N_ABS: + case N_DEBUG: + case N_COMMENT: #ifdef COFFDEBUG - COFFDEBUG("Freeing %s, section %d\n", - symname, sym->n_scnum ); -#endif - xf86loaderfree(symname); - break; - case N_TEXT: - if( (sym->n_sclass == C_EXT || sym->n_sclass == C_HIDEXT) - && cofffile->saddr[sym->n_scnum-1]) { - lookup[l].symName=symname; - lookup[l].offset=(funcptr) - (cofffile->saddr[sym->n_scnum-1]+ - sym->n_value-cofffile->txtaddr); + COFFDEBUG("Freeing %s, section %d\n", symname, sym->n_scnum); +#endif + xf86loaderfree(symname); + break; + case N_TEXT: + if ((sym->n_sclass == C_EXT || sym->n_sclass == C_HIDEXT) + && cofffile->saddr[sym->n_scnum - 1]) { + lookup[l].symName = symname; + lookup[l].offset = (funcptr) + (cofffile->saddr[sym->n_scnum - 1] + + sym->n_value - cofffile->txtaddr); #ifdef COFFDEBUG - COFFDEBUG("Adding %x %s\n", - lookup[l].offset, lookup[l].symName ); + COFFDEBUG("Adding %p %s\n", + (void *)lookup[l].offset, lookup[l].symName); #endif - l++; - } - else { + l++; + } else { #ifdef COFFDEBUG - COFFDEBUG( "TEXT Section not loaded %d\n", - sym->n_scnum-1 ); + COFFDEBUG("TEXT Section not loaded %d\n", sym->n_scnum - 1); #endif - xf86loaderfree(symname); - } - break; - case N_DATA: - /* - * Note: COFF expects .data to be contiguous with - * .data, so that offsets for .data are relative to - * .text. We need to adjust for this, and make them - * relative to .data so that the relocation can be - * properly applied. This is needed becasue we allocate - * .data seperately from .text. - */ - if( (sym->n_sclass == C_EXT || sym->n_sclass == C_HIDEXT) - && cofffile->saddr[sym->n_scnum-1]) { - lookup[l].symName=symname; - lookup[l].offset=(funcptr) - (cofffile->saddr[sym->n_scnum-1]+ - sym->n_value-cofffile->dataddr); + xf86loaderfree(symname); + } + break; + case N_DATA: + /* + * Note: COFF expects .data to be contiguous with + * .data, so that offsets for .data are relative to + * .text. We need to adjust for this, and make them + * relative to .data so that the relocation can be + * properly applied. This is needed becasue we allocate + * .data seperately from .text. + */ + if ((sym->n_sclass == C_EXT || sym->n_sclass == C_HIDEXT) + && cofffile->saddr[sym->n_scnum - 1]) { + lookup[l].symName = symname; + lookup[l].offset = (funcptr) + (cofffile->saddr[sym->n_scnum - 1] + + sym->n_value - cofffile->dataddr); #ifdef COFFDEBUG - COFFDEBUG("Adding %x %s\n", - lookup[l].offset, lookup[l].symName ); + COFFDEBUG("Adding %p %s\n", + (void *)lookup[l].offset, lookup[l].symName); #endif - l++; - } - else { + l++; + } else { #ifdef COFFDEBUG - COFFDEBUG( "DATA Section not loaded %d\n", - sym->n_scnum-1 ); + COFFDEBUG("DATA Section not loaded %d\n", sym->n_scnum - 1); #endif - xf86loaderfree(symname); - } - break; - case N_BSS: - /* - * Note: COFF expects .bss to be contiguous with - * .data, so that offsets for .bss are relative to - * .text. We need to adjust for this, and make them - * relative to .bss so that the relocation can be - * properly applied. This is needed becasue we allocate - * .bss seperately from .text and .data. - */ - if( (sym->n_sclass == C_EXT || sym->n_sclass == C_HIDEXT) - && cofffile->saddr[sym->n_scnum-1]) { - lookup[l].symName=symname; - lookup[l].offset=(funcptr) - (cofffile->saddr[sym->n_scnum-1]+ - sym->n_value-cofffile->bssaddr); + xf86loaderfree(symname); + } + break; + case N_BSS: + /* + * Note: COFF expects .bss to be contiguous with + * .data, so that offsets for .bss are relative to + * .text. We need to adjust for this, and make them + * relative to .bss so that the relocation can be + * properly applied. This is needed becasue we allocate + * .bss seperately from .text and .data. + */ + if ((sym->n_sclass == C_EXT || sym->n_sclass == C_HIDEXT) + && cofffile->saddr[sym->n_scnum - 1]) { + lookup[l].symName = symname; + lookup[l].offset = (funcptr) + (cofffile->saddr[sym->n_scnum - 1] + + sym->n_value - cofffile->bssaddr); #ifdef COFFDEBUG - COFFDEBUG("Adding %x %s\n", - lookup[l].offset, lookup[l].symName ); + COFFDEBUG("Adding %p %s\n", + (void *)lookup[l].offset, lookup[l].symName); #endif - l++; - } - else { + l++; + } else { #ifdef COFFDEBUG - COFFDEBUG( "BSS Section not loaded %d\n", - sym->n_scnum-1 ); + COFFDEBUG("BSS Section not loaded %d\n", sym->n_scnum - 1); #endif - xf86loaderfree(symname); - } - break; - default: - ErrorF("Unknown Section number %d\n", sym->n_scnum ); - xf86loaderfree(symname); - break; - } + xf86loaderfree(symname); + } + break; + default: + ErrorF("Unknown Section number %d\n", sym->n_scnum); + xf86loaderfree(symname); + break; } + } - lookup[l].symName=NULL; /* Terminate the list */ + lookup[l].symName = NULL; /* Terminate the list */ lookup_common = COFFCreateCOMMON(cofffile); if (lookup_common) { - for (i = 0, p = lookup_common; p->symName; i++, p++) - ; - memcpy(&(lookup[l]), lookup_common, i * sizeof (LOOKUP)); + for (i = 0, p = lookup_common; p->symName; i++, p++) ; + memcpy(&(lookup[l]), lookup_common, i * sizeof(LOOKUP)); xf86loaderfree(lookup_common); l += i; @@ -1030,10 +1022,11 @@ COFFModulePtr cofffile; */ for (i = 0, p = lookup; p->symName; i++, p++) { while (p->symName && (!strcmp(lookup[i].symName, ".text") - || !strcmp(lookup[i].symName, ".data") - || !strcmp(lookup[i].symName, ".bss") + || !strcmp(lookup[i].symName, ".data") + || !strcmp(lookup[i].symName, ".bss") )) { - memmove(&(lookup[i]), &(lookup[i+1]), (l-- - i) * sizeof (LOOKUP)); + memmove(&(lookup[i]), &(lookup[i + 1]), + (l-- - i) * sizeof(LOOKUP)); } } @@ -1052,94 +1045,95 @@ COFFModulePtr cofffile; * Do the work required to load each section into memory. */ static void -COFFCollectSections(cofffile) -COFFModulePtr cofffile; +COFFCollectSections(COFFModulePtr cofffile) { - unsigned short i; + unsigned short i; /* * Find and identify all of the Sections */ #ifdef COFFDEBUG - COFFDEBUG("COFFCollectSections(): %d sections\n", cofffile->numsh ); + COFFDEBUG("COFFCollectSections(): %d sections\n", cofffile->numsh); #endif - for( i=0; i<cofffile->numsh; i++) { + for (i = 0; i < cofffile->numsh; i++) { #ifdef COFFDEBUG - COFFDEBUG("%d %s\n", i, cofffile->sections[i].s_name ); + COFFDEBUG("%d %s\n", i, cofffile->sections[i].s_name); #endif /* .text */ - if( strcmp(cofffile->sections[i].s_name, - ".text" ) == 0 ) { - cofffile->text=_LoaderFileToMem(cofffile->fd, - SecOffset(i),SecSize(i),".text"); - cofffile->saddr[i]=cofffile->text; - cofffile->txtndx=i; - cofffile->txtaddr=SecAddr(i); - cofffile->txtsize=SecSize(i); - cofffile->txtrelsize=RelSize(i); - cofffile->reladdr[i]=_LoaderFileToMem(cofffile->fd, - RelOffset(i), RelSize(i),".rel.text"); + if (strcmp(cofffile->sections[i].s_name, ".text") == 0) { + cofffile->text = _LoaderFileToMem(cofffile->fd, + SecOffset(i), SecSize(i), + ".text"); + cofffile->saddr[i] = cofffile->text; + cofffile->txtndx = i; + cofffile->txtaddr = SecAddr(i); + cofffile->txtsize = SecSize(i); + cofffile->txtrelsize = RelSize(i); + cofffile->reladdr[i] = _LoaderFileToMem(cofffile->fd, + RelOffset(i), RelSize(i), + ".rel.text"); #ifdef COFFDEBUG - COFFDEBUG(".text starts at %x (%x bytes)\n", cofffile->text, cofffile->txtsize ); + COFFDEBUG(".text starts at %p (%x bytes)\n", cofffile->text, + cofffile->txtsize); #endif continue; } /* .data */ - if( strcmp(cofffile->sections[i].s_name, - ".data" ) == 0 ) { - cofffile->data=_LoaderFileToMem(cofffile->fd, - SecOffset(i),SecSize(i),".data"); - cofffile->saddr[i]=cofffile->data; - cofffile->datndx=i; - cofffile->dataddr=SecAddr(i); - cofffile->datsize=SecSize(i); - cofffile->datrelsize=RelSize(i); - cofffile->reladdr[i]=_LoaderFileToMem(cofffile->fd, - RelOffset(i), RelSize(i),".rel.data"); + if (strcmp(cofffile->sections[i].s_name, ".data") == 0) { + cofffile->data = _LoaderFileToMem(cofffile->fd, + SecOffset(i), SecSize(i), + ".data"); + cofffile->saddr[i] = cofffile->data; + cofffile->datndx = i; + cofffile->dataddr = SecAddr(i); + cofffile->datsize = SecSize(i); + cofffile->datrelsize = RelSize(i); + cofffile->reladdr[i] = _LoaderFileToMem(cofffile->fd, + RelOffset(i), RelSize(i), + ".rel.data"); #ifdef COFFDEBUG - COFFDEBUG(".data starts at %x (%x bytes)\n", cofffile->data, cofffile->datsize ); + COFFDEBUG(".data starts at %p (%x bytes)\n", cofffile->data, + cofffile->datsize); #endif continue; } /* .bss */ - if( strcmp(cofffile->sections[i].s_name, - ".bss" ) == 0 ) { - if( SecSize(i) ) - cofffile->bss=xf86loadercalloc(1,SecSize(i)); + if (strcmp(cofffile->sections[i].s_name, ".bss") == 0) { + if (SecSize(i)) + cofffile->bss = xf86loadercalloc(1, SecSize(i)); else - cofffile->bss=NULL; - cofffile->saddr[i]=cofffile->bss; - cofffile->bssndx=i; - cofffile->bssaddr=SecAddr(i); - cofffile->bsssize=SecSize(i); + cofffile->bss = NULL; + cofffile->saddr[i] = cofffile->bss; + cofffile->bssndx = i; + cofffile->bssaddr = SecAddr(i); + cofffile->bsssize = SecSize(i); #ifdef COFFDEBUG - COFFDEBUG(".bss starts at %x (%x bytes)\n", cofffile->bss, cofffile->bsssize ); + COFFDEBUG(".bss starts at %p (%x bytes)\n", cofffile->bss, + cofffile->bsssize); #endif continue; } /* .comment */ - if( strncmp(cofffile->sections[i].s_name, - ".comment",strlen(".comment") ) == 0 ) { + if (strncmp(cofffile->sections[i].s_name, + ".comment", strlen(".comment")) == 0) { continue; } /* .stab */ - if( strcmp(cofffile->sections[i].s_name, - ".stab" ) == 0 ) { + if (strcmp(cofffile->sections[i].s_name, ".stab") == 0) { continue; } /* .stabstr */ - if( strcmp(cofffile->sections[i].s_name, - ".stabstr" ) == 0 ) { + if (strcmp(cofffile->sections[i].s_name, ".stabstr") == 0) { continue; } /* .stab.* */ - if( strncmp(cofffile->sections[i].s_name, - ".stab.", strlen(".stab.") ) == 0 ) { + if (strncmp(cofffile->sections[i].s_name, + ".stab.", strlen(".stab.")) == 0) { continue; } - ErrorF("COFF: Not loading %s\n", cofffile->sections[i].s_name ); + ErrorF("COFF: Not loading %s\n", cofffile->sections[i].s_name); } } @@ -1147,52 +1141,54 @@ COFFModulePtr cofffile; * Public API for the COFF implementation of the loader. */ void * -COFFLoadModule(modrec, cofffd, ppLookup) -loaderPtr modrec; -int cofffd; -LOOKUP **ppLookup; +COFFLoadModule(loaderPtr modrec, int cofffd, LOOKUP **ppLookup) { - COFFModulePtr cofffile; + COFFModulePtr cofffile; FILHDR *header; - int stroffset; /* offset of string table */ + int stroffset; /* offset of string table */ COFFRelocPtr coff_reloc, tail; - void *v; + void *v; #ifdef COFFDEBUG - COFFDEBUG("COFFLoadModule(%s,%x,%x)\n",modrec->name,modrec->handle,cofffd); + COFFDEBUG("COFFLoadModule(%s,%x,%x)\n", modrec->name, modrec->handle, + cofffd); #endif - if ((cofffile = xf86loadercalloc(1,sizeof(COFFModuleRec))) == NULL) { - ErrorF( "Unable to allocate COFFModuleRec\n" ); + if ((cofffile = xf86loadercalloc(1, sizeof(COFFModuleRec))) == NULL) { + ErrorF("Unable to allocate COFFModuleRec\n"); return NULL; } - cofffile->handle=modrec->handle; - cofffile->module=modrec->module; - cofffile->fd=cofffd; - v=cofffile->funcs=modrec->funcs; + cofffile->handle = modrec->handle; + cofffile->module = modrec->module; + cofffile->fd = cofffd; + v = cofffile->funcs = modrec->funcs; /* * Get the COFF header */ - cofffile->header=(FILHDR *)_LoaderFileToMem(cofffd,0,sizeof(FILHDR),"header"); - header=(FILHDR *)cofffile->header; + cofffile->header = + (FILHDR *) _LoaderFileToMem(cofffd, 0, sizeof(FILHDR), "header"); + header = (FILHDR *) cofffile->header; - if( header->f_symptr == 0 || header->f_nsyms == 0 ) { + if (header->f_symptr == 0 || header->f_nsyms == 0) { ErrorF("No symbols found in module\n"); - _LoaderFreeFileMem(header,sizeof(FILHDR)); + _LoaderFreeFileMem(header, sizeof(FILHDR)); xf86loaderfree(cofffile); return NULL; } /* * Get the section table */ - cofffile->numsh=header->f_nscns; - cofffile->secsize=(header->f_nscns*SCNHSZ); - cofffile->sections=(SCNHDR *)_LoaderFileToMem(cofffd,FILHSZ+header->f_opthdr, - cofffile->secsize, "sections"); - cofffile->saddr=xf86loadercalloc(cofffile->numsh, sizeof(unsigned char *)); - cofffile->reladdr=xf86loadercalloc(cofffile->numsh, sizeof(unsigned char *)); + cofffile->numsh = header->f_nscns; + cofffile->secsize = (header->f_nscns * SCNHSZ); + cofffile->sections = + (SCNHDR *) _LoaderFileToMem(cofffd, FILHSZ + header->f_opthdr, + cofffile->secsize, "sections"); + cofffile->saddr = + xf86loadercalloc(cofffile->numsh, sizeof(unsigned char *)); + cofffile->reladdr = + xf86loadercalloc(cofffile->numsh, sizeof(unsigned char *)); /* * Load the optional header if we need it ????? @@ -1206,13 +1202,14 @@ LOOKUP **ppLookup; /* * load the string table (must be done before we process symbols). */ - stroffset=header->f_symptr+(header->f_nsyms*SYMESZ); + stroffset = header->f_symptr + (header->f_nsyms * SYMESZ); - _LoaderFileRead(cofffd,stroffset,&(cofffile->strsize),sizeof(int)); + _LoaderFileRead(cofffd, stroffset, &(cofffile->strsize), sizeof(int)); - stroffset+=4; /* Move past the size */ - cofffile->strsize-=sizeof(int); /* size includes itself, so reduce by 4 */ - cofffile->strtab=_LoaderFileToMem(cofffd,stroffset,cofffile->strsize,"strings"); + stroffset += 4; /* Move past the size */ + cofffile->strsize -= sizeof(int); /* size includes itself, so reduce by 4 */ + cofffile->strtab = + _LoaderFileToMem(cofffd, stroffset, cofffile->strsize, "strings"); /* * add symbols @@ -1224,8 +1221,7 @@ LOOKUP **ppLookup; */ coff_reloc = COFFCollectRelocations(cofffile); if (coff_reloc) { - for (tail = coff_reloc; tail->next; tail = tail->next) - ; + for (tail = coff_reloc; tail->next; tail = tail->next) ; tail->next = _LoaderGetRelocations(v)->coff_reloc; _LoaderGetRelocations(v)->coff_reloc = coff_reloc; } @@ -1234,8 +1230,7 @@ LOOKUP **ppLookup; } void -COFFResolveSymbols(mod) -void *mod; +COFFResolveSymbols(void *mod) { COFFRelocPtr newlist, p, tmp; @@ -1243,7 +1238,7 @@ void *mod; * which we failed to relocate. Destroy the old list in the process. */ newlist = 0; - for (p = _LoaderGetRelocations(mod)->coff_reloc; p; ) { + for (p = _LoaderGetRelocations(mod)->coff_reloc; p;) { tmp = COFF_RelocateEntry(p->file, p->secndx, p->rel); if (tmp) { /* Failed to relocate. Keep it in the list. */ @@ -1258,53 +1253,51 @@ void *mod; } int -COFFCheckForUnresolved( mod) -void *mod; +COFFCheckForUnresolved(void *mod) { - char *name; + char *name; COFFRelocPtr crel; int flag, fatalsym = 0; if ((crel = _LoaderGetRelocations(mod)->coff_reloc) == NULL) return 0; - while( crel ) - { + while (crel) { name = COFFGetSymbolName(crel->file, crel->rel->r_symndx); - flag = _LoaderHandleUnresolved(name, - _LoaderHandleToName(crel->file->handle)); - if (flag) fatalsym = 1; + flag = _LoaderHandleUnresolved(name, + _LoaderHandleToName(crel->file-> + handle)); + if (flag) + fatalsym = 1; xf86loaderfree(name); - crel=crel->next; - } + crel = crel->next; + } return fatalsym; } void -COFFUnloadModule(modptr) -void *modptr; +COFFUnloadModule(void *modptr) { - COFFModulePtr cofffile = (COFFModulePtr)modptr; - COFFRelocPtr relptr, reltptr, *brelptr; + COFFModulePtr cofffile = (COFFModulePtr) modptr; + COFFRelocPtr relptr, reltptr, *brelptr; /* * Delete any unresolved relocations */ - relptr=_LoaderGetRelocations(cofffile->funcs)->coff_reloc; - brelptr=&(_LoaderGetRelocations(cofffile->funcs)->coff_reloc); - - while(relptr) { - if( relptr->file == cofffile ) { - *brelptr=relptr->next; /* take it out of the list */ - reltptr=relptr; /* save pointer to this node */ - relptr=relptr->next; /* advance the pointer */ - xf86loaderfree(reltptr); /* free the node */ + relptr = _LoaderGetRelocations(cofffile->funcs)->coff_reloc; + brelptr = &(_LoaderGetRelocations(cofffile->funcs)->coff_reloc); + + while (relptr) { + if (relptr->file == cofffile) { + *brelptr = relptr->next; /* take it out of the list */ + reltptr = relptr; /* save pointer to this node */ + relptr = relptr->next; /* advance the pointer */ + xf86loaderfree(reltptr); /* free the node */ + } else { + brelptr = &(relptr->next); + relptr = relptr->next; /* advance the pointer */ } - else { - brelptr=&(relptr->next); - relptr=relptr->next; /* advance the pointer */ - } } /* @@ -1318,22 +1311,22 @@ void *modptr; */ #define CheckandFree(ptr,size) if(ptr) _LoaderFreeFileMem((ptr),(size)) - CheckandFree(cofffile->strtab,cofffile->strsize); - CheckandFree(cofffile->symtab,cofffile->symsize); - CheckandFree(cofffile->text,cofffile->txtsize); - CheckandFree(cofffile->reladdr[cofffile->txtndx],cofffile->txtrelsize); - CheckandFree(cofffile->data,cofffile->datsize); - CheckandFree(cofffile->reladdr[cofffile->datndx],cofffile->datrelsize); - CheckandFree(cofffile->bss,cofffile->bsssize); - if( cofffile->common ) + CheckandFree(cofffile->strtab, cofffile->strsize); + CheckandFree(cofffile->symtab, cofffile->symsize); + CheckandFree(cofffile->text, cofffile->txtsize); + CheckandFree(cofffile->reladdr[cofffile->txtndx], cofffile->txtrelsize); + CheckandFree(cofffile->data, cofffile->datsize); + CheckandFree(cofffile->reladdr[cofffile->datndx], cofffile->datrelsize); + CheckandFree(cofffile->bss, cofffile->bsssize); + if (cofffile->common) xf86loaderfree(cofffile->common); /* * Free the section table, and section pointer array */ - _LoaderFreeFileMem(cofffile->sections,cofffile->secsize); + _LoaderFreeFileMem(cofffile->sections, cofffile->secsize); xf86loaderfree(cofffile->saddr); xf86loaderfree(cofffile->reladdr); - _LoaderFreeFileMem(cofffile->header,sizeof(FILHDR)); + _LoaderFreeFileMem(cofffile->header, sizeof(FILHDR)); /* * Free the COFFModuleRec */ @@ -1345,14 +1338,14 @@ void *modptr; char * COFFAddressToSection(void *modptr, unsigned long address) { - COFFModulePtr cofffile = (COFFModulePtr)modptr; + COFFModulePtr cofffile = (COFFModulePtr) modptr; int i; - for( i=1; i<cofffile->numsh; i++) { - if( address >= (unsigned long)cofffile->saddr[i] && - address <= (unsigned long)cofffile->saddr[i]+SecSize(i) ) { - return cofffile->sections[i].s_name; - } - } -return NULL; + for (i = 1; i < cofffile->numsh; i++) { + if (address >= (unsigned long)cofffile->saddr[i] && + address <= (unsigned long)cofffile->saddr[i] + SecSize(i)) { + return cofffile->sections[i].s_name; + } + } + return NULL; } diff --git a/hw/xfree86/loader/coffloader.h b/hw/xfree86/loader/coffloader.h index 35ce4b2c5..217474671 100644 --- a/hw/xfree86/loader/coffloader.h +++ b/hw/xfree86/loader/coffloader.h @@ -21,7 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coffloader.h,v 1.3 1998/09/20 14:41:04 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/coffloader.h,v 1.4 2003/10/15 16:29:02 dawes Exp $ */ #ifndef _COFFLOADER_H #define _COFFLOADER_H @@ -29,6 +29,6 @@ extern void *COFFLoadModule(loaderPtr, int, LOOKUP **); extern void COFFResolveSymbols(void *); extern int COFFCheckForUnresolved(void *); -extern char *COFFAddressToSection(void *,unsigned long); +extern char *COFFAddressToSection(void *, unsigned long); extern void COFFUnloadModule(void *); #endif /* _COFFLOADER_H */ diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c index 3c1d5b883..3808cf3e3 100644 --- a/hw/xfree86/loader/dixsym.c +++ b/hw/xfree86/loader/dixsym.c @@ -1,8 +1,6 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.53 2003/01/26 16:40:42 eich Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.61 2003/11/10 18:22:35 tsi Exp $ */ /* - * * Copyright 1995-1998 by Metro Link, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -23,6 +21,32 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ #undef DBMALLOC #include "sym.h" @@ -68,300 +92,309 @@ extern int NumCurrentSelections; LOOKUP dixLookupTab[] = { - /* dix */ - /* atom.c */ - SYMFUNC(MakeAtom) - SYMFUNC(ValidAtom) - /* colormap.c */ - SYMFUNC(AllocColor) - SYMFUNC(CreateColormap) - SYMFUNC(FakeAllocColor) - SYMFUNC(FakeFreeColor) - SYMFUNC(FreeColors) - SYMFUNC(StoreColors) - SYMFUNC(TellLostMap) - SYMFUNC(TellGainedMap) - SYMFUNC(QueryColors) - /* cursor.c */ - SYMFUNC(FreeCursor) - /* devices.c */ - SYMFUNC(Ones) - SYMFUNC(InitButtonClassDeviceStruct) - SYMFUNC(InitFocusClassDeviceStruct) - SYMFUNC(InitLedFeedbackClassDeviceStruct) - SYMFUNC(InitPtrFeedbackClassDeviceStruct) - SYMFUNC(InitValuatorClassDeviceStruct) - SYMFUNC(InitKeyClassDeviceStruct) - SYMFUNC(InitKeyboardDeviceStruct) - SYMFUNC(SendMappingNotify) - /* dispatch.c */ - SYMFUNC(SetInputCheck) - SYMFUNC(SendErrorToClient) - SYMFUNC(UpdateCurrentTime) - SYMFUNC(UpdateCurrentTimeIf) - SYMFUNC(ProcBadRequest) - SYMVAR(dispatchException) - SYMVAR(isItTimeToYield) - SYMVAR(ClientStateCallback) - SYMVAR(ServerGrabCallback) - SYMVAR(CurrentSelections) - SYMVAR(NumCurrentSelections) - /* dixfonts.c */ - SYMFUNC(CloseFont) - SYMFUNC(FontToXError) - SYMFUNC(LoadGlyphs) - SYMVAR(fpe_functions) - /* dixutils.c */ - SYMFUNC(AddCallback) - SYMFUNC(ClientSleep) - SYMFUNC(ClientTimeToServerTime) - SYMFUNC(ClientWakeup) - SYMFUNC(CompareTimeStamps) - SYMFUNC(CopyISOLatin1Lowered) - SYMFUNC(DeleteCallback) - SYMFUNC(LookupClient) - SYMFUNC(LookupDrawable) - SYMFUNC(LookupWindow) - SYMFUNC(NoopDDA) - SYMFUNC(QueueWorkProc) - SYMFUNC(RegisterBlockAndWakeupHandlers) - SYMFUNC(RemoveBlockAndWakeupHandlers) + /* dix */ + /* atom.c */ + SYMFUNC(MakeAtom) + SYMFUNC(ValidAtom) + /* colormap.c */ + SYMFUNC(AllocColor) + SYMFUNC(CreateColormap) + SYMFUNC(FakeAllocColor) + SYMFUNC(FakeFreeColor) + SYMFUNC(FreeColors) + SYMFUNC(StoreColors) + SYMFUNC(TellLostMap) + SYMFUNC(TellGainedMap) + SYMFUNC(QueryColors) + /* cursor.c */ + SYMFUNC(FreeCursor) + /* devices.c */ + SYMFUNC(Ones) + SYMFUNC(InitButtonClassDeviceStruct) + SYMFUNC(InitFocusClassDeviceStruct) + SYMFUNC(InitLedFeedbackClassDeviceStruct) + SYMFUNC(InitPtrFeedbackClassDeviceStruct) + SYMFUNC(InitValuatorClassDeviceStruct) + SYMFUNC(InitKeyClassDeviceStruct) + SYMFUNC(InitKeyboardDeviceStruct) + SYMFUNC(SendMappingNotify) + /* dispatch.c */ + SYMFUNC(SetInputCheck) + SYMFUNC(SendErrorToClient) + SYMFUNC(UpdateCurrentTime) + SYMFUNC(UpdateCurrentTimeIf) + SYMFUNC(ProcBadRequest) + SYMVAR(dispatchException) + SYMVAR(isItTimeToYield) + SYMVAR(ClientStateCallback) + SYMVAR(ServerGrabCallback) + SYMVAR(CurrentSelections) + SYMVAR(NumCurrentSelections) + /* dixfonts.c */ + SYMFUNC(CloseFont) + SYMFUNC(FontToXError) + SYMFUNC(LoadGlyphs) + SYMVAR(fpe_functions) + /* dixutils.c */ + SYMFUNC(AddCallback) + SYMFUNC(ClientSleep) + SYMFUNC(ClientTimeToServerTime) + SYMFUNC(ClientWakeup) + SYMFUNC(CompareTimeStamps) + SYMFUNC(CopyISOLatin1Lowered) + SYMFUNC(DeleteCallback) + SYMFUNC(LookupClient) + SYMFUNC(LookupDrawable) + SYMFUNC(LookupWindow) + SYMFUNC(NoopDDA) + SYMFUNC(QueueWorkProc) + SYMFUNC(RegisterBlockAndWakeupHandlers) + SYMFUNC(RemoveBlockAndWakeupHandlers) #ifdef XCSECURITY - SYMFUNC(SecurityLookupDrawable) - SYMFUNC(SecurityLookupWindow) + SYMFUNC(SecurityLookupDrawable) + SYMFUNC(SecurityLookupWindow) #endif - /* events.c */ - SYMFUNC(CheckCursorConfinement) - SYMFUNC(DeliverEvents) - SYMFUNC(NewCurrentScreen) - SYMFUNC(PointerConfinedToScreen) - SYMFUNC(TryClientEvents) - SYMFUNC(WriteEventsToClient) - SYMVAR(DeviceEventCallback) - SYMVAR(EventCallback) - SYMVAR(inputInfo) - SYMVAR(SetCriticalEvent) + /* events.c */ + SYMFUNC(CheckCursorConfinement) + SYMFUNC(DeliverEvents) + SYMFUNC(NewCurrentScreen) + SYMFUNC(PointerConfinedToScreen) + SYMFUNC(TryClientEvents) + SYMFUNC(WriteEventsToClient) + SYMVAR(DeviceEventCallback) + SYMVAR(EventCallback) + SYMVAR(inputInfo) + SYMVAR(SetCriticalEvent) #ifdef PANORAMIX - SYMVAR(XineramaGetCursorScreen) + SYMVAR(XineramaGetCursorScreen) #endif - /* property.c */ - SYMFUNC(ChangeWindowProperty) - /* extension.c */ - SYMFUNC(AddExtension) - SYMFUNC(AddExtensionAlias) - SYMFUNC(CheckExtension) - SYMFUNC(DeclareExtensionSecurity) - SYMFUNC(MinorOpcodeOfRequest) - SYMFUNC(StandardMinorOpcode) - /* gc.c */ - SYMFUNC(CopyGC) - SYMFUNC(CreateGC) - SYMFUNC(CreateScratchGC) - SYMFUNC(ChangeGC) - SYMFUNC(dixChangeGC) - SYMFUNC(DoChangeGC) - SYMFUNC(FreeGC) - SYMFUNC(FreeScratchGC) - SYMFUNC(GetScratchGC) - SYMFUNC(SetClipRects) - SYMFUNC(ValidateGC) - SYMFUNC(VerifyRectOrder) - SYMFUNC(SetDashes) - /* globals.c */ - SYMVAR(DPMSEnabled) - SYMVAR(DPMSCapableFlag) - SYMVAR(DPMSOffTime) - SYMVAR(DPMSPowerLevel) - SYMVAR(DPMSStandbyTime) - SYMVAR(DPMSSuspendTime) - SYMVAR(DPMSEnabledSwitch) - SYMVAR(DPMSDisabledSwitch) - SYMVAR(defaultDPMSEnabled) + /* property.c */ + SYMFUNC(ChangeWindowProperty) + /* extension.c */ + SYMFUNC(AddExtension) + SYMFUNC(AddExtensionAlias) + SYMFUNC(CheckExtension) + SYMFUNC(DeclareExtensionSecurity) + SYMFUNC(MinorOpcodeOfRequest) + SYMFUNC(StandardMinorOpcode) + /* gc.c */ + SYMFUNC(CopyGC) + SYMFUNC(CreateGC) + SYMFUNC(CreateScratchGC) + SYMFUNC(ChangeGC) + SYMFUNC(dixChangeGC) + SYMFUNC(DoChangeGC) + SYMFUNC(FreeGC) + SYMFUNC(FreeScratchGC) + SYMFUNC(GetScratchGC) + SYMFUNC(SetClipRects) + SYMFUNC(ValidateGC) + SYMFUNC(VerifyRectOrder) + SYMFUNC(SetDashes) + /* globals.c */ + SYMVAR(DPMSEnabled) + SYMVAR(DPMSCapableFlag) + SYMVAR(DPMSOffTime) + SYMVAR(DPMSPowerLevel) + SYMVAR(DPMSStandbyTime) + SYMVAR(DPMSSuspendTime) + SYMVAR(DPMSEnabledSwitch) + SYMVAR(DPMSDisabledSwitch) + SYMVAR(defaultDPMSEnabled) + SYMVAR(currentRegionScreen) + /* bigreq */ + SYMVAR(maxBigRequestSize) #ifdef XV - /* XXX These are exported from the DDX, not DIX. */ - SYMVAR(XvScreenInitProc) - SYMVAR(XvGetScreenIndexProc) - SYMVAR(XvGetRTPortProc) - SYMVAR(XvMCScreenInitProc) + /* XXX These are exported from the DDX, not DIX. */ + SYMVAR(XvScreenInitProc) + SYMVAR(XvGetScreenIndexProc) + SYMVAR(XvGetRTPortProc) + SYMVAR(XvMCScreenInitProc) +#endif + SYMVAR(ScreenSaverBlanking) + SYMVAR(WindowTable) + SYMVAR(clients) + SYMVAR(currentMaxClients) + SYMVAR(currentTime) + SYMVAR(defaultColorVisualClass) + SYMVAR(globalSerialNumber) + SYMVAR(lastDeviceEventTime) + SYMVAR(monitorResolution) + SYMVAR(permitOldBugs) + SYMVAR(screenInfo) + SYMVAR(serverClient) + SYMVAR(serverGeneration) + /* main.c */ + SYMFUNC(NotImplemented) + /* pixmap.c */ + SYMFUNC(AllocatePixmap) + SYMFUNC(GetScratchPixmapHeader) + SYMFUNC(FreeScratchPixmapHeader) + SYMVAR(PixmapWidthPaddingInfo) + /* privates.c */ + SYMFUNC(AllocateClientPrivate) + SYMFUNC(AllocateClientPrivateIndex) + SYMFUNC(AllocateGCPrivate) + SYMFUNC(AllocateGCPrivateIndex) + SYMFUNC(AllocateWindowPrivate) + SYMFUNC(AllocateWindowPrivateIndex) + SYMFUNC(AllocateScreenPrivateIndex) + SYMFUNC(AllocateColormapPrivateIndex) +#ifdef PIXPRIV + SYMFUNC(AllocatePixmapPrivateIndex) + SYMFUNC(AllocatePixmapPrivate) #endif - SYMVAR(ScreenSaverBlanking) - SYMVAR(WindowTable) - SYMVAR(clients) - SYMVAR(currentMaxClients) - SYMVAR(currentTime) - SYMVAR(defaultColorVisualClass) - SYMVAR(globalSerialNumber) - SYMVAR(lastDeviceEventTime) - SYMVAR(monitorResolution) - SYMVAR(permitOldBugs) - SYMVAR(screenInfo) - SYMVAR(serverClient) - SYMVAR(serverGeneration) - /* main.c */ - SYMFUNC(NotImplemented) - /* pixmap.c */ - SYMFUNC(AllocatePixmap) - SYMFUNC(GetScratchPixmapHeader) - SYMFUNC(FreeScratchPixmapHeader) - SYMVAR(PixmapWidthPaddingInfo) - /* privates.c */ - SYMFUNC(AllocateClientPrivate) - SYMFUNC(AllocateClientPrivateIndex) - SYMFUNC(AllocateGCPrivate) - SYMFUNC(AllocateGCPrivateIndex) - SYMFUNC(AllocateWindowPrivate) - SYMFUNC(AllocateWindowPrivateIndex) - SYMFUNC(AllocateScreenPrivateIndex) - SYMFUNC(AllocateColormapPrivateIndex) - /* resource.c */ - SYMFUNC(AddResource) - SYMFUNC(ChangeResourceValue) - SYMFUNC(CreateNewResourceClass) - SYMFUNC(CreateNewResourceType) - SYMFUNC(FakeClientID) - SYMFUNC(FreeResource) - SYMFUNC(FreeResourceByType) - SYMFUNC(GetXIDList) - SYMFUNC(GetXIDRange) - SYMFUNC(LookupIDByType) - SYMFUNC(LookupIDByClass) - SYMFUNC(LegalNewID) + /* resource.c */ + SYMFUNC(AddResource) + SYMFUNC(ChangeResourceValue) + SYMFUNC(CreateNewResourceClass) + SYMFUNC(CreateNewResourceType) + SYMFUNC(FakeClientID) + SYMFUNC(FreeResource) + SYMFUNC(FreeResourceByType) + SYMFUNC(GetXIDList) + SYMFUNC(GetXIDRange) + SYMFUNC(LookupIDByType) + SYMFUNC(LookupIDByClass) + SYMFUNC(LegalNewID) #ifdef XCSECURITY - SYMFUNC(SecurityLookupIDByClass) - SYMFUNC(SecurityLookupIDByType) + SYMFUNC(SecurityLookupIDByClass) + SYMFUNC(SecurityLookupIDByType) #endif - SYMFUNC(FindClientResourcesByType) - SYMFUNC(FindAllClientResources) - SYMVAR(lastResourceType) - SYMVAR(TypeMask) + SYMFUNC(FindClientResourcesByType) + SYMFUNC(FindAllClientResources) + SYMVAR(lastResourceType) + SYMVAR(TypeMask) #ifdef RES - SYMFUNC(RegisterResourceName) - SYMVAR(ResourceNames) + SYMFUNC(RegisterResourceName) + SYMVAR(ResourceNames) #endif - /* swaprep.c */ - SYMFUNC(CopySwap32Write) - SYMFUNC(Swap32Write) - SYMFUNC(SwapConnSetupInfo) - SYMFUNC(SwapConnSetupPrefix) - SYMFUNC(SwapShorts) - SYMFUNC(SwapLongs) - /* swapreq.c */ - SYMFUNC(SwapColorItem) - /* tables.c */ - SYMVAR(EventSwapVector) - SYMVAR(ReplySwapVector) - SYMVAR(ProcVector) - /* window.c */ - SYMFUNC(ChangeWindowAttributes) - SYMFUNC(CheckWindowOptionalNeed) - SYMFUNC(CreateUnclippedWinSize) - SYMFUNC(CreateWindow) - SYMFUNC(FindWindowWithOptional) - SYMFUNC(GravityTranslate) - SYMFUNC(MakeWindowOptional) - SYMFUNC(MapWindow) - SYMFUNC(MoveWindowInStack) - SYMFUNC(NotClippedByChildren) - SYMFUNC(ResizeChildrenWinSize) - SYMFUNC(SaveScreens) - SYMFUNC(SendVisibilityNotify) - SYMFUNC(SetWinSize) - SYMFUNC(SetBorderSize) - SYMFUNC(TraverseTree) - SYMFUNC(UnmapWindow) - SYMFUNC(WalkTree) - SYMFUNC(WindowsRestructured) - SYMVAR(deltaSaveUndersViewable) - SYMVAR(numSaveUndersViewable) - SYMVAR(savedScreenInfo) - SYMVAR(screenIsSaved) + /* swaprep.c */ + SYMFUNC(CopySwap32Write) + SYMFUNC(Swap32Write) + SYMFUNC(SwapConnSetupInfo) + SYMFUNC(SwapConnSetupPrefix) + SYMFUNC(SwapShorts) + SYMFUNC(SwapLongs) + /* swapreq.c */ + SYMFUNC(SwapColorItem) + /* tables.c */ + SYMVAR(EventSwapVector) + SYMVAR(ReplySwapVector) + SYMVAR(ProcVector) + /* window.c */ + SYMFUNC(ChangeWindowAttributes) + SYMFUNC(CheckWindowOptionalNeed) + SYMFUNC(CreateUnclippedWinSize) + SYMFUNC(CreateWindow) + SYMFUNC(FindWindowWithOptional) + SYMFUNC(GravityTranslate) + SYMFUNC(MakeWindowOptional) + SYMFUNC(MapWindow) + SYMFUNC(MoveWindowInStack) + SYMFUNC(NotClippedByChildren) + SYMFUNC(ResizeChildrenWinSize) + SYMFUNC(SaveScreens) + SYMFUNC(SendVisibilityNotify) + SYMFUNC(SetWinSize) + SYMFUNC(SetBorderSize) + SYMFUNC(TraverseTree) + SYMFUNC(UnmapWindow) + SYMFUNC(WalkTree) + SYMFUNC(WindowsRestructured) + SYMVAR(deltaSaveUndersViewable) + SYMVAR(numSaveUndersViewable) + SYMVAR(savedScreenInfo) + SYMVAR(screenIsSaved) - /*os/ */ - /* access.c */ - SYMFUNC(LocalClient) - /* util.c */ - SYMFUNC(Error) - SYMFUNC(VErrorF) - SYMFUNC(ErrorF) - SYMFUNC(FatalError) - SYMFUNC(Xstrdup) - SYMFUNC(XNFstrdup) - SYMVAR(Must_have_memory) - /* xalloc.c */ - SYMFUNC(XNFalloc) - SYMFUNC(XNFcalloc) - SYMFUNC(XNFrealloc) - SYMFUNC(Xalloc) - SYMFUNC(Xcalloc) - SYMFUNC(Xfree) - SYMFUNC(Xrealloc) - /* WaitFor.c */ - SYMFUNC(ScreenSaverTime) - SYMFUNC(TimerFree) - SYMFUNC(TimerSet) - SYMFUNC(TimerCancel) - /* io.c */ - SYMFUNC(WriteToClient) - SYMFUNC(SetCriticalOutputPending) - SYMVAR(FlushCallback) - SYMVAR(ReplyCallback) - SYMVAR(SkippedRequestsCallback) - SYMFUNC(ResetCurrentRequest) - /* connection.c */ - SYMFUNC(IgnoreClient) - SYMFUNC(AttendClient) - SYMFUNC(AddEnabledDevice) - SYMFUNC(RemoveEnabledDevice) - SYMFUNC(MakeClientGrabPervious) - SYMFUNC(MakeClientGrabImpervious) - SYMVAR(GrabInProgress) - /* utils.c */ - SYMFUNC(AdjustWaitForDelay) - SYMVAR(noTestExtensions) + /*os/ */ + /* access.c */ + SYMFUNC(LocalClient) + /* utils.c */ + SYMFUNC(Xstrdup) + SYMFUNC(XNFstrdup) + SYMVAR(Must_have_memory) + SYMFUNC(AdjustWaitForDelay) + SYMVAR(noTestExtensions) + SYMFUNC(GiveUp) + /* log.c */ + SYMFUNC(LogVWrite) + SYMFUNC(LogWrite) + SYMFUNC(LogVMessageVerb) + SYMFUNC(LogMessageVerb) + SYMFUNC(LogMessage) + SYMFUNC(FatalError) + SYMFUNC(VErrorF) + SYMFUNC(ErrorF) + SYMFUNC(Error) + /* xalloc.c */ + SYMFUNC(XNFalloc) + SYMFUNC(XNFcalloc) + SYMFUNC(XNFrealloc) + SYMFUNC(Xalloc) + SYMFUNC(Xcalloc) + SYMFUNC(Xfree) + SYMFUNC(Xrealloc) + /* WaitFor.c */ + SYMFUNC(ScreenSaverTime) + SYMFUNC(TimerFree) + SYMFUNC(TimerSet) + SYMFUNC(TimerCancel) + /* io.c */ + SYMFUNC(WriteToClient) + SYMFUNC(SetCriticalOutputPending) + SYMVAR(FlushCallback) + SYMVAR(ReplyCallback) + SYMVAR(SkippedRequestsCallback) + SYMFUNC(ResetCurrentRequest) + /* connection.c */ + SYMFUNC(IgnoreClient) + SYMFUNC(AttendClient) + SYMFUNC(AddEnabledDevice) + SYMFUNC(RemoveEnabledDevice) + SYMFUNC(MakeClientGrabPervious) + SYMFUNC(MakeClientGrabImpervious) + SYMVAR(GrabInProgress) - /* devices.c */ - SYMFUNC(InitPointerDeviceStruct) - SYMFUNC(LookupKeyboardDevice) - SYMFUNC(LookupPointerDevice) + /* devices.c */ + SYMFUNC(InitPointerDeviceStruct) + SYMFUNC(LookupKeyboardDevice) + SYMFUNC(LookupPointerDevice) #ifdef XKB - /* xkb/xkbInit.c */ - SYMFUNC(XkbInitKeyboardDeviceStruct) - SYMFUNC(XkbSetRulesDflts) - SYMVAR(noXkbExtension) + /* xkb/xkbInit.c */ + SYMFUNC(XkbInitKeyboardDeviceStruct) + SYMFUNC(XkbSetRulesDflts) + SYMVAR(noXkbExtension) #endif #ifdef XINPUT - /* Xi */ - /* exevents.c */ - SYMFUNC(InitValuatorAxisStruct) - SYMFUNC(InitProximityClassDeviceStruct) - /* extinit.c */ - SYMFUNC(AssignTypeAndName) + /* Xi */ + /* exevents.c */ + SYMFUNC(InitValuatorAxisStruct) + SYMFUNC(InitProximityClassDeviceStruct) + /* extinit.c */ + SYMFUNC(AssignTypeAndName) #endif - /* xf86DGA.c */ - /* XXX This is exported from the DDX, not DIX. */ - SYMVAR(XDGAEventBase) + /* xf86DGA.c */ + /* XXX This is exported from the DDX, not DIX. */ + SYMVAR(XDGAEventBase) - /* librender.a */ + /* librender.a */ #ifdef RENDER - SYMFUNC(PictureInit) - SYMFUNC(miPictureInit) - SYMFUNC(miComputeCompositeRegion) - SYMFUNC(miGlyphs) - SYMFUNC(miCompositeRects) - SYMVAR(PictureScreenPrivateIndex) - SYMFUNC(PictureTransformPoint) - SYMFUNC(PictureAddFilter) - SYMFUNC(PictureSetFilterAlias) - SYMFUNC(PictureGetSubpixelOrder) - SYMFUNC(PictureSetSubpixelOrder) + SYMFUNC(PictureInit) + SYMFUNC(miPictureInit) + SYMFUNC(miComputeCompositeRegion) + SYMFUNC(miGlyphs) + SYMFUNC(miCompositeRects) + SYMVAR(PictureScreenPrivateIndex) + SYMFUNC(PictureTransformPoint) + SYMFUNC(PictureAddFilter) + SYMFUNC(PictureSetFilterAlias) + SYMFUNC(PictureGetSubpixelOrder) + SYMFUNC(PictureSetSubpixelOrder) #endif - /* os/utils.c */ - SYMFUNC(GiveUp) - - { 0, 0 }, - + {0, 0} }; diff --git a/hw/xfree86/loader/dlloader.c b/hw/xfree86/loader/dlloader.c index bf4c8c078..9d3011caf 100644 --- a/hw/xfree86/loader/dlloader.c +++ b/hw/xfree86/loader/dlloader.c @@ -1,5 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dlloader.c,v 1.11 2000/08/23 22:10:14 tsi Exp $ */ - +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dlloader.c,v 1.13 2003/10/15 16:29:02 dawes Exp $ */ /* * @@ -100,13 +99,13 @@ DLFindSymbol(const char *name) n = xf86loadermalloc(strlen(name) + 2); sprintf(n, "_%s", name); #endif - - (void)dlerror(); /* Clear out any previous error */ + + (void)dlerror(); /* Clear out any previous error */ for (l = dlModuleList; l != NULL; l = l->next) { #ifdef NEED_UNDERSCORE_FOR_DLLSYM - p = dlsym(l->module->dlhandle, n); + p = dlsym(l->module->dlhandle, n); #else - p = dlsym(l->module->dlhandle, name); + p = dlsym(l->module->dlhandle, name); #endif if (dlerror() == NULL) { #ifdef NEED_UNDERSCORE_FOR_DLLSYM @@ -115,10 +114,10 @@ DLFindSymbol(const char *name) return p; } } -#ifdef NEED_UNDERSCORE_FOR_DLLSYM +#ifdef NEED_UNDERSCORE_FOR_DLLSYM xf86loaderfree(n); #endif - + return NULL; } @@ -126,12 +125,12 @@ DLFindSymbol(const char *name) * public interface */ void * -DLLoadModule(loaderPtr modrec, int fd, LOOKUP **ppLookup) +DLLoadModule(loaderPtr modrec, int fd, LOOKUP ** ppLookup) { DLModulePtr dlfile; DLModuleList *l; - if ((dlfile=xf86loadercalloc(1,sizeof(DLModuleRec)))==NULL) { + if ((dlfile = xf86loadercalloc(1, sizeof(DLModuleRec))) == NULL) { ErrorF("Unable to allocate DLModuleRec\n"); return NULL; } @@ -167,7 +166,7 @@ DLCheckForUnresolved(void *mod) void DLUnloadModule(void *modptr) { - DLModulePtr dlfile = (DLModulePtr)modptr; + DLModulePtr dlfile = (DLModulePtr) modptr; DLModuleList *l, *p; /* remove it from dlModuleList */ diff --git a/hw/xfree86/loader/elf.h b/hw/xfree86/loader/elf.h index ad072c199..91130e63d 100644 --- a/hw/xfree86/loader/elf.h +++ b/hw/xfree86/loader/elf.h @@ -1,19 +1,18 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elf.h,v 1.15 2002/10/30 17:50:19 alanh Exp $ */ - - -typedef unsigned int Elf32_Addr; -typedef unsigned short Elf32_Half; -typedef unsigned int Elf32_Off; -typedef long Elf32_Sword; -typedef unsigned int Elf32_Word; - -typedef unsigned long Elf64_Addr; -typedef unsigned short Elf64_Half; -typedef unsigned long Elf64_Off; -typedef int Elf64_Sword; -typedef unsigned int Elf64_Word; -typedef unsigned long Elf64_Xword; -typedef long Elf64_Sxword; +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elf.h,v 1.17 2003/10/15 16:29:02 dawes Exp $ */ + +typedef unsigned int Elf32_Addr; +typedef unsigned short Elf32_Half; +typedef unsigned int Elf32_Off; +typedef long Elf32_Sword; +typedef unsigned int Elf32_Word; + +typedef unsigned long Elf64_Addr; +typedef unsigned short Elf64_Half; +typedef unsigned long Elf64_Off; +typedef int Elf64_Sword; +typedef unsigned int Elf64_Word; +typedef unsigned long Elf64_Xword; +typedef long Elf64_Sxword; /* These constants are for the segment types stored in the image headers */ #define PT_NULL 0 @@ -42,7 +41,7 @@ typedef long Elf64_Sxword; #define EM_386 3 #define EM_68K 4 #define EM_88K 5 -#define EM_486 6 /* Perhaps disused */ +#define EM_486 6 /* Perhaps disused */ #define EM_860 7 #define EM_MIPS 8 #define EM_MIPS_RS4_BE 10 @@ -101,23 +100,23 @@ typedef long Elf64_Sxword; #define ELF64_ST_TYPE(x) ELF32_ST_TYPE (x) typedef struct dynamic32 { - Elf32_Sword d_tag; - union{ - Elf32_Sword d_val; - Elf32_Addr d_ptr; - } d_un; + Elf32_Sword d_tag; + union { + Elf32_Sword d_val; + Elf32_Addr d_ptr; + } d_un; } Elf32_Dyn; typedef struct dynamic64 { - Elf64_Sxword d_tag; - union{ - Elf64_Xword d_val; - Elf64_Addr d_ptr; - } d_un; + Elf64_Sxword d_tag; + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; } Elf64_Dyn; #ifndef QNX4 -extern Elf32_Dyn _DYNAMIC []; +extern Elf32_Dyn _DYNAMIC[]; #endif /* The following are used with relocations */ @@ -141,7 +140,7 @@ extern Elf32_Dyn _DYNAMIC []; #define R_386_GOTPC 10 #define R_386_NUM 11 -/* x86_64 Relocation Types */ +/* AMD64 Relocation Types */ #define R_X86_64_NONE 0 #define R_X86_64_64 1 #define R_X86_64_PC32 2 @@ -221,29 +220,29 @@ extern Elf32_Dyn _DYNAMIC []; #define R_SPARC_NUM 56 /* m68k Relocation Types */ -#define R_68K_NONE 0 /* No reloc */ -#define R_68K_32 1 /* Direct 32 bit */ -#define R_68K_16 2 /* Direct 16 bit */ -#define R_68K_8 3 /* Direct 8 bit */ -#define R_68K_PC32 4 /* PC relative 32 bit */ -#define R_68K_PC16 5 /* PC relative 16 bit */ -#define R_68K_PC8 6 /* PC relative 8 bit */ -#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ -#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ -#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ -#define R_68K_GOT32O 10 /* 32 bit GOT offset */ -#define R_68K_GOT16O 11 /* 16 bit GOT offset */ -#define R_68K_GOT8O 12 /* 8 bit GOT offset */ -#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ -#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ -#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ -#define R_68K_PLT32O 16 /* 32 bit PLT offset */ -#define R_68K_PLT16O 17 /* 16 bit PLT offset */ -#define R_68K_PLT8O 18 /* 8 bit PLT offset */ -#define R_68K_COPY 19 /* Copy symbol at runtime */ -#define R_68K_GLOB_DAT 20 /* Create GOT entry */ -#define R_68K_JMP_SLOT 21 /* Create PLT entry */ -#define R_68K_RELATIVE 22 /* Adjust by program base */ +#define R_68K_NONE 0 /* No reloc */ +#define R_68K_32 1 /* Direct 32 bit */ +#define R_68K_16 2 /* Direct 16 bit */ +#define R_68K_8 3 /* Direct 8 bit */ +#define R_68K_PC32 4 /* PC relative 32 bit */ +#define R_68K_PC16 5 /* PC relative 16 bit */ +#define R_68K_PC8 6 /* PC relative 8 bit */ +#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ +#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ +#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ +#define R_68K_GOT32O 10 /* 32 bit GOT offset */ +#define R_68K_GOT16O 11 /* 16 bit GOT offset */ +#define R_68K_GOT8O 12 /* 8 bit GOT offset */ +#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ +#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ +#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ +#define R_68K_PLT32O 16 /* 32 bit PLT offset */ +#define R_68K_PLT16O 17 /* 16 bit PLT offset */ +#define R_68K_PLT8O 18 /* 8 bit PLT offset */ +#define R_68K_COPY 19 /* Copy symbol at runtime */ +#define R_68K_GLOB_DAT 20 /* Create GOT entry */ +#define R_68K_JMP_SLOT 21 /* Create PLT entry */ +#define R_68K_RELATIVE 22 /* Adjust by program base */ /* Alpha Relocation Types */ #define R_ALPHA_NONE 0 /* No reloc */ @@ -495,79 +494,79 @@ extern Elf32_Dyn _DYNAMIC []; #define R_ARM_RBASE 255 typedef struct elf32_rel { - Elf32_Addr r_offset; - Elf32_Word r_info; + Elf32_Addr r_offset; + Elf32_Word r_info; } Elf32_Rel; typedef struct elf64_rel { - Elf64_Addr r_offset; - Elf64_Xword r_info; + Elf64_Addr r_offset; + Elf64_Xword r_info; } Elf64_Rel; -typedef struct elf32_rela{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; +typedef struct elf32_rela { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; } Elf32_Rela; -typedef struct elf64_rela{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; +typedef struct elf64_rela { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; } Elf64_Rela; -typedef struct elf32_sym{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf32_Half st_shndx; +typedef struct elf32_sym { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; } Elf32_Sym; -typedef struct elf64_sym{ - Elf64_Word st_name; - unsigned char st_info; - unsigned char st_other; - Elf64_Half st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; +typedef struct elf64_sym { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Half st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; } Elf64_Sym; #define EI_NIDENT 16 -typedef struct elf32hdr{ - unsigned char e_ident[EI_NIDENT]; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; /* Entry point */ - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; +typedef struct elf32hdr { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; /* Entry point */ + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; } Elf32_Ehdr; typedef struct elf64hdr { - unsigned char e_ident[EI_NIDENT]; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; + unsigned char e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; } Elf64_Ehdr; /* These constants define the permissions on sections in the program @@ -576,27 +575,26 @@ typedef struct elf64hdr { #define PF_W 0x2 #define PF_X 0x1 -typedef struct elf_phdr{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; +typedef struct elf_phdr { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; } Elf32_Phdr; -typedef struct -{ - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; } Elf64_Phdr; /* sh_type */ @@ -618,7 +616,7 @@ typedef struct #define SHT_LOUSER 0x80000000 #define SHT_HIUSER 0xffffffff -#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ /* sh_flags */ #define SHF_WRITE 0x1 @@ -634,35 +632,34 @@ typedef struct #define SHN_ABS 0xfff1 #define SHN_COMMON 0xfff2 #define SHN_HIRESERVE 0xffff - + typedef struct { - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; } Elf32_Shdr; -typedef struct -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; +typedef struct { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; } Elf64_Shdr; -#define EI_MAG0 0 /* e_ident[] indexes */ +#define EI_MAG0 0 /* e_ident[] indexes */ #define EI_MAG1 1 #define EI_MAG2 2 #define EI_MAG3 3 @@ -671,7 +668,7 @@ typedef struct #define EI_VERSION 6 #define EI_PAD 7 -#define ELFMAG0 0x7f /* EI_MAG */ +#define ELFMAG0 0x7f /* EI_MAG */ #define ELFMAG1 'E' #define ELFMAG2 'L' #define ELFMAG3 'F' @@ -681,16 +678,16 @@ typedef struct #define ELFDLMAG 3 #define ELFDLOFF 16 -#define ELFCLASSNONE 0 /* EI_CLASS */ +#define ELFCLASSNONE 0 /* EI_CLASS */ #define ELFCLASS32 1 #define ELFCLASS64 2 #define ELFCLASSNUM 3 -#define ELFDATANONE 0 /* e_ident[EI_DATA] */ +#define ELFDATANONE 0 /* e_ident[EI_DATA] */ #define ELFDATA2LSB 1 #define ELFDATA2MSB 2 -#define EV_NONE 0 /* e_version, EI_VERSION */ +#define EV_NONE 0 /* e_version, EI_VERSION */ #define EV_CURRENT 1 #define EV_NUM 2 @@ -702,9 +699,9 @@ typedef struct /* Note header in a PT_NOTE section */ typedef struct elf_note { - Elf32_Word n_namesz; /* Name size */ - Elf32_Word n_descsz; /* Content size */ - Elf32_Word n_type; /* Content type */ + Elf32_Word n_namesz; /* Name size */ + Elf32_Word n_descsz; /* Content size */ + Elf32_Word n_type; /* Content type */ } Elf32_Nhdr; #define ELF_START_MMAP 0x80000000 diff --git a/hw/xfree86/loader/elfloader.c b/hw/xfree86/loader/elfloader.c index 822a50efa..5ab8af62d 100644 --- a/hw/xfree86/loader/elfloader.c +++ b/hw/xfree86/loader/elfloader.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.49 2003/01/24 17:26:35 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.62 2003/11/06 18:38:13 tsi Exp $ */ /* * @@ -23,7 +23,9 @@ * PERFORMANCE OF THIS SOFTWARE. */ #include <sys/types.h> +#ifndef __UNIXOS2__ #include <sys/mman.h> +#endif #include <unistd.h> #include <stdlib.h> #ifdef __QNX__ @@ -52,13 +54,75 @@ #include "compiler.h" -#undef LDTEST +#ifndef LOADERDEBUG +#define LOADERDEBUG 0 +#endif -/* -#ifndef LDTEST +#if LOADERDEBUG # define ELFDEBUG ErrorF #endif -*/ + +#if defined(__ia64__) + +/* + * R_IA64_LTOFF22X and R_IA64_LDXMOV are relocation optimizations for + * IA64. Conforming implementations must recognize them and may either + * implement the optimization or may fallback to previous + * non-optimized behavior by treating R_IA64_LTOFF22X as a + * R_IA64_LTOFF22 and ignoring R_IA64_LDXMOV. The + * IA64_LDX_OPTIMIZATION conditional controls the fallback behavior, + * if defined the optimizations are performed. + * + * To implement the optimization we want to change is the sequence on + * the left to that on the right, without regard to any intervening + * instructions: + * + * 1) addl t1=@ltoff(var),gp ==> addl t1=@gprel(var),gp + * 2) ld8 t2=[t1] ==> mov t2=t1 + * 3) ld8 loc0=[t2] ==> ld8 loc0=[t2] + * + * The relocations that match the above instructions are: + * + * 1) R_IA64_LTOFF22 ==> R_IA64_LTOFF22X + * 2) -- ==> R_IA64_LDXMOV + * 3) -- ==> -- + * + * First lets look at left hand column to understand the original + * mechanism. The virtual address of a symbol is stored in the GOT, + * when that symbol is referenced the following sequence occurs, + * instruction 1 loads the address of the GOT entry containing the + * virtural address of the symbol into t1. Instruction 2 loads the + * virtual address of the symbol into t2 by dereferencing t1. Finally + * the symbol is loaded in instruction 3 by dereferencing its virtual + * address in t2. + * + * The optimization that LTOFF22X/LDXMOV introduces is based on the + * observation we are doing an extra load (instruction 2) if we can + * generate the virtual address for the symbol without doing a lookup in + * the GOT. This is possible if the virtual address of the symbol can be + * computed via GP relative addressing. In other words the virtual + * address of the symbol is a fixed offset from the GP. This fixed offset + * must be within the limits of the signed 22 bit immediate offset in the + * ld8 instruction, otherwise the original indirect GOT lookup must be + * performed (LTOFF22). + * + * If we can use GP relative addressing for the symbol then the + * instruction that loaded the virtual address of the symbol into t2 must + * also be patched, hence the introduction of the LDXMOV relocation. The + * LDXMOV essentially turns the GOT lookup into a no-op by changing the + * ld8 into a register move that preserves the register location of the + * symbol's virtual address (e.g. t2). + * + * The important point to recognize when implementing the LTOFF22X/LDXMOV + * optimization is that relocations are interdependent, the LDXMOV is + * only applied if the LTOFF22X is applied. It is also worth noting that + * there is no relationship between LDXMOV relocations and LTOFF22X in + * the ELF relocation section other than they share the same + * symbol+addend value. + */ + +#define IA64_LDX_OPTIMIZATION 1 +#endif #ifndef UseMMAP # if defined (__ia64__) || defined (__sparc__) @@ -73,7 +137,7 @@ # if !defined(linux) # error No MAP_ANON? # endif -# if !defined (__x86_64__) +# if !defined (__AMD64__) || !defined(__linux__) # define MMAP_FLAGS (MAP_PRIVATE | MAP_ANON) # else # define MMAP_FLAGS (MAP_PRIVATE | MAP_ANON | MAP_32BIT) @@ -91,7 +155,7 @@ #if defined (__alpha__) || \ defined (__ia64__) || \ - defined (__x86_64__) || \ + defined (__AMD64__) || \ (defined (__sparc__) && \ (defined (__arch64__) || \ defined (__sparcv9))) @@ -105,6 +169,7 @@ typedef Elf64_Half Elf_Half; typedef Elf64_Off Elf_Off; typedef Elf64_Sword Elf_Sword; typedef Elf64_Word Elf_Word; + #define ELF_ST_BIND ELF64_ST_BIND #define ELF_ST_TYPE ELF64_ST_TYPE #define ELF_R_SYM ELF64_R_SYM @@ -117,17 +182,17 @@ typedef Elf64_Word Elf_Word; * */ typedef struct _elf_GOT_Entry { - Elf_Rela *rel; - int offset; - struct _elf_GOT_Entry *next; + 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]; + unsigned int size; + unsigned int nuses; + unsigned char *freeptr; + struct _elf_GOT *next; + unsigned char section[1]; } ELFGotRec, *ELFGotPtr; # ifdef MergeSectionAlloc @@ -141,10 +206,10 @@ static ELFGotPtr ELFSharedGOTs; * have already been added to the PLT. */ typedef struct _elf_PLT_Entry { - Elf_Rela *rel; - int offset; - int gotoffset; - struct _elf_PLT_Entry *next; + Elf_Rela *rel; + int offset; + int gotoffset; + struct _elf_PLT_Entry *next; } ELFPltEntryRec, *ELFPltEntryPtr; /* @@ -152,10 +217,10 @@ typedef struct _elf_PLT_Entry { * of entries that have already been added to the OPD. */ typedef struct _elf_OPD { - LOOKUP *l; - int index; - int offset; - struct _elf_OPD *next; + LOOKUP *l; + int index; + int offset; + struct _elf_OPD *next; } ELFOpdRec, *ELFOpdPtr; # endif @@ -170,6 +235,7 @@ typedef Elf32_Half Elf_Half; typedef Elf32_Off Elf_Off; typedef Elf32_Sword Elf_Sword; typedef Elf32_Word Elf_Word; + #define ELF_ST_BIND ELF32_ST_BIND #define ELF_ST_TYPE ELF32_ST_TYPE #define ELF_R_SYM ELF32_R_SYM @@ -181,10 +247,10 @@ typedef Elf32_Word Elf_Word; defined(__alpha__) || \ defined(__sparc__) || \ defined(__ia64__) || \ - defined(__x86_64__) + defined(__AMD64__) typedef Elf_Rela Elf_Rel_t; #else -typedef Elf_Rel Elf_Rel_t; +typedef Elf_Rel Elf_Rel_t; #endif typedef struct { @@ -203,57 +269,57 @@ typedef struct { * that has been loaded. */ -typedef struct { - int handle; - int module; - int fd; - loader_funcs *funcs; - Elf_Ehdr *header;/* file header */ - int numsh; - Elf_Shdr *sections;/* Address of the section header table */ - int secsize; /* size of the section table */ - unsigned char **saddr;/* Start addresss of the section pointer table */ - 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 */ +typedef struct { + int handle; + int module; + int fd; + loader_funcs *funcs; + Elf_Ehdr *header; /* file header */ + int numsh; + Elf_Shdr *sections; /* Address of the section header table */ + int secsize; /* size of the section table */ + unsigned char **saddr; /* Start addresss of the section pointer table */ + 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__) - 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__)*/ + 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__) */ #if defined(__ia64__) - ELFOpdPtr opd_entries; /* List of entries in the .opd section */ - unsigned char *plt; /* Start address of the .plt section */ - ELFPltEntryPtr plt_entries; /* List of entries in the .plt section */ - int pltndx; /* index of the .plt section */ - int pltsize; /* size of the .plt section */ + ELFOpdPtr opd_entries; /* List of entries in the .opd section */ + unsigned char *plt; /* Start address of the .plt section */ + ELFPltEntryPtr plt_entries; /* List of entries in the .plt section */ + int pltndx; /* index of the .plt section */ + int pltsize; /* size of the .plt section */ #endif /*__ia64__*/ - Elf_Sym *symtab; /* Start address of the .symtab section */ - int symndx; /* index of the .symtab section */ - unsigned char *common; /* Start address of the SHN_COMMON space */ - int comsize; /* size of the SHN_COMMON space */ - - unsigned char *base; /* Alloced address of section block */ - unsigned long baseptr; /* Pointer to next free space in base */ - int basesize; /* Size of that allocation */ - unsigned char *straddr; /* Start address of the string table */ - int strndx; /* index of the string table */ - int strsize; /* size of the string table */ - LoadSection *lsection; - int lsectidx; -} ELFModuleRec, *ELFModulePtr; + Elf_Sym *symtab; /* Start address of the .symtab section */ + int symndx; /* index of the .symtab section */ + unsigned char *common; /* Start address of the SHN_COMMON space */ + int comsize; /* size of the SHN_COMMON space */ + + unsigned char *base; /* Alloced address of section block */ + unsigned long baseptr; /* Pointer to next free space in base */ + int basesize; /* Size of that allocation */ + unsigned char *straddr; /* Start address of the string table */ + int strndx; /* index of the string table */ + int strsize; /* size of the string table */ + LoadSection *lsection; + int lsectidx; +} ELFModuleRec, *ELFModulePtr; /* * If a relocation is unable to be satisfied, then put it on a list * to try later after more modules have been loaded. */ typedef struct _elf_reloc { - Elf_Rel_t *rel; - ELFModulePtr file; - Elf_Word secn; - struct _elf_reloc *next; + Elf_Rel_t *rel; + ELFModulePtr file; + Elf_Word secn; + struct _elf_reloc *next; } ELFRelocRec; /* @@ -263,11 +329,11 @@ typedef struct _elf_reloc { * are done. */ typedef struct _elf_COMMON { - Elf_Sym *sym; - struct _elf_COMMON *next; + Elf_Sym *sym; + struct _elf_COMMON *next; } ELFCommonRec; -static ELFCommonPtr listCOMMON=NULL; +static ELFCommonPtr listCOMMON = NULL; /* Prototypes for static functions */ static int ELFhashCleanOut(void *, itemPtr); @@ -277,14 +343,16 @@ static char *ElfGetSectionName(ELFModulePtr, int); static ELFRelocPtr ElfDelayRelocation(ELFModulePtr, Elf_Word, Elf_Rel_t *); static ELFCommonPtr ElfAddCOMMON(Elf_Sym *); static int ElfCOMMONSize(void); -static int ElfCreateCOMMON(ELFModulePtr,LOOKUP *); +static int ElfCreateCOMMON(ELFModulePtr, LOOKUP *); static char *ElfGetSymbolNameIndex(ELFModulePtr, int, int); static char *ElfGetSymbolName(ELFModulePtr, int); static Elf_Addr ElfGetSymbolValue(ELFModulePtr, int); -static ELFRelocPtr Elf_RelocateEntry(ELFModulePtr, Elf_Word, Elf_Rel_t *, int); +static ELFRelocPtr Elf_RelocateEntry(ELFModulePtr, Elf_Word, Elf_Rel_t *, + int); static ELFRelocPtr ELFCollectRelocations(ELFModulePtr, int); static LOOKUP *ELF_GetSymbols(ELFModulePtr, unsigned short **); static void ELFCollectSections(ELFModulePtr, int, int *, int *); + #if defined(__alpha__) || defined(__ia64__) static void ElfAddGOT(ELFModulePtr, Elf_Rel_t *); static int ELFCreateGOT(ELFModulePtr, int); @@ -296,21 +364,19 @@ static void ElfAddPLT(ELFModulePtr, Elf_Rel_t *); static void ELFCreatePLT(ELFModulePtr); enum ia64_operand { IA64_OPND_IMM22, - IA64_OPND_TGT25C + IA64_OPND_TGT25C, + IA64_OPND_LDXMOV }; static void IA64InstallReloc(unsigned long *, int, enum ia64_operand, long); #endif /*__ia64__*/ #ifdef MergeSectionAlloc static void * -ELFLoaderSectToMem(elffile, align, offset, size, label) -ELFModulePtr elffile; -int align; -unsigned long offset; -int size; -char *label; +ELFLoaderSectToMem(ELFModulePtr elffile, int align, unsigned long offset, + int size, char *label) { void *ret; + elffile->baseptr = (elffile->baseptr + align - 1) & ~(align - 1); ret = (void *)elffile->baseptr; _LoaderFileRead(elffile->fd, offset, ret, size); @@ -319,17 +385,15 @@ char *label; } static void * -ELFLoaderSectCalloc(elffile, align, size) -ELFModulePtr elffile; -int align; -int size; +ELFLoaderSectCalloc(ELFModulePtr elffile, int align, int size) { void *ret; + elffile->baseptr = (elffile->baseptr + align - 1) & ~(align - 1); ret = (void *)elffile->baseptr; elffile->baseptr += size; #ifndef DoMMAPedMerge - memset(ret, 0, size); /* mmap() does this for us */ + memset(ret, 0, size); /* mmap() does this for us */ #endif return ret; } @@ -343,13 +407,11 @@ _LoaderFileToMem((elffile)->fd,offset,size,label) * Utility Functions */ - static int -ELFhashCleanOut(voidptr, item) -void *voidptr; -itemPtr item ; +ELFhashCleanOut(void *voidptr, itemPtr item) { ELFModulePtr module = (ELFModulePtr) voidptr; + return (module->handle == item->handle); } @@ -357,31 +419,29 @@ itemPtr item ; * Manage listResolv */ static ELFRelocPtr -ElfDelayRelocation(elffile, secn, rel) -ELFModulePtr elffile; -Elf_Word secn; -Elf_Rel_t *rel; +ElfDelayRelocation(ELFModulePtr elffile, Elf_Word secn, Elf_Rel_t *rel) { - ELFRelocPtr reloc; + ELFRelocPtr reloc; if ((reloc = xf86loadermalloc(sizeof(ELFRelocRec))) == NULL) { - ErrorF( "ElfDelayRelocation() Unable to allocate memory!!!!\n" ); + ErrorF("ElfDelayRelocation() Unable to allocate memory!!!!\n"); return 0; } - reloc->file=elffile; - reloc->secn=secn; - reloc->rel=rel; - reloc->next=0; + reloc->file = elffile; + reloc->secn = secn; + reloc->rel = rel; + reloc->next = 0; #ifdef ELFDEBUG - ELFDEBUG("ElfDelayRelocation %lx: file %lx, sec %d," + ELFDEBUG("ElfDelayRelocation %p: file %p, sec %d," " r_offset 0x%lx, r_info 0x%x", - reloc, elffile, secn, rel->r_offset, rel->r_info); + (void *)reloc, (void *)elffile, secn, + (unsigned long)rel->r_offset, rel->r_info); # if defined(__powerpc__) || \ defined(__mc68000__) || \ defined(__alpha__) || \ defined(__sparc__) || \ defined(__ia64__) || \ - defined(__x86_64__) + defined(__AMD64__) ELFDEBUG(", r_addend 0x%lx", rel->r_addend); # endif ELFDEBUG("\n"); @@ -393,162 +453,146 @@ Elf_Rel_t *rel; * Manage listCOMMON */ static ELFCommonPtr -ElfAddCOMMON(sym) -Elf_Sym *sym; +ElfAddCOMMON(Elf_Sym *sym) { ELFCommonPtr common; if ((common = xf86loadermalloc(sizeof(ELFCommonRec))) == NULL) { - ErrorF( "ElfAddCOMMON() Unable to allocate memory!!!!\n" ); + ErrorF("ElfAddCOMMON() Unable to allocate memory!!!!\n"); return 0; } - common->sym=sym; - common->next=0; + common->sym = sym; + common->next = 0; return common; } static int ElfCOMMONSize(void) { - int size=0; + int size = 0; ELFCommonPtr common; for (common = listCOMMON; common; common = common->next) { - size+=common->sym->st_size; + size += common->sym->st_size; #if defined(__alpha__) || \ defined(__ia64__) || \ - defined(__x86_64__) || \ + defined(__AMD64__) || \ (defined(__sparc__) && \ (defined(__arch64__) || \ defined(__sparcv9))) - size = (size+7)&~0x7; + size = (size + 7) & ~0x7; #endif } return size; } static int -ElfCreateCOMMON(elffile,pLookup) -ELFModulePtr elffile; -LOOKUP *pLookup; +ElfCreateCOMMON(ELFModulePtr elffile, LOOKUP *pLookup) { - int numsyms=0,size=0,l=0; - int offset=0,firstcommon=0; + int numsyms = 0, size = 0, l = 0; + int offset = 0, firstcommon = 0; ELFCommonPtr common; if (listCOMMON == NULL) return TRUE; for (common = listCOMMON; common; common = common->next) { - size+=common->sym->st_size; + size += common->sym->st_size; #if defined(__alpha__) || \ defined(__ia64__) || \ - defined(__x86_64__) || \ + defined(__AMD64__) || \ (defined(__sparc__) && \ (defined(__arch64__) || \ defined(__sparcv9))) - size = (size+7)&~0x7; + size = (size + 7) & ~0x7; #endif numsyms++; } #ifdef ELFDEBUG ELFDEBUG("ElfCreateCOMMON() %d entries (%d bytes) of COMMON data\n", - numsyms, size ); + numsyms, size); #endif - elffile->comsize=size; - if((elffile->common = ELFLoaderSectCalloc(elffile,8,size)) == NULL) { - ErrorF( "ElfCreateCOMMON() Unable to allocate memory!!!!\n" ); + elffile->comsize = size; + if ((elffile->common = ELFLoaderSectCalloc(elffile, 8, size)) == NULL) { + ErrorF("ElfCreateCOMMON() Unable to allocate memory!!!!\n"); return FALSE; } - if (DebuggerPresent) - { - ldrCommons = xf86loadermalloc(numsyms*sizeof(LDRCommon)); + if (DebuggerPresent) { + ldrCommons = xf86loadermalloc(numsyms * sizeof(LDRCommon)); nCommons = numsyms; } - for (l = 0; pLookup[l].symName; l++) - ; - firstcommon=l; - + for (l = 0; pLookup[l].symName; l++) ; + firstcommon = l; + /* Traverse the common list and create a lookup table with all the * common symbols. Destroy the common list in the process. * See also ResolveSymbols. */ - while(listCOMMON) { - common=listCOMMON; + while (listCOMMON) { + common = listCOMMON; /* this is xstrdup because is should be more efficient. it is freed * with xf86loaderfree */ pLookup[l].symName = - xf86loaderstrdup(ElfGetString(elffile,common->sym->st_name)); - pLookup[l].offset = (funcptr)(elffile->common + offset); + xf86loaderstrdup(ElfGetString(elffile, common->sym->st_name)); + pLookup[l].offset = (funcptr) (elffile->common + offset); #ifdef ELFDEBUG - ELFDEBUG("Adding common %lx %s\n", - pLookup[l].offset, pLookup[l].symName); + ELFDEBUG("Adding common %p %s\n", + (void *)pLookup[l].offset, pLookup[l].symName); #endif - + /* Record the symbol address for gdb */ - if (DebuggerPresent && ldrCommons) - { - ldrCommons[l-firstcommon].addr = (void *)pLookup[l].offset; - ldrCommons[l-firstcommon].name = pLookup[l].symName; - ldrCommons[l-firstcommon].namelen = strlen(pLookup[l].symName); + if (DebuggerPresent && ldrCommons) { + ldrCommons[l - firstcommon].addr = (void *)pLookup[l].offset; + ldrCommons[l - firstcommon].name = pLookup[l].symName; + ldrCommons[l - firstcommon].namelen = strlen(pLookup[l].symName); } - listCOMMON=common->next; - offset+=common->sym->st_size; + listCOMMON = common->next; + offset += common->sym->st_size; #if defined(__alpha__) || \ defined(__ia64__) || \ - defined(__x86_64__) || \ + defined(__AMD64__) || \ (defined(__sparc__) && \ (defined(__arch64__) || \ defined(__sparcv9))) - offset = (offset+7)&~0x7; + offset = (offset + 7) & ~0x7; #endif xf86loaderfree(common); l++; } /* listCOMMON == 0 */ - pLookup[l].symName=NULL; /* Terminate the list. */ + pLookup[l].symName = NULL; /* Terminate the list. */ return TRUE; } - /* * String Table */ static char * -ElfGetStringIndex(file, offset, index) -ELFModulePtr file; -int offset; -int index; +ElfGetStringIndex(ELFModulePtr file, int offset, int index) { - if( !offset || !index ) - return ""; + if (!offset || !index) + return ""; - return (char *)(file->saddr[index]+offset); + return (char *)(file->saddr[index] + offset); } static char * -ElfGetString(file, offset) -ELFModulePtr file; -int offset; +ElfGetString(ELFModulePtr file, int offset) { - return ElfGetStringIndex( file, offset, file->strndx ); + return ElfGetStringIndex(file, offset, file->strndx); } static char * -ElfGetSectionName(file, offset) -ELFModulePtr file; -int offset; +ElfGetSectionName(ELFModulePtr file, int offset) { - return (char *)(file->shstraddr+offset); + return (char *)(file->shstraddr + offset); } - - /* * Symbol Table */ @@ -557,113 +601,105 @@ int offset; * Get symbol name */ static char * -ElfGetSymbolNameIndex(elffile, index, secndx) -ELFModulePtr elffile; -int index; -int secndx; +ElfGetSymbolNameIndex(ELFModulePtr elffile, int index, int secndx) { - Elf_Sym *syms; + Elf_Sym *syms; #ifdef ELFDEBUG - ELFDEBUG("ElfGetSymbolNameIndex(%x,%x) ",index, secndx ); + ELFDEBUG("ElfGetSymbolNameIndex(%x,%x) ", index, secndx); #endif - syms=(Elf_Sym *)elffile->saddr[secndx]; + syms = (Elf_Sym *) elffile->saddr[secndx]; #ifdef ELFDEBUG - ELFDEBUG("%s ",ElfGetString(elffile, syms[index].st_name)); - ELFDEBUG("%x %x ",ELF_ST_BIND(syms[index].st_info), + ELFDEBUG("%s ", ElfGetString(elffile, syms[index].st_name)); + ELFDEBUG("%x %x ", ELF_ST_BIND(syms[index].st_info), ELF_ST_TYPE(syms[index].st_info)); - ELFDEBUG("%lx\n",syms[index].st_value); + ELFDEBUG("%lx\n", (unsigned long)syms[index].st_value); #endif - return ElfGetString(elffile,syms[index].st_name ); + return ElfGetString(elffile, syms[index].st_name); } static char * -ElfGetSymbolName(elffile, index) -ELFModulePtr elffile; -int index; +ElfGetSymbolName(ELFModulePtr elffile, int index) { return ElfGetSymbolNameIndex(elffile, index, elffile->symndx); } static Elf_Addr -ElfGetSymbolValue(elffile, index) -ELFModulePtr elffile; -int index; +ElfGetSymbolValue(ELFModulePtr elffile, int index) { - Elf_Sym *syms; - Elf_Addr symval=0; /* value of the indicated symbol */ - char *symname = NULL; /* name of symbol in relocation */ - itemPtr symbol = NULL; /* name/value of symbol */ + Elf_Sym *syms; + Elf_Addr symval = 0; /* value of the indicated symbol */ + char *symname = NULL; /* name of symbol in relocation */ + itemPtr symbol = NULL; /* name/value of symbol */ - syms=(Elf_Sym *)elffile->saddr[elffile->symndx]; + syms = (Elf_Sym *) elffile->saddr[elffile->symndx]; - switch( ELF_ST_TYPE(syms[index].st_info) ) - { - case STT_NOTYPE: - case STT_OBJECT: - case STT_FUNC: - switch( ELF_ST_BIND(syms[index].st_info) ) - { - case STB_LOCAL: - symval=(Elf_Addr)( - elffile->saddr[syms[index].st_shndx]+ - syms[index].st_value); + switch (ELF_ST_TYPE(syms[index].st_info)) { + case STT_NOTYPE: + case STT_OBJECT: + case STT_FUNC: + switch (ELF_ST_BIND(syms[index].st_info)) { + case STB_LOCAL: + symval = (Elf_Addr) (elffile->saddr[syms[index].st_shndx] + + syms[index].st_value); #ifdef __ia64__ - if( ELF_ST_TYPE(syms[index].st_info) == STT_FUNC ) { - ELFOpdPtr opdent; - for (opdent = elffile->opd_entries; opdent; opdent = opdent->next) - if (opdent->index == index) - break; - if(opdent) { - ((unsigned long *)(elffile->got+opdent->offset))[0] = symval; - ((unsigned long *)(elffile->got+opdent->offset))[1] = (long)elffile->got; - symval = (Elf_Addr)(elffile->got+opdent->offset); - } - } -#endif - break; - case STB_GLOBAL: - case STB_WEAK: /* STB_WEAK seems like a hack to cover for - some other problem */ - symname= - ElfGetString(elffile,syms[index].st_name); - symbol = LoaderHashFind(symname); - if( symbol == 0 ) { - return 0; - } - symval=(Elf_Addr)symbol->address; - break; - default: - symval=0; - ErrorF( - "ElfGetSymbolValue(), unhandled symbol scope %x\n", - ELF_ST_BIND(syms[index].st_info) ); - break; + if (ELF_ST_TYPE(syms[index].st_info) == STT_FUNC) { + ELFOpdPtr opdent; + + for (opdent = elffile->opd_entries; opdent; + opdent = opdent->next) + if (opdent->index == index) + break; + if (opdent) { + ((unsigned long *)(elffile->got + opdent->offset))[0] = + symval; + ((unsigned long *)(elffile->got + opdent->offset))[1] = + (long)elffile->got; + symval = (Elf_Addr) (elffile->got + opdent->offset); } -#ifdef ELFDEBUG - ELFDEBUG( "%lx\t", symbol ); - ELFDEBUG( "%lx\t", symval ); - ELFDEBUG( "%s\n", symname ? symname : "NULL"); + } #endif break; - case STT_SECTION: - symval=(Elf_Addr)elffile->saddr[syms[index].st_shndx]; -#ifdef ELFDEBUG - ELFDEBUG( "ST_SECTION %lx\n", symval ); -#endif + case STB_GLOBAL: + case STB_WEAK: /* STB_WEAK seems like a hack to cover for + * some other problem */ + symname = ElfGetString(elffile, syms[index].st_name); + symbol = LoaderHashFind(symname); + if (symbol == 0) { + return 0; + } + symval = (Elf_Addr) symbol->address; break; - case STT_FILE: - case STT_LOPROC: - case STT_HIPROC: default: - symval=0; - ErrorF( "ElfGetSymbolValue(), unhandled symbol type %x\n", - ELF_ST_TYPE(syms[index].st_info) ); + symval = 0; + ErrorF("ElfGetSymbolValue(), unhandled symbol scope %x\n", + ELF_ST_BIND(syms[index].st_info)); break; } +#ifdef ELFDEBUG + ELFDEBUG("%p\t", (void *)symbol); + ELFDEBUG("%lx\t", (unsigned long)symval); + ELFDEBUG("%s\n", symname ? symname : "NULL"); +#endif + break; + case STT_SECTION: + symval = (Elf_Addr) elffile->saddr[syms[index].st_shndx]; +#ifdef ELFDEBUG + ELFDEBUG("ST_SECTION %lx\n", (unsigned long)symval); +#endif + break; + case STT_FILE: + case STT_LOPROC: + case STT_HIPROC: + default: + symval = 0; + ErrorF("ElfGetSymbolValue(), unhandled symbol type %x\n", + ELF_ST_TYPE(syms[index].st_info)); + break; + } return symval; } @@ -676,30 +712,25 @@ int index; * will be within a 24 bit offset (non-PIC code). */ static Elf_Addr -ElfGetPltAddr(elffile, index) -ELFModulePtr elffile; -int index; +ElfGetPltAddr(ELFModulePtr elffile, int index) { - Elf_Sym *syms; - Elf_Addr symval=0; /* value of the indicated symbol */ + Elf_Sym *syms; + Elf_Addr symval = 0; /* value of the indicated symbol */ char *symname = NULL; /* name of symbol in relocation */ itemPtr symbol; /* name/value of symbol */ - syms=(Elf_Sym *)elffile->saddr[elffile->symndx]; + syms = (Elf_Sym *) elffile->saddr[elffile->symndx]; - switch( ELF_ST_TYPE(syms[index].st_info) ) - { - case STT_NOTYPE: - case STT_OBJECT: - case STT_FUNC: - switch( ELF_ST_BIND(syms[index].st_info) ) - { - case STB_GLOBAL: - symname= - ElfGetString(elffile,syms[index].st_name); - symbol=LoaderHashFind(symname); - if( symbol == 0 ) - return 0; + switch (ELF_ST_TYPE(syms[index].st_info)) { + case STT_NOTYPE: + case STT_OBJECT: + case STT_FUNC: + switch (ELF_ST_BIND(syms[index].st_info)) { + case STB_GLOBAL: + symname = ElfGetString(elffile, syms[index].st_name); + symbol = LoaderHashFind(symname); + if (symbol == 0) + return 0; /* * Here we are building up a pseudo Plt function that can make a call to * a function that has an offset greater than 24 bits. The following code @@ -715,43 +746,43 @@ int index; */ - symbol->code.plt[0]=0x3d80; /* lis r12 */ - symbol->code.plt[1]=(((Elf_Addr)symbol->address)&0xffff0000)>>16; - symbol->code.plt[2]=0x618c; /* ori r12,r12 */ - symbol->code.plt[3]=(((Elf_Addr)symbol->address)&0xffff); - symbol->code.plt[4]=0x7d89; /* mtcr r12 */ - symbol->code.plt[5]=0x03a6; - symbol->code.plt[6]=0x4e80; /* bctr */ - symbol->code.plt[7]=0x0420; - symbol->address=(char *)&symbol->code.plt[0]; - symval=(Elf_Addr)symbol->address; - ppc_flush_icache(&symbol->code.plt[0]); - ppc_flush_icache(&symbol->code.plt[6]); - break; - default: - symval=0; - ErrorF( - "ElfGetPltAddr(), unhandled symbol scope %x\n", - ELF_ST_BIND(syms[index].st_info) ); - break; - } -# ifdef ELFDEBUG - ELFDEBUG( "ElfGetPlt: symbol=%lx\t", symbol ); - ELFDEBUG( "newval=%lx\t", symval ); - ELFDEBUG( "name=\"%s\"\n", symname ? symname : "NULL"); -# endif + symbol->code.plt[0] = 0x3d80; /* lis r12 */ + symbol->code.plt[1] = + (((Elf_Addr) symbol->address) & 0xffff0000) >> 16; + symbol->code.plt[2] = 0x618c; /* ori r12,r12 */ + symbol->code.plt[3] = (((Elf_Addr) symbol->address) & 0xffff); + symbol->code.plt[4] = 0x7d89; /* mtcr r12 */ + symbol->code.plt[5] = 0x03a6; + symbol->code.plt[6] = 0x4e80; /* bctr */ + symbol->code.plt[7] = 0x0420; + symbol->address = (char *)&symbol->code.plt[0]; + symval = (Elf_Addr) symbol->address; + ppc_flush_icache(&symbol->code.plt[0]); + ppc_flush_icache(&symbol->code.plt[6]); break; - case STT_SECTION: - case STT_FILE: - case STT_LOPROC: - case STT_HIPROC: default: - symval=0; - ErrorF( "ElfGetPltAddr(), Unexpected symbol type %x", - ELF_ST_TYPE(syms[index].st_info) ); - ErrorF( "for a Plt request\n" ); + symval = 0; + ErrorF("ElfGetPltAddr(), unhandled symbol scope %x\n", + ELF_ST_BIND(syms[index].st_info)); break; } +# ifdef ELFDEBUG + ELFDEBUG("ElfGetPlt: symbol=%lx\t", symbol); + ELFDEBUG("newval=%lx\t", symval); + ELFDEBUG("name=\"%s\"\n", symname ? symname : "NULL"); +# endif + break; + case STT_SECTION: + case STT_FILE: + case STT_LOPROC: + case STT_HIPROC: + default: + symval = 0; + ErrorF("ElfGetPltAddr(), Unexpected symbol type %x", + ELF_ST_TYPE(syms[index].st_info)); + ErrorF("for a Plt request\n"); + break; + } return symval; } #endif /* __powerpc__ */ @@ -761,34 +792,33 @@ int index; * Manage GOT Entries */ static void -ElfAddGOT(elffile,rel) -ELFModulePtr elffile; -Elf_Rel_t *rel; +ElfAddGOT(ELFModulePtr elffile, Elf_Rel_t *rel) { ELFGotEntryPtr gotent; # ifdef ELFDEBUG { - Elf_Sym *sym; - - sym=(Elf_Sym *)&(elffile->symtab[ELF_R_SYM(rel->r_info)]); - if( sym->st_name) { - ELFDEBUG("ElfAddGOT: Adding GOT entry for %s\n", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - } - else - ELFDEBUG("ElfAddGOT: Adding GOT entry for %s\n", - ElfGetSectionName(elffile,elffile->sections[sym->st_shndx].sh_name)); + Elf_Sym *sym; + + sym = (Elf_Sym *) & (elffile->symtab[ELF_R_SYM(rel->r_info)]); + if (sym->st_name) { + ELFDEBUG("ElfAddGOT: Adding GOT entry for %s\n", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + } else + ELFDEBUG("ElfAddGOT: Adding GOT entry for %s\n", + ElfGetSectionName(elffile, + elffile->sections[sym->st_shndx]. + sh_name)); } # endif - 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; + 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 ) { + if (gotent) { # ifdef ELFDEBUG ELFDEBUG("Entry already present in GOT\n"); # endif @@ -796,25 +826,22 @@ Elf_Rel_t *rel; } if ((gotent = xf86loadermalloc(sizeof(ELFGotEntryRec))) == NULL) { - ErrorF( "ElfAddGOT() Unable to allocate memory!!!!\n" ); + ErrorF("ElfAddGOT() Unable to allocate memory!!!!\n"); return; } - # ifdef ELFDEBUG - ELFDEBUG("Entry added with offset %x\n",elffile->gotsize); + ELFDEBUG("Entry added with offset %x\n", elffile->gotsize); # endif - gotent->rel=rel; - gotent->offset=elffile->gotsize; - gotent->next=elffile->got_entries; - elffile->got_entries=gotent; - elffile->gotsize+=8; + gotent->rel = rel; + gotent->offset = elffile->gotsize; + gotent->next = elffile->got_entries; + elffile->got_entries = gotent; + elffile->gotsize += 8; return; } static int -ELFCreateGOT(elffile, maxalign) -ELFModulePtr elffile; -int maxalign; +ELFCreateGOT(ELFModulePtr elffile, int maxalign) { # ifdef MergeSectionAlloc ELFGotPtr gots; @@ -825,18 +852,19 @@ int maxalign; * XXX: Is it REALLY needed to ensure GOT's are non-null? */ # ifdef ELFDEBUG - ELFDEBUG( "ELFCreateGOT: %x entries in the GOT\n", elffile->gotsize/8 ); + ELFDEBUG("ELFCreateGOT: %x entries in the GOT\n", elffile->gotsize / 8); /* * Hmmm. Someone is getting here without any got entries, but they * may still have R_ALPHA_GPDISP relocations against the got. */ - if( elffile->gotsize == 0 ) - ELFDEBUG( "Module %s doesn't have any GOT entries!\n", - _LoaderModuleToName(elffile->module) ); + if (elffile->gotsize == 0) + ELFDEBUG("Module %s doesn't have any GOT entries!\n", + _LoaderModuleToName(elffile->module)); # endif - if( elffile->gotsize == 0 ) elffile->gotsize=8; - elffile->sections[elffile->gotndx].sh_size=elffile->gotsize; + if (elffile->gotsize == 0) + elffile->gotsize = 8; + elffile->sections[elffile->gotndx].sh_size = elffile->gotsize; gotsize = elffile->gotsize; # ifdef MergeSectionAlloc @@ -853,7 +881,8 @@ int maxalign; if (gots->section + gots->size - elffile->base >= GOTDistance) continue; } else { - if (elffile->base + elffile->basesize - gots->section >= GOTDistance) + if (elffile->base + elffile->basesize - gots->section >= + GOTDistance) continue; } elffile->got = gots->freeptr; @@ -861,20 +890,19 @@ int maxalign; gots->freeptr = gots->freeptr + elffile->gotsize; gots->nuses++; # ifdef ELFDEBUG - ELFDEBUG( "ELFCreateGOT: GOT address %lx in shared GOT, nuses %d\n", - elffile->got, gots->nuses ); + ELFDEBUG("ELFCreateGOT: GOT address %lx in shared GOT, nuses %d\n", + elffile->got, gots->nuses); # endif return TRUE; } gotsize += 16383 + sizeof(ELFGotRec); -# endif /*MergeSectionAlloc*/ +# endif /*MergeSectionAlloc */ if ((elffile->got = xf86loadermalloc(gotsize)) == NULL) { - ErrorF( "ELFCreateGOT() Unable to allocate memory!!!!\n" ); + ErrorF("ELFCreateGOT() Unable to allocate memory!!!!\n"); return FALSE; } - # ifdef MergeSectionAlloc if (elffile->got > elffile->base) { if (elffile->got + elffile->gotsize - elffile->base >= GOTDistance) @@ -890,7 +918,7 @@ int maxalign; elffile->basesize += 8 + elffile->gotsize; elffile->base = xf86loaderrealloc(elffile->base, elffile->basesize); if (elffile->base == NULL) { - ErrorF( "ELFCreateGOT() Unable to reallocate memory!!!!\n" ); + ErrorF("ELFCreateGOT() Unable to reallocate memory!!!!\n"); return FALSE; } # if defined(linux) && defined(__ia64__) || defined(__OpenBSD__) @@ -898,29 +926,36 @@ int maxalign; unsigned long page_size = getpagesize(); unsigned long round; - round = (unsigned long)elffile->base & (page_size-1); - mprotect(elffile->base - round, (elffile->basesize+round+page_size-1) & ~(page_size-1), - PROT_READ|PROT_WRITE|PROT_EXEC); + round = (unsigned long)elffile->base & (page_size - 1); + mprotect(elffile->base - round, + (elffile->basesize + round + page_size - + 1) & ~(page_size - 1), + PROT_READ | PROT_WRITE | PROT_EXEC); } # endif # else { int oldbasesize = elffile->basesize; + elffile->basesize += 8 + elffile->gotsize; MMAP_ALIGN(elffile->basesize); - elffile->base = mremap(elffile->base,oldbasesize, - elffile->basesize,MREMAP_MAYMOVE); + elffile->base = mremap(elffile->base, oldbasesize, + elffile->basesize, MREMAP_MAYMOVE); if (elffile->base == NULL) { - ErrorF( "ELFCreateGOT() Unable to remap memory!!!!\n" ); + ErrorF("ELFCreateGOT() Unable to remap memory!!!!\n"); return FALSE; } } # endif - elffile->baseptr = ((long)elffile->base + (maxalign - 1)) & ~(maxalign - 1); - elffile->got = (unsigned char *)((long)(elffile->base + elffile->basesize - elffile->gotsize) & ~7); + elffile->baseptr = + ((long)elffile->base + (maxalign - 1)) & ~(maxalign - 1); + elffile->got = + (unsigned char + *)((long)(elffile->base + elffile->basesize - + elffile->gotsize) & ~7); } else { - gots = (ELFGotPtr)elffile->got; + gots = (ELFGotPtr) elffile->got; elffile->got = gots->section; gots->size = gotsize - sizeof(ELFGotRec) + 1; gots->nuses = 1; @@ -929,28 +964,26 @@ int maxalign; ELFSharedGOTs = gots; elffile->shared_got = gots; # ifdef ELFDEBUG - ELFDEBUG( "ELFCreateGOT: Created a shareable GOT with size %d\n", gots->size); + ELFDEBUG("ELFCreateGOT: Created a shareable GOT with size %d\n", + gots->size); # endif } -# endif/*MergeSectionAlloc*/ +# endif /*MergeSectionAlloc */ # ifdef ELFDEBUG - ELFDEBUG( "ELFCreateGOT: GOT address %lx\n", elffile->got ); + ELFDEBUG("ELFCreateGOT: GOT address %lx\n", elffile->got); # endif return TRUE; } -#endif /* defined(__alpha__) || defined(__ia64__)*/ +#endif /* defined(__alpha__) || defined(__ia64__) */ #if defined(__ia64__) /* * Manage OPD Entries */ static void -ElfAddOPD(elffile,index,l) -ELFModulePtr elffile; -int index; -LOOKUP *l; +ElfAddOPD(ELFModulePtr elffile, int index, LOOKUP *l) { ELFOpdPtr opdent; @@ -961,37 +994,37 @@ LOOKUP *l; } if ((opdent = xf86loadermalloc(sizeof(ELFOpdRec))) == NULL) { - ErrorF( "ElfAddOPD() Unable to allocate memory!!!!\n" ); + ErrorF("ElfAddOPD() Unable to allocate memory!!!!\n"); return; } - # ifdef ELFDEBUG - ELFDEBUG("OPD Entry %d added with offset %x\n",index,elffile->gotsize); -# endif - opdent->l=l; - opdent->index=index; - opdent->offset=elffile->gotsize; - opdent->next=elffile->opd_entries; - elffile->opd_entries=opdent; - elffile->gotsize+=16; - return ; + ELFDEBUG("OPD Entry %d added with offset %x\n", index, elffile->gotsize); +# endif + opdent->l = l; + opdent->index = index; + opdent->offset = elffile->gotsize; + opdent->next = elffile->opd_entries; + elffile->opd_entries = opdent; + elffile->gotsize += 16; + return; } static void -ELFCreateOPD(elffile) -ELFModulePtr elffile; +ELFCreateOPD(ELFModulePtr elffile) { ELFOpdPtr opdent; if (elffile->got == NULL) - ErrorF( "ELFCreateOPD() Unallocated GOT!!!!\n" ); + ErrorF("ELFCreateOPD() Unallocated GOT!!!!\n"); for (opdent = elffile->opd_entries; opdent; opdent = opdent->next) { if (opdent->index != -1) continue; - ((unsigned long *)(elffile->got+opdent->offset))[0] = (long)opdent->l->offset; - ((unsigned long *)(elffile->got+opdent->offset))[1] = (long)elffile->got; - opdent->l->offset = (funcptr)(elffile->got+opdent->offset); + ((unsigned long *)(elffile->got + opdent->offset))[0] = + (long)opdent->l->offset; + ((unsigned long *)(elffile->got + opdent->offset))[1] = + (long)elffile->got; + opdent->l->offset = (funcptr) (elffile->got + opdent->offset); } } @@ -999,35 +1032,32 @@ ELFModulePtr elffile; * Manage PLT Entries */ static void -ElfAddPLT(elffile,rel) -ELFModulePtr elffile; -Elf_Rel_t *rel; +ElfAddPLT(ELFModulePtr elffile, Elf_Rel_t *rel) { ELFPltEntryPtr pltent; # ifdef ELFDEBUG { - Elf_Sym *sym; - - sym=(Elf_Sym *)&(elffile->symtab[ELF_R_SYM(rel->r_info)]); - if( sym->st_name) { - ELFDEBUG("ElfAddPLT: Adding PLT entry for %s\n", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - } - else - ErrorF("ElfAddPLT: Add PLT entry for section??\n"); + Elf_Sym *sym; + + sym = (Elf_Sym *) & (elffile->symtab[ELF_R_SYM(rel->r_info)]); + if (sym->st_name) { + ELFDEBUG("ElfAddPLT: Adding PLT entry for %s\n", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + } else + ErrorF("ElfAddPLT: Add PLT entry for section??\n"); } # endif if (rel->r_addend) ErrorF("ElfAddPLT: Add PLT entry with non-zero addend??\n"); - for (pltent=elffile->plt_entries;pltent;pltent=pltent->next) { - if ( ELF_R_SYM(pltent->rel->r_info) == ELF_R_SYM(rel->r_info) ) - break; + for (pltent = elffile->plt_entries; pltent; pltent = pltent->next) { + if (ELF_R_SYM(pltent->rel->r_info) == ELF_R_SYM(rel->r_info)) + break; } - if( pltent ) { + if (pltent) { # ifdef ELFDEBUG ELFDEBUG("Entry already present in PLT\n"); # endif @@ -1035,68 +1065,73 @@ Elf_Rel_t *rel; } if ((pltent = xf86loadermalloc(sizeof(ELFPltEntryRec))) == NULL) { - ErrorF( "ElfAddPLT() Unable to allocate memory!!!!\n" ); + ErrorF("ElfAddPLT() Unable to allocate memory!!!!\n"); return; } - # ifdef ELFDEBUG - ELFDEBUG("Entry added with offset %x\n",elffile->pltsize); -# endif - pltent->rel=rel; - pltent->offset=elffile->pltsize; - pltent->gotoffset=elffile->gotsize; - pltent->next=elffile->plt_entries; - elffile->plt_entries=pltent; - elffile->pltsize+=32; - elffile->gotsize+=16; - return ; + ELFDEBUG("Entry added with offset %x\n", elffile->pltsize); +# endif + pltent->rel = rel; + pltent->offset = elffile->pltsize; + pltent->gotoffset = elffile->gotsize; + pltent->next = elffile->plt_entries; + elffile->plt_entries = pltent; + elffile->pltsize += 32; + elffile->gotsize += 16; + return; } static void -ELFCreatePLT(elffile) -ELFModulePtr elffile; +ELFCreatePLT(ELFModulePtr elffile) { # ifdef ELFDEBUG - ELFDEBUG( "ELFCreatePLT: %x entries in the PLT\n", elffile->pltsize/8 ); + ELFDEBUG("ELFCreatePLT: %x entries in the PLT\n", elffile->pltsize / 8); # endif - if( elffile->pltsize == 0 ) return; + if (elffile->pltsize == 0) + return; - if ((elffile->plt = ELFLoaderSectCalloc(elffile,32,elffile->pltsize)) == NULL) { - ErrorF( "ELFCreatePLT() Unable to allocate memory!!!!\n" ); + if ((elffile->plt = + ELFLoaderSectCalloc(elffile, 32, elffile->pltsize)) == NULL) { + ErrorF("ELFCreatePLT() Unable to allocate memory!!!!\n"); return; } - elffile->sections[elffile->pltndx].sh_size=elffile->pltsize; + elffile->sections[elffile->pltndx].sh_size = elffile->pltsize; # ifdef ELFDEBUG - ELFDEBUG( "ELFCreatePLT: PLT address %lx\n", elffile->plt ); + ELFDEBUG("ELFCreatePLT: PLT address %lx\n", elffile->plt); # endif return; } static void -IA64InstallReloc(data128, slot, opnd, value) -unsigned long *data128; -int slot; -enum ia64_operand opnd; -long value; +IA64InstallReloc(unsigned long *data128, int slot, enum ia64_operand opnd, + long value) { unsigned long data = 0; # ifdef ELFDEBUG - ELFDEBUG( "\nIA64InstallReloc %p %d %d %016lx\n", data128, slot, opnd, value); - ELFDEBUG( "Before [%016lx%016lx]\n", data128[1], data128[0]); + ELFDEBUG("\nIA64InstallReloc %p %d %d %016lx\n", data128, slot, opnd, + value); + ELFDEBUG("Before [%016lx%016lx]\n", data128[1], data128[0]); # endif switch (slot) { - case 0: data = *data128; break; - case 1: memcpy(&data, (char *)data128 + 5, 8); break; - case 2: memcpy(&data, (char *)data128 + 10, 6); break; - default: FatalError("Unexpected slot in IA64InstallReloc()\n"); + case 0: + data = *data128; + break; + case 1: + memcpy(&data, (char *)data128 + 5, 8); + break; + case 2: + memcpy(&data, (char *)data128 + 10, 6); + break; + default: + FatalError("Unexpected slot in IA64InstallReloc()\n"); } switch (opnd) { case IA64_OPND_IMM22: data &= ~(0x3fff9fc0000UL << slot); - data |= (value & 0x7f) << (18 + slot); /* [13:19] + 5 + slot */ + data |= (value & 0x7f) << (18 + slot); /* [13:19] + 5 + slot */ data |= (value & 0xff80) << (25 + slot); /* [27:35] + 5 + slot */ data |= (value & 0x1f0000) << (11 + slot); /* [22:26] + 5 + slot */ data |= (value & 0x200000) << (20 + slot); /* [36:36] + 5 + slot */ @@ -1110,18 +1145,44 @@ long value; if (value << 39 >> 39 != value || (value & 0xf)) ErrorF("Relocation %016lx truncated to fit into TGT25C\n", value); break; +#ifdef IA64_LDX_OPTIMIZATION + case IA64_OPND_LDXMOV: + /* + * Convert "ld8 t2=[t1]" to "mov t2=t1" which is really "add t2=0,t1" + * Mask all but the r3,r1,qp fields, + * then OR in the ALU opcode = 8 into the opcode field [40:37] + * + * Mask for the r3,r1,qp bit fields [26:20][12:6][5:0] = 0x7f01fff, + * This mask negated only within the 41 bit wide instruction and + * shifted left by 5 for the bundle template is 0x3FFF01FC0000 + * + * opcode field [40:37] with a value of 8 is 0x10000000000 + * shifted left by 5 for the bundle template is 0x200000000000 + * + */ + data &= ~(0x3FFF01FC0000 << slot); + data |= (0x200000000000 << slot); + break; +#endif default: FatalError("Unhandled operand in IA64InstallReloc()\n"); } switch (slot) { - case 0: *data128 = data; break; - case 1: memcpy((char *)data128 + 5, &data, 8); break; - case 2: memcpy((char *)data128 + 10, &data, 6); break; - default: FatalError("Unexpected slot in IA64InstallReloc()\n"); + case 0: + *data128 = data; + break; + case 1: + memcpy((char *)data128 + 5, &data, 8); + break; + case 2: + memcpy((char *)data128 + 10, &data, 6); + break; + default: + FatalError("Unexpected slot in IA64InstallReloc()\n"); } ia64_flush_cache(data128); # ifdef ELFDEBUG - ELFDEBUG( "After [%016lx%016lx]\n", data128[1], data128[0]); + ELFDEBUG("After [%016lx%016lx]\n", data128[1], data128[0]); # endif } @@ -1135,13 +1196,11 @@ long value; */ static ELFRelocPtr -Elf_RelocateEntry(elffile, secn, rel, force) -ELFModulePtr elffile; -Elf_Word secn; -Elf_Rel_t *rel; -int force; +Elf_RelocateEntry(ELFModulePtr elffile, Elf_Word secn, Elf_Rel_t *rel, + int force) { unsigned char *secp = elffile->saddr[secn]; + #if !defined(__ia64__) unsigned int *dest32; /* address of the 32 bit place being modified */ #endif @@ -1150,13 +1209,14 @@ int force; #endif #if defined(__sparc__) unsigned char *dest8; /* address of the 8 bit place being modified */ + unsigned long *dest64; #endif -#if defined(__alpha__) +#if defined(__alpha__) unsigned int *dest32h; /* address of the high 32 bit place being modified */ unsigned long *dest64; unsigned short *dest16; #endif -#if defined(__x86_64__) +#if defined(__AMD64__) unsigned long *dest64; int *dest32s; #endif @@ -1167,28 +1227,29 @@ int force; Elf_Addr symval = 0; /* value of the indicated symbol */ #ifdef ELFDEBUG - ELFDEBUG( "%lx %d %d\n", rel->r_offset, - ELF_R_SYM(rel->r_info), ELF_R_TYPE(rel->r_info) ); + ELFDEBUG("%lx %d %d\n", (unsigned long)rel->r_offset, + ELF_R_SYM(rel->r_info), ELF_R_TYPE(rel->r_info)); # if defined(__powerpc__) || \ defined(__mc68000__) || \ defined(__alpha__) || \ defined(__sparc__) || \ defined(__ia64__) || \ - defined(__x86_64__) - ELFDEBUG( "%lx", rel->r_addend ); + defined(__AMD64__) + ELFDEBUG("%lx", rel->r_addend); # endif ELFDEBUG("\n"); #endif /*ELFDEBUG*/ #if defined(__alpha__) - if (ELF_R_SYM(rel->r_info) && ELF_R_TYPE(rel->r_info) != R_ALPHA_GPDISP) + if (ELF_R_SYM(rel->r_info) + && ELF_R_TYPE(rel->r_info) != R_ALPHA_GPDISP) #else - if (ELF_R_SYM(rel->r_info)) + if (ELF_R_SYM(rel->r_info)) #endif { symval = ElfGetSymbolValue(elffile, ELF_R_SYM(rel->r_info)); if (symval == 0) { if (force) { - symval = (Elf_Addr) &LoaderDefaultFunc; + symval = (Elf_Addr) & LoaderDefaultFunc; } else { #ifdef ELFDEBUG ELFDEBUG("***Unable to resolve symbol %s\n", @@ -1199,942 +1260,982 @@ int force; } } - switch( ELF_R_TYPE(rel->r_info) ) - { + switch (ELF_R_TYPE(rel->r_info)) { #if defined(i386) - case R_386_32: - dest32=(unsigned int *)(secp+rel->r_offset); + case R_386_32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_386_32\t"); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8lx\t", *dest32 ); + ELFDEBUG("R_386_32\t"); + ELFDEBUG("dest32=%p\t", (void *)dest32); + ELFDEBUG("*dest32=%8.8x\t", (unsigned int)*dest32); # endif - *dest32=symval+(*dest32); /* S + A */ + *dest32 = symval + (*dest32); /* S + A */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8lx\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", (unsigned int)*dest32); # endif - break; - case R_386_PC32: - dest32=(unsigned int *)(secp+rel->r_offset); + break; + case R_386_PC32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_386_PC32 %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8lx\t", *dest32 ); + ELFDEBUG("R_386_PC32 %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%p\t", secp); + ELFDEBUG("symval=%lx\t", (unsigned long)symval); + ELFDEBUG("dest32=%p\t", (void *)dest32); + ELFDEBUG("*dest32=%8.8x\t", (unsigned int)*dest32); # endif - *dest32=symval+(*dest32)-(Elf_Addr)dest32; /* S + A - P */ + *dest32 = symval + (*dest32) - (Elf_Addr) dest32; /* S + A - P */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8lx\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", (unsigned int)*dest32); # endif - break; + break; #endif /* i386 */ -#if defined(__x86_64__) - case R_X86_64_32: - dest32=(unsigned int *)(secp+rel->r_offset ); +#if defined(__AMD64__) + case R_X86_64_32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_X86_32\t"); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8lx\t", *dest32 ); - ELFDEBUG( "r_addend=%lx\t", rel->r_addend); + ELFDEBUG("R_X86_32\t"); + ELFDEBUG("dest32=%x\t", dest32); + ELFDEBUG("*dest32=%8.8lx\t", *dest32); + ELFDEBUG("r_addend=%lx\t", rel->r_addend); # endif - *dest32=symval + rel->r_addend + (*dest32); /* S + A */ + *dest32 = symval + rel->r_addend + (*dest32); /* S + A */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8lx\n", *dest32 ); + ELFDEBUG("*dest32=%8.8lx\n", *dest32); # endif - break; - case R_X86_64_32S: - dest32s=(int *)(secp+rel->r_offset); + break; + case R_X86_64_32S: + dest32s = (int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_X86_64_32\t"); - ELFDEBUG( "dest32s=%x\t", dest32s ); - ELFDEBUG( "*dest32s=%8.8lx\t", *dest32s ); - ELFDEBUG( "r_addend=%lx\t", rel->r_addend); + ELFDEBUG("R_X86_64_32\t"); + ELFDEBUG("dest32s=%x\t", dest32s); + ELFDEBUG("*dest32s=%8.8lx\t", *dest32s); + ELFDEBUG("r_addend=%lx\t", rel->r_addend); # endif - *dest32s=symval + rel->r_addend + (*dest32s); /* S + A */ + *dest32s = symval + rel->r_addend + (*dest32s); /* S + A */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32s=%8.8lx\n", *dest32s ); + ELFDEBUG("*dest32s=%8.8lx\n", *dest32s); # endif - break; - case R_X86_64_PC32: - dest32=(unsigned int *)(secp+rel->r_offset); + break; + case R_X86_64_PC32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_X86_64_PC32 %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8lx\t", *dest32 ); - ELFDEBUG( "r_addend=%lx\t", rel->r_addend); + ELFDEBUG("R_X86_64_PC32 %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest32=%x\t", dest32); + ELFDEBUG("*dest32=%8.8lx\t", *dest32); + ELFDEBUG("r_addend=%lx\t", rel->r_addend); # endif - *dest32 = symval + rel->r_addend + (*dest32)-(Elf_Addr)dest32; /* S + A - P */ + *dest32 = symval + rel->r_addend + (*dest32) - (Elf_Addr) dest32; /* S + A - P */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8lx\n", *dest32 ); + ELFDEBUG("*dest32=%8.8lx\n", *dest32); # endif - break; - case R_X86_64_64: - dest64=(unsigned long *)(secp+rel->r_offset); + break; + case R_X86_64_64: + dest64 = (unsigned long *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_x86_64_64\t"); - ELFDEBUG( "dest64=%x\t", dest64 ); - ELFDEBUG( "*dest64=%8.8lx\t", *dest64 ); - ELFDEBUG( "r_addend=%lx\t", rel->r_addend); + ELFDEBUG("R_AMD64_64\t"); + ELFDEBUG("dest64=%x\t", dest64); + ELFDEBUG("*dest64=%8.8lx\t", *dest64); + ELFDEBUG("r_addend=%lx\t", rel->r_addend); # endif - *dest64=symval + rel->r_addend + (*dest64); /* S + A */ + *dest64 = symval + rel->r_addend + (*dest64); /* S + A */ # ifdef ELFDEBUG - ELFDEBUG( "*dest64=%8.8lx\n", *dest64 ); + ELFDEBUG("*dest64=%8.8lx\n", *dest64); # endif - break; -#endif /* __x86_64__ */ + break; +#endif /* __AMD64__ */ #if defined(__alpha__) - case R_ALPHA_NONE: - case R_ALPHA_LITUSE: - break; - - case R_ALPHA_REFQUAD: - dest64=(unsigned long *)(secp+rel->r_offset); - symval=ElfGetSymbolValue(elffile, - ELF_R_SYM(rel->r_info)); -# ifdef ELFDEBUG - ELFDEBUG( "R_ALPHA_REFQUAD\t"); - ELFDEBUG( "dest64=%lx\t", dest64 ); - ELFDEBUG( "*dest64=%8.8lx\t", *dest64 ); -# endif - *dest64=symval+rel->r_addend+(*dest64); /* S + A + P */ -# ifdef ELFDEBUG - ELFDEBUG( "*dest64=%8.8lx\n", *dest64 ); -# endif - break; - - case R_ALPHA_GPREL32: - { - dest64=(unsigned long *)(secp+rel->r_offset); - dest32=(unsigned int *)dest64; - -# ifdef ELFDEBUG - ELFDEBUG( "R_ALPHA_GPREL32 %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest32=%lx\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); + case R_ALPHA_NONE: + case R_ALPHA_LITUSE: + break; + + case R_ALPHA_REFQUAD: + dest64 = (unsigned long *)(secp + rel->r_offset); + symval = ElfGetSymbolValue(elffile, ELF_R_SYM(rel->r_info)); +# ifdef ELFDEBUG + ELFDEBUG("R_ALPHA_REFQUAD\t"); + ELFDEBUG("dest64=%lx\t", dest64); + ELFDEBUG("*dest64=%8.8lx\t", *dest64); +# endif + *dest64 = symval + rel->r_addend + (*dest64); /* S + A + P */ +# ifdef ELFDEBUG + ELFDEBUG("*dest64=%8.8lx\n", *dest64); +# endif + break; + + case R_ALPHA_GPREL32: + { + dest64 = (unsigned long *)(secp + rel->r_offset); + dest32 = (unsigned int *)dest64; + +# ifdef ELFDEBUG + ELFDEBUG("R_ALPHA_GPREL32 %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest32=%lx\t", dest32); + ELFDEBUG("*dest32=%8.8x\t", *dest32); # endif symval += rel->r_addend; - symval = ((unsigned char *)symval)-((unsigned char *)elffile->got); + symval = ((unsigned char *)symval) - + ((unsigned char *)elffile->got); # ifdef ELFDEBUG - ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG("symval=%lx\t", symval); # endif - if( (symval&0xffffffff00000000) != 0x0000000000000000 && - (symval&0xffffffff00000000) != 0xffffffff00000000 ) { + if ((symval & 0xffffffff00000000) != 0x0000000000000000 && + (symval & 0xffffffff00000000) != 0xffffffff00000000) { FatalError("R_ALPHA_GPREL32 symval-got is too large for %s\n", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info))); + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); } - *dest32=symval; + *dest32 = symval; # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%x\n", *dest32 ); + ELFDEBUG("*dest32=%x\n", *dest32); # endif break; - } + } - case R_ALPHA_GPRELLOW: - { - dest64=(unsigned long *)(secp+rel->r_offset); - dest16=(unsigned short *)dest64; + case R_ALPHA_GPRELLOW: + { + dest64 = (unsigned long *)(secp + rel->r_offset); + dest16 = (unsigned short *)dest64; symval += rel->r_addend; - symval = ((unsigned char *)symval)-((unsigned char *)elffile->got); + symval = ((unsigned char *)symval) - + ((unsigned char *)elffile->got); - *dest16=symval; + *dest16 = symval; break; - } + } - case R_ALPHA_GPRELHIGH: - { - dest64=(unsigned long *)(secp+rel->r_offset); - dest16=(unsigned short *)dest64; + case R_ALPHA_GPRELHIGH: + { + dest64 = (unsigned long *)(secp + rel->r_offset); + dest16 = (unsigned short *)dest64; symval += rel->r_addend; - symval = ((unsigned char *)symval)-((unsigned char *)elffile->got); + symval = ((unsigned char *)symval) - + ((unsigned char *)elffile->got); symval = ((long)symval >> 16) + ((symval >> 15) & 1); - if( (long)symval > 0x7fff || (long)symval < -(long)0x8000 ) { - FatalError("R_ALPHA_GPRELHIGH symval-got is too large for %s:%lx\n", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)),symval); + if ((long)symval > 0x7fff || (long)symval < -(long)0x8000) { + FatalError + ("R_ALPHA_GPRELHIGH symval-got is too large for %s:%lx\n", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info)), + symval); } - *dest16=symval; + *dest16 = symval; break; - } + } - case R_ALPHA_LITERAL: - { + case R_ALPHA_LITERAL: + { ELFGotEntryPtr gotent; - dest32=(unsigned int *)(secp+rel->r_offset); + + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_ALPHA_LITERAL %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest32=%lx\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); + ELFDEBUG("R_ALPHA_LITERAL %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest32=%lx\t", dest32); + ELFDEBUG("*dest32=%8.8x\t", *dest32); # endif - 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; + 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; } /* Set the address in the GOT */ - if( gotent ) { - *(unsigned long *)(elffile->got+gotent->offset) = - symval+rel->r_addend; + if (gotent) { + *(unsigned long *)(elffile->got + gotent->offset) = + symval + rel->r_addend; # ifdef ELFDEBUG ELFDEBUG("Setting gotent[%x]=%lx\t", - gotent->offset, symval+rel->r_addend); + gotent->offset, symval + rel->r_addend); # endif if ((gotent->offset & 0xffff0000) != 0) FatalError("\nR_ALPHA_LITERAL offset %x too large\n", gotent->offset); - (*dest32)|=(gotent->offset); /* The address part is always 0 */ - } - else { + (*dest32) |= (gotent->offset); /* The address part is always 0 */ + } else { unsigned long val; - + /* S + A - P >> 2 */ - val=((symval+(rel->r_addend)-(Elf_Addr)dest32)); + val = ((symval + (rel->r_addend) - (Elf_Addr) dest32)); # ifdef ELFDEBUG - ELFDEBUG("S+A-P=%x\t",val); + ELFDEBUG("S+A-P=%x\t", val); # endif - if( (val & 0xffff0000) != 0xffff0000 && - (val & 0xffff0000) != 0x00000000 ) { + if ((val & 0xffff0000) != 0xffff0000 && + (val & 0xffff0000) != 0x00000000) { ErrorF("\nR_ALPHA_LITERAL offset %x too large\n", val); - break; + break; } val &= 0x0000ffff; - (*dest32)|=(val); /* The address part is always 0 */ + (*dest32) |= (val); /* The address part is always 0 */ } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif break; - } - - case R_ALPHA_GPDISP: - { + } + + case R_ALPHA_GPDISP: + { long offset; - dest32h=(unsigned int *)(secp+rel->r_offset); - dest32=(unsigned int *)((secp+rel->r_offset)+rel->r_addend); + dest32h = (unsigned int *)(secp + rel->r_offset); + dest32 = (unsigned int *)((secp + rel->r_offset) + rel->r_addend); # ifdef ELFDEBUG - ELFDEBUG( "R_ALPHA_GPDISP %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "got=%lx\t", elffile->got ); - ELFDEBUG( "dest32=%lx\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); - ELFDEBUG( "dest32h=%lx\t", dest32h ); - ELFDEBUG( "*dest32h=%8.8x\t", *dest32h ); + ELFDEBUG("R_ALPHA_GPDISP %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("got=%lx\t", elffile->got); + ELFDEBUG("dest32=%lx\t", dest32); + ELFDEBUG("*dest32=%8.8x\t", *dest32); + ELFDEBUG("dest32h=%lx\t", dest32h); + ELFDEBUG("*dest32h=%8.8x\t", *dest32h); # endif if ((*dest32h >> 26) != 9 || (*dest32 >> 26) != 8) { - ErrorF( "***Bad instructions in relocating %s\n", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + ErrorF("***Bad instructions in relocating %s\n", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); } symval = (*dest32h & 0xffff) << 16 | (*dest32 & 0xffff); symval = (symval ^ 0x80008000) - 0x80008000; - - offset = ((unsigned char *)elffile->got - (unsigned char *)dest32h); + + offset = ((unsigned char *)elffile->got - + (unsigned char *)dest32h); # ifdef ELFDEBUG - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "got-dest32=%lx\t", offset ); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("got-dest32=%lx\t", offset); # endif - if( (offset >= 0x7fff8000L) || (offset < -0x80000000L) ) { - FatalError( "Offset overflow for R_ALPHA_GPDISP\n"); + if ((offset >= 0x7fff8000L) || (offset < -0x80000000L)) { + FatalError("Offset overflow for R_ALPHA_GPDISP\n"); } symval += (unsigned long)offset; # ifdef ELFDEBUG - ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG("symval=%lx\t", symval); +# endif + *dest32 = (*dest32 & 0xffff0000) | (symval & 0xffff); + *dest32h = (*dest32h & 0xffff0000) | + (((symval >> 16) + ((symval >> 15) & 1)) & 0xffff); +# ifdef ELFDEBUG + ELFDEBUG("*dest32=%8.8x\t", *dest32); + ELFDEBUG("*dest32h=%8.8x\n", *dest32h); # endif - *dest32=(*dest32&0xffff0000) | (symval&0xffff); - *dest32h=(*dest32h&0xffff0000)| - (((symval>>16)+((symval>>15)&1))&0xffff); + break; + } + + case R_ALPHA_HINT: + dest32 = (unsigned int *)((secp + rel->r_offset) + rel->r_addend); # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); - ELFDEBUG( "*dest32h=%8.8x\n", *dest32h ); + ELFDEBUG("R_ALPHA_HINT %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest32=%lx\t", dest32); + ELFDEBUG("*dest32=%8.8x\t", *dest32); # endif - break; - } - - case R_ALPHA_HINT: - dest32=(unsigned int *)((secp+rel->r_offset)+rel->r_addend); + # ifdef ELFDEBUG - ELFDEBUG( "R_ALPHA_HINT %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest32=%lx\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); + ELFDEBUG("symval=%lx\t", symval); # endif + symval -= (Elf_Addr) (((unsigned char *)dest32) + 4); + if (symval % 4) { + ErrorF("R_ALPHA_HINT bad alignment of offset\n"); + } + symval = symval >> 2; # ifdef ELFDEBUG - ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG("symval=%lx\t", symval); # endif - symval -= (Elf_Addr)(((unsigned char *)dest32)+4); - if (symval % 4 ) { - ErrorF( "R_ALPHA_HINT bad alignment of offset\n"); - } - symval=symval>>2; + if (symval & 0xffff8000) { # ifdef ELFDEBUG - ELFDEBUG( "symval=%lx\t", symval ); + ELFDEBUG("R_ALPHA_HINT symval too large\n"); # endif + } + + *dest32 = (*dest32 & ~0x3fff) | (symval & 0x3fff); - if( symval & 0xffff8000 ) { # ifdef ELFDEBUG - ELFDEBUG("R_ALPHA_HINT symval too large\n" ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif + break; + + case R_ALPHA_GPREL16: + { + dest64 = (unsigned long *)(secp + rel->r_offset); + dest16 = (unsigned short *)dest64; + + symval += rel->r_addend; + symval = ((unsigned char *)symval) - + ((unsigned char *)elffile->got); + if ((long)symval > 0x7fff || (long)symval < -(long)0x8000) { + FatalError + ("R_ALPHA_GPREL16 symval-got is too large for %s:%lx\n", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info)), + symval); } - *dest32 = (*dest32&~0x3fff) | (symval&0x3fff); - -# ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); -# endif - break; - - case R_ALPHA_GPREL16: - { - dest64=(unsigned long *)(secp+rel->r_offset); - dest16=(unsigned short *)dest64; - - symval += rel->r_addend; - symval = ((unsigned char *)symval)-((unsigned char *)elffile->got); - if( (long)symval > 0x7fff || - (long)symval < -(long)0x8000 ) { - FatalError("R_ALPHA_GPREL16 symval-got is too large for %s:%lx\n", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)),symval); - } - - *dest16=symval; - break; - } - + *dest16 = symval; + break; + } + #endif /* alpha */ #if defined(__mc68000__) - case R_68K_32: - dest32=(unsigned int *)(secp+rel->r_offset); + case R_68K_32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_68K_32\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_68K_32\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned long val; - /* S + A */ - val=symval+(rel->r_addend); + { + unsigned long val; + + /* S + A */ + val = symval + (rel->r_addend); # ifdef ELFDEBUG - ELFDEBUG("S+A=%x\t",val); + ELFDEBUG("S+A=%x\t", val); # endif - *dest32=val; /* S + A */ - } + *dest32 = val; /* S + A */ + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_68K_PC32: - dest32=(unsigned int *)(secp+rel->r_offset); + break; + case R_68K_PC32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_68K_PC32\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_68K_PC32\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned long val; - /* S + A - P */ - val=symval+(rel->r_addend); - val-=*dest32; + { + unsigned long val; + + /* S + A - P */ + val = symval + (rel->r_addend); + val -= *dest32; # ifdef ELFDEBUG - ELFDEBUG("S+A=%x\t",val); - ELFDEBUG("S+A-P=%x\t",val+(*dest32)-(Elf_Addr)dest32); + ELFDEBUG("S+A=%x\t", val); + ELFDEBUG("S+A-P=%x\t", val + (*dest32) - (Elf_Addr) dest32); # endif - *dest32=val+(*dest32)-(Elf_Addr)dest32; /* S + A - P */ - } + *dest32 = val + (*dest32) - (Elf_Addr) dest32; /* S + A - P */ + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; + break; #endif /* __mc68000__ */ #if defined(__powerpc__) # if defined(PowerMAX_OS) - case R_PPC_DISP24: /* 11 */ - dest32=(unsigned long *)(secp+rel->r_offset); + case R_PPC_DISP24: /* 11 */ + dest32 = (unsigned long *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_DISP24 %s\t", ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); + ELFDEBUG("R_PPC_DISP24 %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("dest32=%x\t", dest32); + ELFDEBUG("*dest32=%8.8x\t", *dest32); # endif - { - unsigned long val; - - /* S + A - P >> 2 */ - val=((symval+(rel->r_addend)-(Elf_Addr)dest32)); + { + unsigned long val; + + /* S + A - P >> 2 */ + val = ((symval + (rel->r_addend) - (Elf_Addr) dest32)); # ifdef ELFDEBUG - ELFDEBUG("S+A-P=%x\t",val); + ELFDEBUG("S+A-P=%x\t", val); # endif - val = val>>2; - if( (val & 0x3f000000) != 0x3f000000 && - (val & 0x3f000000) != 0x00000000 ) { + val = val >> 2; + if ((val & 0x3f000000) != 0x3f000000 && + (val & 0x3f000000) != 0x00000000) { # ifdef ELFDEBUG - ELFDEBUG("R_PPC_DISP24 offset %x too large\n", val<<2); + ELFDEBUG("R_PPC_DISP24 offset %x too large\n", val << 2); # endif - symval = ElfGetPltAddr(elffile,ELF_R_SYM(rel->r_info)); - val=((symval+(rel->r_addend)-(Elf_Addr)dest32)); + symval = ElfGetPltAddr(elffile, ELF_R_SYM(rel->r_info)); + val = ((symval + (rel->r_addend) - (Elf_Addr) dest32)); # ifdef ELFDEBUG - ELFDEBUG("PLT offset is %x\n", val); + ELFDEBUG("PLT offset is %x\n", val); # endif - val=val>>2; - if( (val & 0x3f000000) != 0x3f000000 && - (val & 0x3f000000) != 0x00000000 ) - FatalError("R_PPC_DISP24 PLT offset %x too large\n", val<<2); - } - val &= 0x00ffffff; - (*dest32)|=(val<<2); /* The address part is always 0 */ - ppc_flush_icache(dest32); + val = val >> 2; + if ((val & 0x3f000000) != 0x3f000000 && + (val & 0x3f000000) != 0x00000000) + FatalError("R_PPC_DISP24 PLT offset %x too large\n", + val << 2); } + val &= 0x00ffffff; + (*dest32) |= (val << 2); /* The address part is always 0 */ + ppc_flush_icache(dest32); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_16HU: /* 31 */ - dest16=(unsigned short *)(secp+rel->r_offset); + break; + case R_PPC_16HU: /* 31 */ + dest16 = (unsigned short *)(secp + rel->r_offset); # ifdef ELFDEBUG - dest32=(unsigned long *)(dest16-1); + dest32 = (unsigned long *)(dest16 - 1); # endif # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_16HU\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest16=%x\t", dest16 ); - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_16HU\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest16=%x\t", dest16); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned short val; - /* S + A */ - val=((symval+(rel->r_addend))&0xffff0000)>>16; + { + unsigned short val; + + /* S + A */ + val = ((symval + (rel->r_addend)) & 0xffff0000) >> 16; # ifdef ELFDEBUG - ELFDEBUG("uhi16(S+A)=%x\t",val); + ELFDEBUG("uhi16(S+A)=%x\t", val); # endif - *dest16=val; /* S + A */ - ppc_flush_icache(dest16); - } + *dest16 = val; /* S + A */ + ppc_flush_icache(dest16); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_32: /* 32 */ - dest32=(unsigned long *)(secp+rel->r_offset); + break; + case R_PPC_32: /* 32 */ + dest32 = (unsigned long *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_32\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_32\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned long val; - /* S + A */ - val=symval+(rel->r_addend); + { + unsigned long val; + + /* S + A */ + val = symval + (rel->r_addend); # ifdef ELFDEBUG - ELFDEBUG("S+A=%x\t",val); + ELFDEBUG("S+A=%x\t", val); # endif - *dest32=val; /* S + A */ - ppc_flush_icache(dest32); - } + *dest32 = val; /* S + A */ + ppc_flush_icache(dest32); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_32UA: /* 33 */ - dest32=(unsigned long *)(secp+rel->r_offset); + break; + case R_PPC_32UA: /* 33 */ + dest32 = (unsigned long *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_32UA\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_32UA\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned long val; - unsigned char *dest8 = (unsigned char *)dest32; - /* S + A */ - val=symval+(rel->r_addend); + { + unsigned long val; + unsigned char *dest8 = (unsigned char *)dest32; + + /* S + A */ + val = symval + (rel->r_addend); # ifdef ELFDEBUG - ELFDEBUG("S+A=%x\t",val); + ELFDEBUG("S+A=%x\t", val); # endif - *dest8++=(val&0xff000000)>>24; - *dest8++=(val&0x00ff0000)>>16; - *dest8++=(val&0x0000ff00)>> 8; - *dest8++=(val&0x000000ff); - ppc_flush_icache(dest32); - } + *dest8++ = (val & 0xff000000) >> 24; + *dest8++ = (val & 0x00ff0000) >> 16; + *dest8++ = (val & 0x0000ff00) >> 8; + *dest8++ = (val & 0x000000ff); + ppc_flush_icache(dest32); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_16H: /* 34 */ - dest16=(unsigned short *)(secp+rel->r_offset); + break; + case R_PPC_16H: /* 34 */ + dest16 = (unsigned short *)(secp + rel->r_offset); # ifdef ELFDEBUG - dest32=(unsigned long *)(dest16-1); + dest32 = (unsigned long *)(dest16 - 1); # endif # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_16H\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symbol=%s\t", ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest16=%x\t", dest16 ); - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_16H\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symbol=%s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest16=%x\t", dest16); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned short val; - unsigned short loval; - /* S + A */ - val=((symval+(rel->r_addend))&0xffff0000)>>16; - loval=(symval+(rel->r_addend))&0xffff; - if( loval & 0x8000 ) { - /* - * This is hi16(), instead of uhi16(). Because of this, - * if the lo16() will produce a negative offset, then - * we have to increment this part of the address to get - * the correct final result. - */ - val++; - } + { + unsigned short val; + unsigned short loval; + + /* S + A */ + val = ((symval + (rel->r_addend)) & 0xffff0000) >> 16; + loval = (symval + (rel->r_addend)) & 0xffff; + if (loval & 0x8000) { + /* + * This is hi16(), instead of uhi16(). Because of this, + * if the lo16() will produce a negative offset, then + * we have to increment this part of the address to get + * the correct final result. + */ + val++; + } # ifdef ELFDEBUG - ELFDEBUG("hi16(S+A)=%x\t",val); + ELFDEBUG("hi16(S+A)=%x\t", val); # endif - *dest16=val; /* S + A */ - ppc_flush_icache(dest16); - } + *dest16 = val; /* S + A */ + ppc_flush_icache(dest16); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_16L: /* 35 */ - dest16=(unsigned short *)(secp+rel->r_offset); + break; + case R_PPC_16L: /* 35 */ + dest16 = (unsigned short *)(secp + rel->r_offset); # ifdef ELFDEBUG - dest32=(unsigned long *)(dest16-1); + dest32 = (unsigned long *)(dest16 - 1); # endif # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_16L\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest16=%x\t", dest16 ); - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_16L\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest16=%x\t", dest16); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned short val; - /* S + A */ - val=(symval+(rel->r_addend))&0xffff; + { + unsigned short val; + + /* S + A */ + val = (symval + (rel->r_addend)) & 0xffff; # ifdef ELFDEBUG - ELFDEBUG("lo16(S+A)=%x\t",val); + ELFDEBUG("lo16(S+A)=%x\t", val); # endif - *dest16=val; /* S + A */ - ppc_flush_icache(dest16); - } + *dest16 = val; /* S + A */ + ppc_flush_icache(dest16); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; + break; # else /* PowerMAX_OS */ - /* Linux PPC */ - case R_PPC_ADDR32: /* 1 */ - dest32=(unsigned int *)(secp+rel->r_offset); - symval=ElfGetSymbolValue(elffile,ELF_R_SYM(rel->r_info)); + /* Linux PPC */ + case R_PPC_ADDR32: /* 1 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + symval = ElfGetSymbolValue(elffile, ELF_R_SYM(rel->r_info)); # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_ADDR32\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_ADDR32\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned long val; - /* S + A */ - val=symval+(rel->r_addend); + { + unsigned long val; + + /* S + A */ + val = symval + (rel->r_addend); # ifdef ELFDEBUG - ELFDEBUG("S+A=%x\t",val); + ELFDEBUG("S+A=%x\t", val); # endif - *dest32=val; /* S + A */ - ppc_flush_icache(dest32); - } + *dest32 = val; /* S + A */ + ppc_flush_icache(dest32); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_ADDR16_LO: /* 4 */ - dest16=(unsigned short *)(secp+rel->r_offset); + break; + case R_PPC_ADDR16_LO: /* 4 */ + dest16 = (unsigned short *)(secp + rel->r_offset); # ifdef ELFDEBUG - dest32=(unsigned long *)(dest16-1); + dest32 = (unsigned long *)(dest16 - 1); # endif # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_ADDR16_LO\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest16=%x\t", dest16 ); - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); + ELFDEBUG("R_PPC_ADDR16_LO\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest16=%x\t", dest16); + ELFDEBUG("*dest16=%8.8x\t", *dest16); # endif - { - unsigned short val; - /* S + A */ - val=(symval+(rel->r_addend))&0xffff; + { + unsigned short val; + + /* S + A */ + val = (symval + (rel->r_addend)) & 0xffff; # ifdef ELFDEBUG - ELFDEBUG("lo16(S+A)=%x\t",val); + ELFDEBUG("lo16(S+A)=%x\t", val); # endif - *dest16=val; /* S + A */ - ppc_flush_icache(dest16); - } + *dest16 = val; /* S + A */ + ppc_flush_icache(dest16); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_ADDR16_HA: /* 6 */ - dest16=(unsigned short *)(secp+rel->r_offset); + break; + case R_PPC_ADDR16_HA: /* 6 */ + dest16 = (unsigned short *)(secp + rel->r_offset); # ifdef ELFDEBUG - dest32=(unsigned long *)(dest16-1); + dest32 = (unsigned long *)(dest16 - 1); # endif # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_ADDR16_HA\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest16=%x\t", dest16 ); - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); + ELFDEBUG("R_PPC_ADDR16_HA\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest16=%x\t", dest16); + ELFDEBUG("*dest16=%8.8x\t", *dest16); # endif - { - unsigned short val; - unsigned short loval; - /* S + A */ - val=((symval+(rel->r_addend))&0xffff0000)>>16; - loval=(symval+(rel->r_addend))&0xffff; - if( loval & 0x8000 ) { - /* - * This is hi16(), instead of uhi16(). Because of this, - * if the lo16() will produce a negative offset, then - * we have to increment this part of the address to get - * the correct final result. - */ - val++; - } + { + unsigned short val; + unsigned short loval; + + /* S + A */ + val = ((symval + (rel->r_addend)) & 0xffff0000) >> 16; + loval = (symval + (rel->r_addend)) & 0xffff; + if (loval & 0x8000) { + /* + * This is hi16(), instead of uhi16(). Because of this, + * if the lo16() will produce a negative offset, then + * we have to increment this part of the address to get + * the correct final result. + */ + val++; + } # ifdef ELFDEBUG - ELFDEBUG("hi16(S+A)=%x\t",val); + ELFDEBUG("hi16(S+A)=%x\t", val); # endif - *dest16=val; /* S + A */ - ppc_flush_icache(dest16); - } + *dest16 = val; /* S + A */ + ppc_flush_icache(dest16); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest16=%8.8x\t", *dest16 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest16=%8.8x\t", *dest16); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_REL24: /* 10 */ - dest32=(unsigned int *)(secp+rel->r_offset); + break; + case R_PPC_REL24: /* 10 */ + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_REL24 %s\t", ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\t", *dest32 ); + ELFDEBUG("R_PPC_REL24 %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("dest32=%x\t", dest32); + ELFDEBUG("*dest32=%8.8x\t", *dest32); # endif - { - unsigned long val; - - /* S + A - P >> 2 */ - val=((symval+(rel->r_addend)-(Elf_Addr)dest32)); + { + unsigned long val; + + /* S + A - P >> 2 */ + val = ((symval + (rel->r_addend) - (Elf_Addr) dest32)); # ifdef ELFDEBUG - ELFDEBUG("S+A-P=%x\t",val); + ELFDEBUG("S+A-P=%x\t", val); # endif - val = val>>2; - if( (val & 0x3f000000) != 0x3f000000 && - (val & 0x3f000000) != 0x00000000 ) { + val = val >> 2; + if ((val & 0x3f000000) != 0x3f000000 && + (val & 0x3f000000) != 0x00000000) { # ifdef ELFDEBUG - ELFDEBUG("R_PPC_REL24 offset %x too large\n", val<<2); + ELFDEBUG("R_PPC_REL24 offset %x too large\n", val << 2); # endif - symval = ElfGetPltAddr(elffile,ELF_R_SYM(rel->r_info)); - val=((symval+(rel->r_addend)-(Elf_Addr)dest32)); + symval = ElfGetPltAddr(elffile, ELF_R_SYM(rel->r_info)); + val = ((symval + (rel->r_addend) - (Elf_Addr) dest32)); # ifdef ELFDEBUG - ELFDEBUG("PLT offset is %x\n", val); + ELFDEBUG("PLT offset is %x\n", val); # endif - val=val>>2; - if( (val & 0x3f000000) != 0x3f000000 && - (val & 0x3f000000) != 0x00000000 ) - FatalError("R_PPC_REL24 PLT offset %x too large\n", val<<2); - } - val &= 0x00ffffff; - (*dest32)|=(val<<2); /* The address part is always 0 */ - ppc_flush_icache(dest32); + val = val >> 2; + if ((val & 0x3f000000) != 0x3f000000 && + (val & 0x3f000000) != 0x00000000) + FatalError("R_PPC_REL24 PLT offset %x too large\n", + val << 2); } + val &= 0x00ffffff; + (*dest32) |= (val << 2); /* The address part is always 0 */ + ppc_flush_icache(dest32); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; - case R_PPC_REL32: /* 26 */ - dest32=(unsigned int *)(secp+rel->r_offset); + break; + case R_PPC_REL32: /* 26 */ + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_PPC_REL32\t" ); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%x\t", symval ); - ELFDEBUG( "r_addend=%x\t", rel->r_addend ); - ELFDEBUG( "dest32=%8.8x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("R_PPC_REL32\t"); + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%x\t", symval); + ELFDEBUG("r_addend=%x\t", rel->r_addend); + ELFDEBUG("dest32=%8.8x\t", dest32); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - { - unsigned long val; - /* S + A - P */ - val=symval+(rel->r_addend); - val-=*dest32; + { + unsigned long val; + + /* S + A - P */ + val = symval + (rel->r_addend); + val -= *dest32; # ifdef ELFDEBUG - ELFDEBUG("S+A=%x\t",val); - ELFDEBUG("S+A-P=%x\t",val+(*dest32)-(Elf_Addr)dest32); + ELFDEBUG("S+A=%x\t", val); + ELFDEBUG("S+A-P=%x\t", val + (*dest32) - (Elf_Addr) dest32); # endif - *dest32=val+(*dest32)-(Elf_Addr)dest32; /* S + A - P */ - ppc_flush_icache(dest32); - } + *dest32 = val + (*dest32) - (Elf_Addr) dest32; /* S + A - P */ + ppc_flush_icache(dest32); + } # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8x\n", *dest32 ); + ELFDEBUG("*dest32=%8.8x\n", *dest32); # endif - break; -# endif /* PowerMAX_OS */ + break; +# endif /* PowerMAX_OS */ #endif /* __powerpc__ */ #ifdef __sparc__ - case R_SPARC_NONE: /* 0 */ - break; + case R_SPARC_NONE: /* 0 */ + break; - case R_SPARC_8: /* 1 */ - dest8 = (unsigned char *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest8 = symval; - break; + case R_SPARC_8: /* 1 */ + dest8 = (unsigned char *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest8 = symval; + break; - case R_SPARC_16: /* 2 */ - dest16 = (unsigned short *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest16 = symval; - break; + case R_SPARC_16: /* 2 */ + dest16 = (unsigned short *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest16 = symval; + break; - case R_SPARC_32: /* 3 */ - case R_SPARC_GLOB_DAT: /* 20 */ - case R_SPARC_UA32: /* 23 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - symval += rel->r_addend; - ((unsigned char *)dest32)[0] = (unsigned char)(symval >> 24); - ((unsigned char *)dest32)[1] = (unsigned char)(symval >> 16); - ((unsigned char *)dest32)[2] = (unsigned char)(symval >> 8); - ((unsigned char *)dest32)[3] = (unsigned char)(symval ); - break; + case R_SPARC_32: /* 3 */ + case R_SPARC_UA32: /* 23 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + symval += rel->r_addend; + ((unsigned char *)dest32)[0] = (unsigned char)(symval >> 24); + ((unsigned char *)dest32)[1] = (unsigned char)(symval >> 16); + ((unsigned char *)dest32)[2] = (unsigned char)(symval >> 8); + ((unsigned char *)dest32)[3] = (unsigned char)(symval); + break; - case R_SPARC_DISP8: /* 4 */ - dest8 = (unsigned char *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest8 = (symval - (Elf32_Addr) dest8); - break; + case R_SPARC_GLOB_DAT: /* 20 */ + case R_SPARC_64: /* 32 */ + dest64 = (unsigned long *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest64 = symval; + break; - case R_SPARC_DISP16: /* 5 */ - dest16 = (unsigned short *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest16 = (symval - (Elf32_Addr) dest16); - break; + case R_SPARC_DISP8: /* 4 */ + dest8 = (unsigned char *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest8 = (symval - (Elf_Addr) dest8); + break; - case R_SPARC_DISP32: /* 6 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest32 = (symval - (Elf32_Addr) dest32); - break; + case R_SPARC_DISP16: /* 5 */ + dest16 = (unsigned short *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest16 = (symval - (Elf_Addr) dest16); + break; - case R_SPARC_WDISP30: /* 7 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest32 = ((*dest32 & 0xc0000000) | - ((symval - (Elf32_Addr) dest32) >> 2)); - break; + case R_SPARC_DISP32: /* 6 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest32 = (symval - (Elf_Addr) dest32); + break; - case R_SPARC_HI22: /* 9 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest32 = (*dest32 & 0xffc00000) | (symval >> 10); - break; + case R_SPARC_WDISP30: /* 7 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest32 = ((*dest32 & 0xc0000000) | + (((symval - (Elf_Addr) dest32) >> 2) & 0x3fffffff)); + break; - case R_SPARC_LO10: /* 12 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - symval += rel->r_addend; - *dest32 = (*dest32 & ~0x3ff) | (symval & 0x3ff); - break; + case R_SPARC_HI22: /* 9 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest32 = (*dest32 & 0xffc00000) | (symval >> 10); + break; - case R_SPARC_COPY: /* 19 */ - /* Fix your code... I'd rather dish out an error here - * so people will not link together PIC and non-PIC - * code into a final driver object file. - */ - ErrorF("Elf_RelocateEntry():" - " Copy relocs not supported on Sparc.\n"); - break; + case R_SPARC_LO10: /* 12 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + symval += rel->r_addend; + *dest32 = (*dest32 & ~0x3ff) | (symval & 0x3ff); + break; - case R_SPARC_JMP_SLOT: /* 21 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - /* Before we change it the PLT entry looks like: - * - * pltent: sethi %hi(rela_plt_offset), %g1 - * b,a PLT0 - * nop - * - * We change it into: - * - * pltent: sethi %hi(rela_plt_offset), %g1 - * sethi %hi(symval), %g1 - * jmp %g1 + %lo(symval), %g0 - */ - symval += rel->r_addend; - dest32[2] = 0x81c06000 | (symval & 0x3ff); - __asm __volatile("flush %0 + 0x8" : : "r" (dest32)); - dest32[1] = 0x03000000 | (symval >> 10); - __asm __volatile("flush %0 + 0x4" : : "r" (dest32)); - break; + case R_SPARC_COPY: /* 19 */ + /* Fix your code... I'd rather dish out an error here + * so people will not link together PIC and non-PIC + * code into a final driver object file. + */ + ErrorF("Elf_RelocateEntry():" + " Copy relocs not supported on Sparc.\n"); + break; - case R_SPARC_RELATIVE: /* 22 */ - dest32 = (unsigned int *)(secp + rel->r_offset); - *dest32 += (unsigned int)secp + rel->r_addend; - break; + case R_SPARC_JMP_SLOT: /* 21 */ + dest32 = (unsigned int *)(secp + rel->r_offset); + /* Before we change it the PLT entry looks like: + * + * pltent: sethi %hi(rela_plt_offset), %g1 + * b,a PLT0 + * nop + * + * We change it into: + * + * pltent: sethi %hi(rela_plt_offset), %g1 + * sethi %hi(symval), %g1 + * jmp %g1 + %lo(symval), %g0 + */ + symval += rel->r_addend; + dest32[2] = 0x81c06000 | (symval & 0x3ff); + __asm __volatile("flush %0 + 0x8"::"r"(dest32)); + + dest32[1] = 0x03000000 | (symval >> 10); + __asm __volatile("flush %0 + 0x4"::"r"(dest32)); + + break; + + case R_SPARC_RELATIVE: /* 22 */ + dest64 = (unsigned long *)(secp + rel->r_offset); + *dest64 = (unsigned long)secp + rel->r_addend; + break; #endif /*__sparc__*/ #ifdef __ia64__ - case R_IA64_NONE: - break; + case R_IA64_NONE: + break; - case R_IA64_LTOFF_FPTR22: - if (rel->r_addend) - FatalError("\nAddend for R_IA64_LTOFF_FPTR22 not supported\n"); + case R_IA64_LTOFF_FPTR22: + if (rel->r_addend) + FatalError("\nAddend for R_IA64_LTOFF_FPTR22 not supported\n"); # ifdef ELFDEBUG - ELFDEBUG( "opd=%016lx.%016lx\n", - ((long *)symval)[0], ((long *)symval)[1] ); + ELFDEBUG("opd=%016lx.%016lx\n", + ((long *)symval)[0], ((long *)symval)[1]); # endif - /* FALLTHROUGH */ - case R_IA64_LTOFF22: - { + /* FALLTHROUGH */ + case R_IA64_LTOFF22: +#ifndef IA64_LDX_OPTIMIZATION + case R_IA64_LTOFF22X: /* If not implementing LDXMOV optimization treat LTOFF22X as LTOFF22 */ +#endif + { ELFGotEntryPtr gotent; - dest128=(unsigned long *)(secp+(rel->r_offset&~3)); -# ifdef ELFDEBUG - ELFDEBUG( "%s %s\t", ELF_R_TYPE(rel->r_info) == R_IA64_LTOFF22 ? - "R_IA64_LTOFF22" : "R_IA64_LTOFF_FPTR22", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest128=%lx\t", dest128 ); - ELFDEBUG( "slot=%d\n", rel->r_offset & 3); - ELFDEBUG( "*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); -# endif - 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; + dest128 = (unsigned long *)(secp + (rel->r_offset & ~3)); +# ifdef ELFDEBUG + ELFDEBUG("%s %s\t", ELF_R_TYPE(rel->r_info) == R_IA64_LTOFF22 ? + "R_IA64_LTOFF22" : "R_IA64_LTOFF_FPTR22", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest128=%lx\t", dest128); + ELFDEBUG("slot=%d\n", rel->r_offset & 3); + ELFDEBUG("*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); +# endif + + 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; } /* Set the address in the GOT */ - if( gotent ) { - *(unsigned long *)(elffile->got+gotent->offset) = - symval+rel->r_addend; + if (gotent) { + *(unsigned long *)(elffile->got + gotent->offset) = + symval + rel->r_addend; # ifdef ELFDEBUG ELFDEBUG("Setting gotent[%x]=%lx\n", - gotent->offset, symval+rel->r_addend); + gotent->offset, symval + rel->r_addend); # endif if ((gotent->offset & 0xffe00000) != 0) FatalError("\nR_IA64_LTOFF22 offset %x too large\n", gotent->offset); - IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_IMM22, gotent->offset); - } - else + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_IMM22, + gotent->offset); + } else FatalError("\nCould not find GOT entry\n"); - } - break; + } + break; - case R_IA64_PCREL21B: - { + case R_IA64_PCREL21B: + { ELFPltEntryPtr pltent; - dest128=(unsigned long *)(secp+(rel->r_offset&~3)); + + dest128 = (unsigned long *)(secp + (rel->r_offset & ~3)); # ifdef ELFDEBUG - ELFDEBUG( "R_IA64_PCREL21B %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "opd=%lx.%lx\t", ((long *)symval)[0], ((long *)symval)[1]); - ELFDEBUG( "dest128=%lx\t", dest128 ); - ELFDEBUG( "slot=%d\n", rel->r_offset & 3); - ELFDEBUG( "*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); + ELFDEBUG("R_IA64_PCREL21B %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("opd=%lx.%lx\t", ((long *)symval)[0], + ((long *)symval)[1]); + ELFDEBUG("dest128=%lx\t", dest128); + ELFDEBUG("slot=%d\n", rel->r_offset & 3); + ELFDEBUG("*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); # endif if (rel->r_addend) FatalError("\nAddend for PCREL21B not supported\n"); if (((long *)symval)[1] == (long)elffile->got - && (((unsigned long)dest128 - ((unsigned long *)symval)[0]) + 0x2000000 < 0x4000000)) { + && (((unsigned long)dest128 - ((unsigned long *)symval)[0]) + + 0x2000000 < 0x4000000)) { /* We can save the travel through PLT */ IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_TGT25C, - ((unsigned long *)symval)[0] - (unsigned long)dest128); + ((unsigned long *)symval)[0] - + (unsigned long)dest128); break; } - for (pltent=elffile->plt_entries;pltent;pltent=pltent->next) { - if ( ELF_R_SYM(pltent->rel->r_info) == ELF_R_SYM(rel->r_info) && - pltent->rel->r_addend == rel->r_addend ) - break; + for (pltent = elffile->plt_entries; pltent; pltent = pltent->next) { + if (ELF_R_SYM(pltent->rel->r_info) == ELF_R_SYM(rel->r_info) + && pltent->rel->r_addend == rel->r_addend) + break; } /* Set the address in the PLT */ if (pltent == NULL) FatalError("\nCould not find PLT entry\n"); else { - unsigned long *p = (unsigned long *)(elffile->plt+pltent->offset); - unsigned long r = (unsigned long)symval - (unsigned long)elffile->got; + unsigned long *p = + (unsigned long *)(elffile->plt + pltent->offset); + unsigned long r = + (unsigned long)symval - (unsigned long)elffile->got; if (r + 0x200000 >= 0x400000) { - /* Too far from gp to use the official function descriptor, - * so we have to make a local one. - */ - r = pltent->gotoffset; - memcpy(elffile->got+r, (char *)symval, 16); + /* Too far from gp to use the official function descriptor, + * so we have to make a local one. + */ + r = pltent->gotoffset; + memcpy(elffile->got + r, (char *)symval, 16); } /* [MMI] addl r15=NNN,r1;; ld8 r16=[r15],8; mov r14=r1;; */ @@ -2147,162 +2248,262 @@ int force; IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_TGT25C, (unsigned long)p - (unsigned long)dest128); } - } - break; + } + break; + + case R_IA64_FPTR64LSB: + dest64 = (unsigned long *)(secp + rel->r_offset); +# ifdef ELFDEBUG + ELFDEBUG("R_IA64_FPTR64LSB %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest64=%lx\t", dest64); + ELFDEBUG("opd=%016lx.%016lx\n", ((long *)symval)[0], + ((long *)symval)[1]); +# endif + + if (rel->r_addend) + FatalError("\nAddend not supported for R_IA64_FPTR64LSB\n"); + *dest64 = symval; + ia64_flush_cache(dest64); + break; + + case R_IA64_DIR64LSB: + dest64 = (unsigned long *)(secp + rel->r_offset); +# ifdef ELFDEBUG + ELFDEBUG("R_IA64_DIR64LSB %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest64=%lx\n", dest64); +# endif + *dest64 = symval + rel->r_addend; + ia64_flush_cache(dest64); + break; + + case R_IA64_PCREL64LSB: + dest64 = (unsigned long *)(secp + rel->r_offset); +#ifdef ELFDEBUG + ELFDEBUG("R_IA64_PCREL64LSB %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest64=%lx\n", dest64); +#endif + *dest64 = symval + rel->r_addend - (unsigned long)dest64; + break; + + case R_IA64_GPREL22: + dest128 = (unsigned long *)(secp + (rel->r_offset & ~3)); +# ifdef ELFDEBUG + ELFDEBUG("R_IA64_GPREL22 %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest128=%lx\t", dest128); + ELFDEBUG("slot=%d\n", rel->r_offset & 3); + ELFDEBUG("*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); +# endif + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_IMM22, + symval + rel->r_addend - (long)elffile->got); + break; + +#ifdef IA64_LDX_OPTIMIZATION + case R_IA64_LTOFF22X: + { + ELFGotEntryPtr gotent; + long gp_offset = symval + rel->r_addend - (long)elffile->got; + + dest128 = (unsigned long *)(secp + (rel->r_offset & ~3)); - case R_IA64_FPTR64LSB: - dest64=(unsigned long *)(secp+rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_IA64_FPTR64LSB %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest64=%lx\t", dest64 ); - ELFDEBUG( "opd=%016lx.%016lx\n", ((long *)symval)[0], ((long *)symval)[1] ); + ELFDEBUG("R_IA64_LTOFF22X %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest128=%lx\t", dest128); + ELFDEBUG("slot=%d\n", rel->r_offset & 3); # endif - if (rel->r_addend) - FatalError("\nAddend not supported for R_IA64_FPTR64LSB\n"); - *dest64 = symval; - ia64_flush_cache(dest64); - break; + if (gp_offset << 42 >> 42 != gp_offset) { + /* Offset is too large for LTOFF22X, + * fallback to using GOT lookup, e.g. LTOFF22. + * Note: LDXMOV will fail the same test and will be ignored. */ - case R_IA64_DIR64LSB: - dest64=(unsigned long *)(secp+rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_IA64_DIR64LSB %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest64=%lx\n", dest64 ); + ELFDEBUG("gp_offset=%ld too large, using GOT instead (LTOFF22)\n", gp_offset); # endif - *dest64 = symval + rel->r_addend; - ia64_flush_cache(dest64); - break; - case R_IA64_PCREL64LSB: - dest64=(unsigned long *)(secp+rel->r_offset); -#ifdef ELFDEBUG - ELFDEBUG( "R_IA64_PCREL64LSB %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest64=%lx\n", dest64 ); -#endif - *dest64 = symval + rel->r_addend - (unsigned long)dest64; - break; + 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; + } - case R_IA64_GPREL22: - dest128=(unsigned long *)(secp+(rel->r_offset&~3)); + /* Set the address in the GOT */ + if (gotent) { + *(unsigned long *)(elffile->got + gotent->offset) = + symval + rel->r_addend; +# ifdef ELFDEBUG + ELFDEBUG("Setting gotent[%x]=%lx\n", gotent->offset, + symval + rel->r_addend); +# endif + if ((gotent->offset & 0xffe00000) != 0) + FatalError("\nR_IA64_LTOFF22 offset %x too large\n", + gotent->offset); + } else { + FatalError("\nCould not find GOT entry\n"); + } + gp_offset = gotent->offset; /* Use GOT lookup */ + } else { # ifdef ELFDEBUG - ELFDEBUG( "R_IA64_GPREL22 %s\t", - ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); - ELFDEBUG( "secp=%lx\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest128=%lx\t", dest128 ); - ELFDEBUG( "slot=%d\n", rel->r_offset & 3); - ELFDEBUG( "*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); + ELFDEBUG("using gp_offset=%ld (LTOFF22X)", gp_offset); # endif + } IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_IMM22, - symval + rel->r_addend - (long)elffile->got); - break; + gp_offset); + } + break; +#endif + + case R_IA64_LDXMOV: +# ifdef ELFDEBUG + ELFDEBUG("R_IA64_LDXMOV %s\t", + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); +# endif + +#ifdef IA64_LDX_OPTIMIZATION + { + long gp_offset = symval + rel->r_addend - (long)elffile->got; + + dest128 = (unsigned long *)(secp + (rel->r_offset & ~3)); + + if (gp_offset << 42 >> 42 != gp_offset) { + /* Offset is too large for LTOFF22X, ignore this relocation */ +# ifdef ELFDEBUG + ELFDEBUG("offset = %ld too large, ignoring\n", gp_offset); +# endif + } else { + +# ifdef ELFDEBUG + ELFDEBUG("secp=%lx\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest128=%lx\t", dest128); + ELFDEBUG("slot=%d\n", rel->r_offset & 3); + ELFDEBUG("offset=%ld\n", gp_offset); + ELFDEBUG("*dest128=[%016lx%016lx]\n", dest128[1], dest128[0]); +# endif + + IA64InstallReloc(dest128, rel->r_offset & 3, IA64_OPND_LDXMOV, + 0); + } + } +#endif + break; #endif /*__ia64__*/ #if defined(__arm__) - case R_ARM_ABS32: - dest32=(unsigned int *)(secp+rel->r_offset); + case R_ARM_ABS32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - ELFDEBUG( "R_ARM_ABS32\t"); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8lx\t", *dest32 ); + ELFDEBUG("R_ARM_ABS32\t"); + ELFDEBUG("dest32=%x\t", dest32); + ELFDEBUG("*dest32=%8.8lx\t", *dest32); # endif - *dest32=symval+(*dest32); /* S + A */ + *dest32 = symval + (*dest32); /* S + A */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8lx\n", *dest32 ); + ELFDEBUG("*dest32=%8.8lx\n", *dest32); # endif - break; + break; - case R_ARM_REL32: - dest32=(unsigned int *)(secp+rel->r_offset); + case R_ARM_REL32: + dest32 = (unsigned int *)(secp + rel->r_offset); # ifdef ELFDEBUG - { + { char *namestr; - ELFDEBUG( "R_ARM_REL32 %s\t", - namestr=ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) ); + + ELFDEBUG("R_ARM_REL32 %s\t", + namestr = + ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info))); xf86loaderfree(namestr); - ELFDEBUG( "secp=%x\t", secp ); - ELFDEBUG( "symval=%lx\t", symval ); - ELFDEBUG( "dest32=%x\t", dest32 ); - ELFDEBUG( "*dest32=%8.8lx\t", *dest32 ); - } + ELFDEBUG("secp=%x\t", secp); + ELFDEBUG("symval=%lx\t", symval); + ELFDEBUG("dest32=%x\t", dest32); + ELFDEBUG("*dest32=%8.8lx\t", *dest32); + } # endif - *dest32=symval+(*dest32)-(Elf_Addr)dest32; /* S + A - P */ + *dest32 = symval + (*dest32) - (Elf_Addr) dest32; /* S + A - P */ # ifdef ELFDEBUG - ELFDEBUG( "*dest32=%8.8lx\n", *dest32 ); + ELFDEBUG("*dest32=%8.8lx\n", *dest32); # endif - break; + break; - case R_ARM_PC24: - { + case R_ARM_PC24: + { unsigned long val; - dest32=(unsigned int *)(secp+rel->r_offset); + + dest32 = (unsigned int *)(secp + rel->r_offset); val = (*dest32 & 0x00ffffff) << 2; - val = symval - (unsigned long)dest32 + val; - val >>= 2; - *dest32 = (*dest32 & 0xff000000) | (val & 0x00ffffff); + val = symval - (unsigned long)dest32 + val; + val >>= 2; + *dest32 = (*dest32 & 0xff000000) | (val & 0x00ffffff); #ifdef NOTYET arm_flush_cache(dest32); #endif - } - break; + } + break; #endif /* (__arm__) */ - default: - ErrorF("Elf_RelocateEntry() Unsupported relocation type %d\n", - ELF_R_TYPE(rel->r_info)); - break; - } + default: + ErrorF("Elf_RelocateEntry() Unsupported relocation type %d\n", + (int)ELF_R_TYPE(rel->r_info)); + break; + } return 0; } static ELFRelocPtr ELFCollectRelocations(elffile, index) -ELFModulePtr elffile; -int index; /* The section to use as relocation data */ + ELFModulePtr elffile; + int index; /* The section to use as relocation data */ { - int i, numrel; - Elf_Shdr *sect=&(elffile->sections[index]); - Elf_Rel_t *rel=(Elf_Rel_t *)elffile->saddr[index]; - Elf_Sym *syms; + int i, numrel; + Elf_Shdr *sect = &(elffile->sections[index]); + Elf_Rel_t *rel = (Elf_Rel_t *) elffile->saddr[index]; ELFRelocPtr reloc_head = NULL; ELFRelocPtr tmp; - syms = (Elf_Sym *) elffile->saddr[elffile->symndx]; + numrel = sect->sh_size / sect->sh_entsize; - numrel=sect->sh_size/sect->sh_entsize; - - for(i=0; i<numrel; i++ ) { + for (i = 0; i < numrel; i++) { #if defined(__alpha__) - if( ELF_R_TYPE(rel[i].r_info) == R_ALPHA_LITERAL) { - ElfAddGOT(elffile,&rel[i]); - } + if (ELF_R_TYPE(rel[i].r_info) == R_ALPHA_LITERAL) { + ElfAddGOT(elffile, &rel[i]); + } #endif #if defined(__ia64__) if (ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF22 + || ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF22X || ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF_FPTR22) { - ElfAddGOT(elffile,&rel[i]); + ElfAddGOT(elffile, &rel[i]); } if (ELF_R_TYPE(rel[i].r_info) == R_IA64_PCREL21B) { - ElfAddPLT(elffile,&rel[i]); + ElfAddPLT(elffile, &rel[i]); } if (ELF_R_TYPE(rel[i].r_info) == R_IA64_LTOFF_FPTR22 || ELF_R_TYPE(rel[i].r_info) == R_IA64_FPTR64LSB) { - if (ELF_ST_BIND(syms[ELF_R_SYM(rel[i].r_info)].st_info) == STB_LOCAL) { + Elf_Sym *syms = (Elf_Sym *) elffile->saddr[elffile->symndx]; + + if (ELF_ST_BIND(syms[ELF_R_SYM(rel[i].r_info)].st_info) == + STB_LOCAL) { ElfAddOPD(elffile, ELF_R_SYM(rel[i].r_info), NULL); } } @@ -2322,110 +2523,109 @@ int index; /* The section to use as relocation data */ */ static LOOKUP * -ELF_GetSymbols(elffile, psecttable) -ELFModulePtr elffile; -unsigned short **psecttable; +ELF_GetSymbols(ELFModulePtr elffile, unsigned short **psecttable) { - Elf_Sym *syms; - Elf_Shdr *sect; - int i, l, numsyms; - LOOKUP *lookup, *p; + Elf_Sym *syms; + Elf_Shdr *sect; + int i, l, numsyms; + LOOKUP *lookup, *p; ELFCommonPtr tmp; unsigned short *secttable; - syms=elffile->symtab; - sect=&(elffile->sections[elffile->symndx]); - numsyms=sect->sh_size/sect->sh_entsize; + syms = elffile->symtab; + sect = &(elffile->sections[elffile->symndx]); + numsyms = sect->sh_size / sect->sh_entsize; - if ((lookup = xf86loadermalloc((numsyms+1)*sizeof(LOOKUP))) == NULL) + if ((lookup = xf86loadermalloc((numsyms + 1) * sizeof(LOOKUP))) == NULL) return 0; - if ((secttable = xf86loadercalloc(sizeof(unsigned short),(numsyms+1))) == NULL) { + if ((secttable = + xf86loadercalloc(sizeof(unsigned short), (numsyms + 1))) == NULL) { xf86loaderfree(lookup); return 0; } *psecttable = secttable; - for(i=0,l=0; i<numsyms; i++) - { + for (i = 0, l = 0; i < numsyms; i++) { #ifdef ELFDEBUG - ELFDEBUG("value=%lx\tsize=%lx\tBIND=%x\tTYPE=%x\tndx=%x\t%s\n", - syms[i].st_value,syms[i].st_size, - ELF_ST_BIND(syms[i].st_info),ELF_ST_TYPE(syms[i].st_info), - syms[i].st_shndx,ElfGetString(elffile,syms[i].st_name) ); + ELFDEBUG("value=%lx\tsize=%lx\tBIND=%x\tTYPE=%x\tndx=%x\t%s\n", + (unsigned long)syms[i].st_value, + (unsigned long)syms[i].st_size, + ELF_ST_BIND(syms[i].st_info), ELF_ST_TYPE(syms[i].st_info), + syms[i].st_shndx, ElfGetString(elffile, syms[i].st_name)); #endif - if( ELF_ST_BIND(syms[i].st_info) == STB_LOCAL ) - /* Don't add static symbols to the symbol table */ - continue; + if (ELF_ST_BIND(syms[i].st_info) == STB_LOCAL) + /* Don't add static symbols to the symbol table */ + continue; - switch( ELF_ST_TYPE(syms[i].st_info) ) - { - case STT_OBJECT: - case STT_FUNC: - case STT_SECTION: - case STT_NOTYPE: - switch(syms[i].st_shndx) - { - case SHN_ABS: - ErrorF("ELF_GetSymbols() Don't know how to handle SHN_ABS\n" ); - break; - case SHN_COMMON: + switch (ELF_ST_TYPE(syms[i].st_info)) { + case STT_OBJECT: + case STT_FUNC: + case STT_SECTION: + case STT_NOTYPE: + switch (syms[i].st_shndx) { + case SHN_ABS: + ErrorF("ELF_GetSymbols() Don't know how to handle SHN_ABS\n"); + break; + case SHN_COMMON: #ifdef ELFDEBUG - ELFDEBUG("Adding COMMON space for %s\n", - ElfGetString(elffile,syms[i].st_name) ); -#endif - if (!LoaderHashFind(ElfGetString(elffile, - syms[i].st_name))) { - tmp = ElfAddCOMMON(&(syms[i])); - if (tmp) { - tmp->next = listCOMMON; - listCOMMON = tmp; - } - } - break; - case SHN_UNDEF: - /* - * UNDEF will get resolved later, so the value - * doesn't really matter here. - */ - /* since we don't know the value don't advertise the symbol */ - break; - default: - lookup[l].symName=xf86loaderstrdup(ElfGetString(elffile,syms[i].st_name)); - lookup[l].offset=(funcptr)syms[i].st_value; - secttable[l] = syms[i].st_shndx; + ELFDEBUG("Adding COMMON space for %s\n", + ElfGetString(elffile, syms[i].st_name)); +#endif + if (!LoaderHashFind(ElfGetString(elffile, syms[i].st_name))) { + tmp = ElfAddCOMMON(&(syms[i])); + if (tmp) { + tmp->next = listCOMMON; + listCOMMON = tmp; + } + } + break; + case SHN_UNDEF: + /* + * UNDEF will get resolved later, so the value + * doesn't really matter here. + */ + /* since we don't know the value don't advertise the symbol */ + break; + default: + lookup[l].symName = + xf86loaderstrdup(ElfGetString + (elffile, syms[i].st_name)); + lookup[l].offset = (funcptr) syms[i].st_value; + secttable[l] = syms[i].st_shndx; #ifdef ELFDEBUG - ELFDEBUG("Adding symbol %lx(%d) %s\n", - lookup[l].offset, secttable[l], lookup[l].symName ); + ELFDEBUG("Adding symbol %lx(%d) %s\n", + (unsigned long)lookup[l].offset, secttable[l], + lookup[l].symName); #endif #ifdef __ia64__ - if ( ELF_ST_TYPE(syms[i].st_info) == STT_FUNC ) { - ElfAddOPD(elffile, -1, &lookup[l]); - } + if (ELF_ST_TYPE(syms[i].st_info) == STT_FUNC) { + ElfAddOPD(elffile, -1, &lookup[l]); + } #endif - l++; - break; - } - break; - case STT_FILE: - case STT_LOPROC: - case STT_HIPROC: - /* Skip this type */ + l++; + break; + } + break; + case STT_FILE: + case STT_LOPROC: + case STT_HIPROC: + /* Skip this type */ #ifdef ELFDEBUG - ELFDEBUG("Skipping TYPE %d %s\n", - ELF_ST_TYPE(syms[i].st_info), - ElfGetString(elffile,syms[i].st_name)); + ELFDEBUG("Skipping TYPE %d %s\n", + ELF_ST_TYPE(syms[i].st_info), + ElfGetString(elffile, syms[i].st_name)); #endif - break; - default: - ErrorF("ELF_GetSymbols(): Unepected symbol type %d\n", - ELF_ST_TYPE(syms[i].st_info) ); - break; - } + break; + default: + ErrorF("ELF_GetSymbols(): Unepected symbol type %d\n", + ELF_ST_TYPE(syms[i].st_info)); + break; } + } - lookup[l].symName=NULL; /* Terminate the list */ + lookup[l].symName = NULL; /* Terminate the list */ /* * Remove the ELF symbols that will show up in every object module. @@ -2436,8 +2636,10 @@ unsigned short **psecttable; || !strcmp(lookup[i].symName, ".bss") || !strcmp(lookup[i].symName, ".comment") || !strcmp(lookup[i].symName, ".note") - ) { - memmove(&(lookup[i]), &(lookup[i+1]), (l-- - i) * sizeof (LOOKUP)); + ) { + memmove(&(lookup[i]), &(lookup[i + 1]), (l - i) * sizeof(LOOKUP)); + memmove(&(secttable[i]), &(secttable[i + 1]), + (l-- - i) * sizeof(unsigned short)); } } return lookup; @@ -2466,105 +2668,106 @@ unsigned short **psecttable; * Do the work required to load each section into memory. */ static void -ELFCollectSections(elffile,pass,totalsize,maxalign) -ELFModulePtr elffile; -int pass; -int *totalsize; -int *maxalign; +ELFCollectSections(ELFModulePtr elffile, int pass, int *totalsize, + int *maxalign) { - int i; + int i; int j; + /* * Find and identify all of the Sections */ j = elffile->lsectidx; - for( i=1; i<elffile->numsh; i++) { + for (i = 1; i < elffile->numsh; i++) { int flags = 0; char *name = ElfGetSectionName(elffile, elffile->sections[i].sh_name); #if defined(__alpha__) || defined(__ia64__) - if (!strcmp(name,".got") /*Isn't there a more generic way to do this?*/ + 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") + || !strcmp(name, ".plt") || !strcmp(name, ".IA_64.unwind_info") # endif - ) continue; + ) + continue; #endif switch (SecType(i)) { case SHT_STRTAB: - if (!strcmp(name,".shstrtab")) /* already loaded */ + if (!strcmp(name, ".shstrtab")) /* already loaded */ continue; - if (!strcmp(name,".stabstr")) /* ignore debug info */ + if (!strcmp(name, ".stabstr")) /* ignore debug info */ continue; case SHT_SYMTAB: - if (pass) continue; + if (pass) + continue; flags = LOADED_SECTION; flags |= RELOC_SECTION; break; case SHT_REL: case SHT_RELA: - if (pass) continue; - if (! (SecFlags(SecInfo(i)) & SHF_ALLOC)) - continue; + if (pass) + continue; + if (!(SecFlags(SecInfo(i)) & SHF_ALLOC)) + continue; #ifdef __ia64__ if (SecType(SecInfo(i)) == SHT_IA_64_UNWIND) - continue; + continue; #endif - flags = LOADED_SECTION; - flags |= RELOC_SECTION; - break; + flags = LOADED_SECTION; + flags |= RELOC_SECTION; + break; case SHT_PROGBITS: flags |= LOADED_SECTION; case SHT_NOBITS: - if (! (elffile->sections[i].sh_flags & SHF_ALLOC)) + if (!(elffile->sections[i].sh_flags & SHF_ALLOC)) continue; AdjustSize(i); break; default: #ifdef ELFDEBUG if (pass) - ELFDEBUG("ELF: Not loading %s\n",name); + ELFDEBUG("ELF: Not loading %s\n", name); #endif continue; } - + elffile->lsection = xf86loaderrealloc(elffile->lsection, - (j + 1) * sizeof (LoadSection)); + (j + 1) * sizeof(LoadSection)); if (!(flags & RELOC_SECTION)) { - if (flags & LOADED_SECTION) { - elffile->lsection[j].saddr /* sect. contains data */ - = ELFLoaderSectToMem(elffile,SecAlign(i),SecOffset(i), - SecSize(i), name); + if (flags & LOADED_SECTION) { + elffile->lsection[j].saddr /* sect. contains data */ + = ELFLoaderSectToMem(elffile, SecAlign(i), + SecOffset(i), SecSize(i), name); } else { - if( SecSize(i) ) - elffile->lsection[j].saddr - = ELFLoaderSectCalloc(elffile,SecAlign(i), - SecSize(i)); - else + if (SecSize(i)) + elffile->lsection[j].saddr + = ELFLoaderSectCalloc(elffile, SecAlign(i), + SecSize(i)); + else elffile->lsection[j].saddr = NULL; } } else { elffile->lsection[j].saddr = - (Elf_Sym *)_LoaderFileToMem(elffile->fd,SecOffset(i), - SecSize(i),name); + (Elf_Sym *) _LoaderFileToMem(elffile->fd, SecOffset(i), + SecSize(i), name); } - elffile->saddr[i]=elffile->lsection[j].saddr; + elffile->saddr[i] = elffile->lsection[j].saddr; #ifdef ELFDEBUG - ELFDEBUG("%s starts at %lx size: %lx\n", - name, elffile->saddr[i], SecSize(i)); -#endif - elffile->lsection[j].name= name; + ELFDEBUG("%s starts at %p size: %lx\n", + name, elffile->saddr[i], (unsigned long)SecSize(i)); +#endif + elffile->lsection[j].name = name; elffile->lsection[j].ndx = i; - elffile->lsection[j].size=SecSize(i); - elffile->lsection[j].flags=flags; + elffile->lsection[j].size = SecSize(i); + elffile->lsection[j].flags = flags; switch (SecType(i)) { #ifdef __OpenBSD__ case SHT_PROGBITS: - mprotect(elffile->lsection[j].saddr, SecSize(i), - PROT_READ|PROT_WRITE|PROT_EXEC); + mprotect(elffile->lsection[j].saddr, SecSize(i), + PROT_READ | PROT_WRITE | PROT_EXEC); break; #endif case SHT_SYMTAB: - elffile->symtab = (Elf_Sym *)elffile->saddr[i]; + elffile->symtab = (Elf_Sym *) elffile->saddr[i]; elffile->symndx = i; break; case SHT_STRTAB: @@ -2583,20 +2786,17 @@ int *maxalign; * Public API for the ELF implementation of the loader. */ void * -ELFLoadModule(modrec, elffd, ppLookup) -loaderPtr modrec; -int elffd; -LOOKUP **ppLookup; +ELFLoadModule(loaderPtr modrec, int elffd, LOOKUP **ppLookup) { ELFModulePtr elffile; - Elf_Ehdr *header; - ELFRelocPtr elf_reloc, tail; - void *v; + Elf_Ehdr *header; + ELFRelocPtr elf_reloc, tail; + void *v; LDRModulePtr elfmod; - int totalsize, maxalign, i; + int totalsize, maxalign, i; unsigned short *secttable; - LOOKUP *pLookup; - + LOOKUP *pLookup; + ldrCommons = 0; nCommons = 0; @@ -2604,72 +2804,77 @@ LOOKUP **ppLookup; ELFDEBUG("Loading %s %s\n", modrec->name, modrec->cname); #endif if ((elffile = xf86loadercalloc(1, sizeof(ELFModuleRec))) == NULL) { - ErrorF( "Unable to allocate ELFModuleRec\n" ); + ErrorF("Unable to allocate ELFModuleRec\n"); return NULL; } - elffile->handle=modrec->handle; - elffile->module=modrec->module; - elffile->fd=elffd; - v=elffile->funcs=modrec->funcs; + elffile->handle = modrec->handle; + elffile->module = modrec->module; + elffile->fd = elffd; + v = elffile->funcs = modrec->funcs; /* * Get the ELF header */ - elffile->header= - (Elf_Ehdr*)_LoaderFileToMem(elffd, 0, sizeof(Elf_Ehdr), "header"); - header=(Elf_Ehdr *)elffile->header; + elffile->header = + (Elf_Ehdr *) _LoaderFileToMem(elffd, 0, sizeof(Elf_Ehdr), + "header"); + header = (Elf_Ehdr *) elffile->header; /* * Get the section table */ - elffile->numsh=header->e_shnum; - elffile->secsize=(header->e_shentsize * header->e_shnum); - elffile->sections= - (Elf_Shdr *)_LoaderFileToMem(elffd, header->e_shoff, elffile->secsize, - "sections"); + elffile->numsh = header->e_shnum; + elffile->secsize = (header->e_shentsize * header->e_shnum); + elffile->sections = + (Elf_Shdr *) _LoaderFileToMem(elffd, header->e_shoff, + elffile->secsize, "sections"); #if defined(__alpha__) || defined(__ia64__) /* * Need to allocate space for the .got section which will be * fabricated later */ - elffile->gotndx=header->e_shnum; + elffile->gotndx = header->e_shnum; header->e_shnum++; # if defined(__ia64__) - elffile->pltndx=header->e_shnum; + elffile->pltndx = header->e_shnum; header->e_shnum++; # endif - elffile->numsh=header->e_shnum; - elffile->secsize=(header->e_shentsize*header->e_shnum); - elffile->sections=xf86loaderrealloc(elffile->sections,elffile->secsize); -#endif /*defined(__alpha__) || defined(__ia64__)*/ - elffile->saddr=xf86loadercalloc(elffile->numsh, sizeof(unsigned char *)); + elffile->numsh = header->e_shnum; + elffile->secsize = (header->e_shentsize * header->e_shnum); + elffile->sections = + xf86loaderrealloc(elffile->sections, elffile->secsize); +#endif /*defined(__alpha__) || defined(__ia64__) */ + elffile->saddr = + xf86loadercalloc(elffile->numsh, sizeof(unsigned char *)); #if defined(__alpha__) || defined(__ia64__) /* * Manually fill in the entry for the .got section so ELFCollectSections() * will be able to find it. */ - elffile->sections[elffile->gotndx].sh_name=SecSize(header->e_shstrndx)+1; - 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; - elffile->sections[elffile->gotndx].sh_addralign=8; + elffile->sections[elffile->gotndx].sh_name = + SecSize(header->e_shstrndx) + 1; + 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; + elffile->sections[elffile->gotndx].sh_addralign = 8; /* Add room to copy ".got", and maintain alignment */ - SecSize(header->e_shstrndx)+=8; + SecSize(header->e_shstrndx) += 8; #endif #if defined(__ia64__) /* * Manually fill in the entry for the .plt section so ELFCollectSections() * will be able to find it. */ - elffile->sections[elffile->pltndx].sh_name=SecSize(header->e_shstrndx)+1; - elffile->sections[elffile->pltndx].sh_type=SHT_PROGBITS; - elffile->sections[elffile->pltndx].sh_flags=SHF_EXECINSTR|SHF_ALLOC; - elffile->sections[elffile->pltndx].sh_size=0; - elffile->sections[elffile->pltndx].sh_addralign=32; + elffile->sections[elffile->pltndx].sh_name = + SecSize(header->e_shstrndx) + 1; + elffile->sections[elffile->pltndx].sh_type = SHT_PROGBITS; + elffile->sections[elffile->pltndx].sh_flags = SHF_EXECINSTR | SHF_ALLOC; + elffile->sections[elffile->pltndx].sh_size = 0; + elffile->sections[elffile->pltndx].sh_addralign = 32; /* Add room to copy ".plt", and maintain alignment */ - SecSize(header->e_shstrndx)+=32; + SecSize(header->e_shstrndx) += 32; #endif /* @@ -2677,22 +2882,22 @@ LOOKUP **ppLookup; */ elffile->shstrsize = SecSize(header->e_shstrndx); elffile->shstraddr = - _LoaderFileToMem(elffd, SecOffset(header->e_shstrndx), - SecSize(header->e_shstrndx), ".shstrtab"); + _LoaderFileToMem(elffd, SecOffset(header->e_shstrndx), + SecSize(header->e_shstrndx), ".shstrtab"); elffile->shstrndx = header->e_shstrndx; #if defined(__alpha__) || defined(__ia64__) /* * Add the string for the .got section */ - strcpy((char*)(elffile->shstraddr+elffile->sections[elffile->gotndx].sh_name), - ".got"); + strcpy((char *)(elffile->shstraddr + + elffile->sections[elffile->gotndx].sh_name), ".got"); #endif #if defined(__ia64__) /* * Add the string for the .plt section */ - strcpy((char*)(elffile->shstraddr+elffile->sections[elffile->pltndx].sh_name), - ".plt"); + strcpy((char *)(elffile->shstraddr + + elffile->sections[elffile->pltndx].sh_name), ".plt"); #endif /* @@ -2701,12 +2906,12 @@ LOOKUP **ppLookup; totalsize = 0; maxalign = 0; ELFCollectSections(elffile, 0, &totalsize, &maxalign); - if( elffile->straddr == NULL || elffile->strsize == 0 ) { + if (elffile->straddr == NULL || elffile->strsize == 0) { #if 0 ErrorF("No symbols found in this module\n"); #endif ELFUnloadModule(elffile); - return (void *) -1L; + return (void *)-1L; } /* * add symbols @@ -2724,10 +2929,9 @@ LOOKUP **ppLookup; default: continue; } - elf_reloc = ELFCollectRelocations(elffile,elffile->lsection[i].ndx); + elf_reloc = ELFCollectRelocations(elffile, elffile->lsection[i].ndx); if (elf_reloc) { - for (tail = elf_reloc; tail->next; tail = tail->next) - ; + for (tail = elf_reloc; tail->next; tail = tail->next) ; tail->next = _LoaderGetRelocations(v)->elf_reloc; _LoaderGetRelocations(v)->elf_reloc = elf_reloc; } @@ -2747,11 +2951,11 @@ LOOKUP **ppLookup; #ifdef MergeSectionAlloc elffile->basesize = totalsize + maxalign; - + # if !defined(DoMMAPedMerge) elffile->base = xf86loadermalloc(elffile->basesize); if (elffile->base == NULL) { - ErrorF( "Unable to allocate ELF sections\n" ); + ErrorF("Unable to allocate ELF sections\n"); return NULL; } # if defined(linux) && defined(__ia64__) || defined(__OpenBSD__) @@ -2759,25 +2963,28 @@ LOOKUP **ppLookup; unsigned long page_size = getpagesize(); unsigned long round; - round = (unsigned long)elffile->base & (page_size-1); - mprotect(elffile->base - round, (elffile->basesize+round+page_size-1) & ~(page_size-1), - PROT_READ|PROT_WRITE|PROT_EXEC); + round = (unsigned long)elffile->base & (page_size - 1); + mprotect(elffile->base - round, + (elffile->basesize + round + page_size - 1) & ~(page_size - + 1), + PROT_READ | PROT_WRITE | PROT_EXEC); } # endif -# else +# else MMAP_ALIGN(elffile->basesize); - elffile->base = mmap( 0,elffile->basesize,MMAP_PROT,MMAP_FLAGS,-1, - (off_t)0); + elffile->base = mmap(0, elffile->basesize, MMAP_PROT, MMAP_FLAGS, -1, + (off_t) 0); if (elffile->base == NULL) { - ErrorF( "Unable to mmap ELF sections\n" ); + ErrorF("Unable to mmap ELF sections\n"); return NULL; } # endif - elffile->baseptr = ((long)elffile->base + (maxalign - 1)) & ~(maxalign - 1); + elffile->baseptr = + ((long)elffile->base + (maxalign - 1)) & ~(maxalign - 1); #endif #if defined(__alpha__) || defined(__ia64__) - if (! ELFCreateGOT(elffile, maxalign)) + if (!ELFCreateGOT(elffile, maxalign)) return NULL; #endif #if defined(__ia64__) @@ -2788,10 +2995,12 @@ LOOKUP **ppLookup; for (i = 0; pLookup[i].symName; i++) if (secttable[i]) { - pLookup[i].offset = (funcptr)((long)pLookup[i].offset + (long)elffile->saddr[secttable[i]]); + pLookup[i].offset = + (funcptr) ((long)pLookup[i].offset + + (long)elffile->saddr[secttable[i]]); #ifdef ELFDEBUG - ELFDEBUG("Finalizing symbol %lx %s\n", - pLookup[i].offset, pLookup[i].symName); + ELFDEBUG("Finalizing symbol %p %s\n", + (void *)pLookup[i].offset, pLookup[i].symName); #endif } xf86loaderfree(secttable); @@ -2800,24 +3009,25 @@ LOOKUP **ppLookup; ELFCreateOPD(elffile); #endif - if (! ElfCreateCOMMON(elffile, *ppLookup)) + if (!ElfCreateCOMMON(elffile, *ppLookup)) return NULL; /* Record info for gdb - if we can't allocate the loader record fail - silently (the user will find out soon enough that there's no VM left */ + * silently (the user will find out soon enough that there's no VM left */ if ((elfmod = xf86loadercalloc(1, sizeof(LDRModuleRec))) != NULL) { elfmod->name = strdup(modrec->name); elfmod->namelen = strlen(modrec->name); elfmod->version = 1; - for (i=0; i < elffile->lsectidx;i++) { + for (i = 0; i < elffile->lsectidx; i++) { char *name = elffile->lsection[i].name; - if (!strcmp(name,".text")) + + if (!strcmp(name, ".text")) elfmod->text = elffile->lsection[i].saddr; - else if (!strcmp(name,".data")) + else if (!strcmp(name, ".data")) elfmod->data = elffile->lsection[i].saddr; - else if (!strcmp(name,".rodata")) + else if (!strcmp(name, ".rodata")) elfmod->rodata = elffile->lsection[i].saddr; - else if (!strcmp(name,".bss")) + else if (!strcmp(name, ".bss")) elfmod->bss = elffile->lsection[i].saddr; } elfmod->next = ModList; @@ -2833,8 +3043,7 @@ LOOKUP **ppLookup; } void -ELFResolveSymbols(mod) -void *mod; +ELFResolveSymbols(void *mod) { ELFRelocPtr newlist, p, tmp; @@ -2842,10 +3051,12 @@ void *mod; * which we failed to relocate. Destroy the old list in the process. */ newlist = 0; - for (p = _LoaderGetRelocations(mod)->elf_reloc; p; ) { + for (p = _LoaderGetRelocations(mod)->elf_reloc; p;) { #ifdef ELFDEBUG - ErrorF("ResolveSymbols: file %lx, sec %d, r_offset 0x%x, r_info 0x%lx\n", - p->file, p->secn, p->rel->r_offset, p->rel->r_info); + ELFDEBUG("ResolveSymbols: " + "file %p, sec %d, r_offset 0x%x, r_info 0x%p\n", + (void *)p->file, p->secn, p->rel->r_offset, + (void *)p->rel->r_info); #endif tmp = Elf_RelocateEntry(p->file, p->secn, p->rel, FALSE); if (tmp) { @@ -2857,57 +3068,56 @@ void *mod; p = p->next; xf86loaderfree(tmp); } - _LoaderGetRelocations(mod)->elf_reloc=newlist; + _LoaderGetRelocations(mod)->elf_reloc = newlist; } int -ELFCheckForUnresolved(mod) -void *mod; +ELFCheckForUnresolved(void *mod) { - ELFRelocPtr erel; - char *name; - int flag, fatalsym=0; + ELFRelocPtr erel; + char *name; + int flag, fatalsym = 0; if ((erel = _LoaderGetRelocations(mod)->elf_reloc) == NULL) return 0; - while( erel ) { + while (erel) { Elf_RelocateEntry(erel->file, erel->secn, erel->rel, TRUE); name = ElfGetSymbolName(erel->file, ELF_R_SYM(erel->rel->r_info)); - flag = _LoaderHandleUnresolved( - name, _LoaderHandleToName(erel->file->handle)); - if(flag) fatalsym = 1; - erel=erel->next; + flag = _LoaderHandleUnresolved(name, + _LoaderHandleToName(erel->file-> + handle)); + if (flag) + fatalsym = 1; + erel = erel->next; } return fatalsym; } void -ELFUnloadModule(modptr) -void *modptr; +ELFUnloadModule(void *modptr) { - ELFModulePtr elffile = (ELFModulePtr)modptr; - ELFRelocPtr relptr, reltptr, *brelptr; + ELFModulePtr elffile = (ELFModulePtr) modptr; + ELFRelocPtr relptr, reltptr, *brelptr; int i; - + /* * Delete any unresolved relocations */ - relptr=_LoaderGetRelocations(elffile->funcs)->elf_reloc; - brelptr=&(_LoaderGetRelocations(elffile->funcs)->elf_reloc); + relptr = _LoaderGetRelocations(elffile->funcs)->elf_reloc; + brelptr = &(_LoaderGetRelocations(elffile->funcs)->elf_reloc); - while(relptr) { - if( relptr->file == elffile ) { - *brelptr=relptr->next; /* take it out of the list */ - reltptr=relptr; /* save pointer to this node */ - relptr=relptr->next; /* advance the pointer */ - xf86loaderfree(reltptr); /* free the node */ + while (relptr) { + if (relptr->file == elffile) { + *brelptr = relptr->next; /* take it out of the list */ + reltptr = relptr; /* save pointer to this node */ + relptr = relptr->next; /* advance the pointer */ + xf86loaderfree(reltptr); /* free the node */ + } else { + brelptr = &(relptr->next); + relptr = relptr->next; /* advance the pointer */ } - else { - brelptr=&(relptr->next); - relptr=relptr->next; /* advance the pointer */ - } } /* @@ -2921,18 +3131,19 @@ void *modptr; */ #if !defined (DoMMAPedMerge) # define CheckandFree(ptr,size) if(ptr) xf86loaderfree(ptr) -#else +#else # define CheckandFree(ptr,size) if (ptr) munmap(ptr,size) #endif #define CheckandFreeFile(ptr,size) if(ptr) _LoaderFreeFileMem((ptr),(size)) #ifdef MergeSectionAlloc - CheckandFree(elffile->base,elffile->basesize); + CheckandFree(elffile->base, elffile->basesize); # if defined(__alpha__) || defined(__ia64__) if (elffile->shared_got) { elffile->shared_got->nuses--; if (!elffile->shared_got->nuses) { ELFGotPtr *pgot = &ELFSharedGOTs; + while (*pgot && *pgot != elffile->shared_got) pgot = &(*pgot)->next; if (*pgot) @@ -2941,19 +3152,20 @@ void *modptr; } } # endif -#else /*MergeSectionAlloc*/ - CheckandFree(elffile->common,elffile->comsize); +#else /*MergeSectionAlloc */ + CheckandFree(elffile->common, elffile->comsize); # if defined(__alpha__) || defined(__ia64__) - CheckandFree(elffile->got,elffile->gotsize); + CheckandFree(elffile->got, elffile->gotsize); # endif # if defined(__ia64__) - CheckandFree(elffile->plt,elffile->pltsize); + CheckandFree(elffile->plt, elffile->pltsize); # endif #endif #if defined(__alpha__) || defined(__ia64__) { ELFGotEntryPtr gotent; - while((gotent = elffile->got_entries)) { + + while ((gotent = elffile->got_entries)) { elffile->got_entries = gotent->next; xf86loaderfree(gotent); } @@ -2962,6 +3174,7 @@ void *modptr; #if defined(__ia64__) { ELFPltEntryPtr pltent; + while ((pltent = elffile->plt_entries)) { elffile->plt_entries = pltent->next; xf86loaderfree(pltent); @@ -2969,6 +3182,7 @@ void *modptr; } { ELFOpdPtr opdent; + while ((opdent = elffile->opd_entries)) { elffile->opd_entries = opdent->next; xf86loaderfree(opdent); @@ -2994,12 +3208,11 @@ void *modptr; /* * Free the section table, section pointer array, and section names */ - _LoaderFreeFileMem(elffile->sections,elffile->secsize); + _LoaderFreeFileMem(elffile->sections, elffile->secsize); xf86loaderfree(elffile->saddr); - _LoaderFreeFileMem(elffile->header,sizeof(Elf_Ehdr)); - _LoaderFreeFileMem(elffile->shstraddr,elffile->shstrsize); - - + _LoaderFreeFileMem(elffile->header, sizeof(Elf_Ehdr)); + _LoaderFreeFileMem(elffile->shstraddr, elffile->shstrsize); + /* * Free the ELFModuleRec */ @@ -3011,14 +3224,14 @@ void *modptr; char * ELFAddressToSection(void *modptr, unsigned long address) { - ELFModulePtr elffile = (ELFModulePtr)modptr; + ELFModulePtr elffile = (ELFModulePtr) modptr; int i; - for( i=1; i<elffile->numsh; i++) { - if( address >= (unsigned long)elffile->saddr[i] && - address <= (unsigned long)elffile->saddr[i]+SecSize(i) ) { - return ElfGetSectionName(elffile, elffile->sections[i].sh_name); - } + for (i = 1; i < elffile->numsh; i++) { + if (address >= (unsigned long)elffile->saddr[i] && + address <= (unsigned long)elffile->saddr[i] + SecSize(i)) { + return ElfGetSectionName(elffile, elffile->sections[i].sh_name); } + } return NULL; } diff --git a/hw/xfree86/loader/elfloader.h b/hw/xfree86/loader/elfloader.h index cbd5f118a..e4693411b 100644 --- a/hw/xfree86/loader/elfloader.h +++ b/hw/xfree86/loader/elfloader.h @@ -21,7 +21,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.h,v 1.3 1998/09/20 14:41:05 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.h,v 1.4 2003/10/15 16:29:03 dawes Exp $ */ #ifndef _ELFLOADER_H #define _ELFLOADER_H @@ -29,6 +29,6 @@ extern void *ELFLoadModule(loaderPtr, int, LOOKUP **); extern void ELFResolveSymbols(void *); extern int ELFCheckForUnresolved(void *); -extern char *ELFAddressToSection(void *,unsigned long); +extern char *ELFAddressToSection(void *, unsigned long); extern void ELFUnloadModule(void *); #endif /* _ELFLOADER_h */ diff --git a/hw/xfree86/loader/extsym.c b/hw/xfree86/loader/extsym.c index 62a5ea98a..8da5089bc 100644 --- a/hw/xfree86/loader/extsym.c +++ b/hw/xfree86/loader/extsym.c @@ -1,8 +1,8 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.6 2001/11/17 16:05:59 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.9 2003/10/15 16:29:03 dawes Exp $ */ /* * - * Copyright 1999 by The XFree86 Project, Inc. + * Copyright 1999-2003 by The XFree86 Project, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -42,38 +42,39 @@ extern RESTYPE ShmSegType, ShmPixType; extern Bool noPanoramiXExtension; extern int PanoramiXNumScreens; extern PanoramiXData *panoramiXdataPtr; +extern XID *PanoramiXVisualTable; extern unsigned long XRT_WINDOW; extern unsigned long XRT_PIXMAP; extern unsigned long XRT_GC; extern unsigned long XRT_COLORMAP; extern unsigned long XRC_DRAWABLE; -extern Bool XineramaRegisterConnectionBlockCallback(void (*func)(void)); +extern Bool XineramaRegisterConnectionBlockCallback(void (*func) (void)); extern int XineramaDeleteResource(pointer, XID); #endif LOOKUP extLookupTab[] = { - SYMFUNC(ClientSleepUntil) + SYMFUNC(ClientSleepUntil) #ifdef HAS_SHM - SYMVAR(ShmCompletionCode) - SYMVAR(BadShmSegCode) - SYMVAR(ShmSegType) + SYMVAR(ShmCompletionCode) + SYMVAR(BadShmSegCode) + SYMVAR(ShmSegType) #endif #ifdef PANORAMIX - SYMFUNC(XineramaRegisterConnectionBlockCallback) - SYMFUNC(XineramaDeleteResource) - SYMVAR(noPanoramiXExtension) - SYMVAR(PanoramiXNumScreens) - SYMVAR(panoramiXdataPtr) - SYMVAR(XRT_WINDOW) - SYMVAR(XRT_PIXMAP) - SYMVAR(XRT_GC) - SYMVAR(XRT_COLORMAP) - SYMVAR(XRC_DRAWABLE) + SYMFUNC(XineramaRegisterConnectionBlockCallback) + SYMFUNC(XineramaDeleteResource) + SYMVAR(noPanoramiXExtension) + SYMVAR(PanoramiXNumScreens) + SYMVAR(panoramiXdataPtr) + SYMVAR(PanoramiXVisualTable) + SYMVAR(XRT_WINDOW) + SYMVAR(XRT_PIXMAP) + SYMVAR(XRT_GC) + SYMVAR(XRT_COLORMAP) + SYMVAR(XRC_DRAWABLE) #endif - { 0, 0 }, - + {0, 0} }; diff --git a/hw/xfree86/loader/fontsym.c b/hw/xfree86/loader/fontsym.c index 50def63ea..d91a2e216 100644 --- a/hw/xfree86/loader/fontsym.c +++ b/hw/xfree86/loader/fontsym.c @@ -1,4 +1,30 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/fontsym.c,v 1.11 2002/12/09 17:30:12 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/fontsym.c,v 1.13 2003/10/15 16:29:04 dawes Exp $ */ +/* + * Copyright (c) 1998-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ #include "font.h" #include "sym.h" @@ -16,64 +42,63 @@ LOOKUP fontLookupTab[] = { - SYMFUNC(TwoByteSwap) - SYMFUNC(FourByteSwap) - SYMFUNC(FontCouldBeTerminal) - SYMFUNC(BufFileRead) - SYMFUNC(BufFileWrite) - SYMFUNC(CheckFSFormat) - SYMFUNC(FontFileOpen) - SYMFUNC(FontFilePriorityRegisterRenderer) - SYMFUNC(FontFileRegisterRenderer) - SYMFUNC(FontParseXLFDName) - SYMFUNC(FontFileCloseFont) - SYMFUNC(FontFileOpenBitmap) - SYMFUNC(FontFileCompleteXLFD) - SYMFUNC(FontFileCountDashes) - SYMFUNC(FontFileFindNameInDir) - SYMFUNC(FontFileClose) - SYMFUNC(FontComputeInfoAccelerators) - SYMFUNC(FontDefaultFormat) - SYMFUNC(NameForAtom) - SYMFUNC(BitOrderInvert) - SYMFUNC(FontFileMatchRenderer) - SYMFUNC(RepadBitmap) - SYMFUNC(FontEncName) - SYMFUNC(FontEncRecode) - SYMFUNC(FontEncFind) - SYMFUNC(FontMapFind) - SYMFUNC(FontEncMapFind) - SYMFUNC(FontEncFromXLFD) - SYMFUNC(FontEncDirectory) - SYMFUNC(FontMapReverse) - SYMFUNC(FontMapReverseFree) - SYMFUNC(CreateFontRec) - SYMFUNC(DestroyFontRec) - SYMFUNC(GetGlyphs) - SYMFUNC(QueryGlyphExtents) - - SYMVAR(FontFileBitmapSources) + SYMFUNC(TwoByteSwap) + SYMFUNC(FourByteSwap) + SYMFUNC(FontCouldBeTerminal) + SYMFUNC(BufFileRead) + SYMFUNC(BufFileWrite) + SYMFUNC(CheckFSFormat) + SYMFUNC(FontFileOpen) + SYMFUNC(FontFilePriorityRegisterRenderer) + SYMFUNC(FontFileRegisterRenderer) + SYMFUNC(FontParseXLFDName) + SYMFUNC(FontFileCloseFont) + SYMFUNC(FontFileOpenBitmap) + SYMFUNC(FontFileCompleteXLFD) + SYMFUNC(FontFileCountDashes) + SYMFUNC(FontFileFindNameInDir) + SYMFUNC(FontFileClose) + SYMFUNC(FontComputeInfoAccelerators) + SYMFUNC(FontDefaultFormat) + SYMFUNC(NameForAtom) + SYMFUNC(BitOrderInvert) + SYMFUNC(FontFileMatchRenderer) + SYMFUNC(RepadBitmap) + SYMFUNC(FontEncName) + SYMFUNC(FontEncRecode) + SYMFUNC(FontEncFind) + SYMFUNC(FontMapFind) + SYMFUNC(FontEncMapFind) + SYMFUNC(FontEncFromXLFD) + SYMFUNC(FontEncDirectory) + SYMFUNC(FontMapReverse) + SYMFUNC(FontMapReverseFree) + SYMFUNC(CreateFontRec) + SYMFUNC(DestroyFontRec) + SYMFUNC(GetGlyphs) + SYMFUNC(QueryGlyphExtents) + + SYMVAR(FontFileBitmapSources) #ifdef FONTENC_COMPATIBILITY - /* Obsolete backwards compatibility symbols -- fontencc.c */ - SYMFUNC(font_encoding_from_xlfd) - SYMFUNC(font_encoding_find) - SYMFUNC(font_encoding_recode) - SYMFUNC(font_encoding_name) - SYMFUNC(identifyEncodingFile) + /* Obsolete backwards compatibility symbols -- fontencc.c */ + SYMFUNC(font_encoding_from_xlfd) + SYMFUNC(font_encoding_find) + SYMFUNC(font_encoding_recode) + SYMFUNC(font_encoding_name) + SYMFUNC(identifyEncodingFile) #endif - /* fontcache.c */ - SYMFUNC(FontCacheGetSettings) - SYMFUNC(FontCacheGetStatistics) - SYMFUNC(FontCacheChangeSettings) - SYMFUNC(FontCacheOpenCache) - SYMFUNC(FontCacheCloseCache) - SYMFUNC(FontCacheSearchEntry) - SYMFUNC(FontCacheGetEntry) - SYMFUNC(FontCacheInsertEntry) - SYMFUNC(FontCacheGetBitmap) - - { 0, 0 }, + /* fontcache.c */ + SYMFUNC(FontCacheGetSettings) + SYMFUNC(FontCacheGetStatistics) + SYMFUNC(FontCacheChangeSettings) + SYMFUNC(FontCacheOpenCache) + SYMFUNC(FontCacheCloseCache) + SYMFUNC(FontCacheSearchEntry) + SYMFUNC(FontCacheGetEntry) + SYMFUNC(FontCacheInsertEntry) + SYMFUNC(FontCacheGetBitmap) + {0, 0} }; diff --git a/hw/xfree86/loader/hash.c b/hw/xfree86/loader/hash.c index 22996f217..f8ddd45a4 100644 --- a/hw/xfree86/loader/hash.c +++ b/hw/xfree86/loader/hash.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.19 2001/07/25 15:05:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/hash.c,v 1.24 2003/11/17 22:20:40 dawes Exp $ */ /* * @@ -42,58 +42,54 @@ /* Prototypes for static functions. */ static unsigned int hashFunc(const char *); static itemPtr LoaderHashFindNearest( -#if NeedFunctionPrototypes -unsigned long -#endif -); + unsigned long + ); -static itemPtr LoaderhashTable[ HASHSIZE ] ; +static itemPtr LoaderhashTable[HASHSIZE]; #ifdef DEBUG -static int hashhits[ HASHSIZE ] ; +static int hashhits[HASHSIZE]; void DumpHashHits(void) { - int i; - int depth=0; - int dev=0; + int i; + int depth = 0; + int dev = 0; - for(i=0;i<HASHSIZE;i++) { - ErrorF("hashhits[%d]=%d\n", i, hashhits[i] ); + for (i = 0; i < HASHSIZE; i++) { + ErrorF("hashhits[%d]=%d\n", i, hashhits[i]); depth += hashhits[i]; } depth /= HASHSIZE; - ErrorF("Average hash depth=%d\n", depth ); + ErrorF("Average hash depth=%d\n", depth); - for(i=0;i<HASHSIZE;i++) { - if( hashhits[i] < depth ) - dev += depth-hashhits[i]; + for (i = 0; i < HASHSIZE; i++) { + if (hashhits[i] < depth) + dev += depth - hashhits[i]; else - dev += hashhits[i]-depth; + dev += hashhits[i] - depth; } - dev /=HASHSIZE; - ErrorF("Average hash deviation=%d\n", dev ); + dev /= HASHSIZE; + ErrorF("Average hash deviation=%d\n", dev); } #endif - static unsigned int -hashFunc(string) -const char *string; +hashFunc(const char *string) { - int i=0; + int i = 0; - while ( i < 10 && string[i] ) - i ++ ; + while (i < 10 && string[i]) + i++; - if ( i < 5 ) { + if (i < 5) { #ifdef DEBUG hashhits[i]++; #endif - return i ; + return i; } /* @@ -111,29 +107,25 @@ const char *string; } void -LoaderHashAdd( entry ) - itemPtr entry ; +LoaderHashAdd(itemPtr entry) { - int bucket = hashFunc( entry->name ) ; - itemPtr oentry; + int bucket = hashFunc(entry->name); + itemPtr oentry; - if ((oentry = LoaderHashFind(entry->name)) != NULL) + if ((oentry = LoaderHashFind(entry->name)) != NULL) LoaderDuplicateSymbol(entry->name, oentry->handle); - entry->next = LoaderhashTable[ bucket ] ; - LoaderhashTable[ bucket ] = entry ; - return; + entry->next = LoaderhashTable[bucket]; + LoaderhashTable[bucket] = entry; + return; } void -LoaderAddSymbols(handle, module, list) -int handle; -int module; -LOOKUP *list ; +LoaderAddSymbols(int handle, int module, LOOKUP *list) { - LOOKUP *l = list, *exports = NULL; - itemPtr i, exportsItem = NULL; - char *modname; + LOOKUP *l = list, *exports = NULL; + itemPtr i, exportsItem = NULL; + char *modname; if (!list) return; @@ -148,7 +140,7 @@ LOOKUP *list ; char *exportname; exportname = xf86loadermalloc(strlen("ExportedSymbols") + - strlen(modname) + 1); + strlen(modname) + 1); if (exportname) { sprintf(exportname, "%sExportedSymbols", modname); while (l->symName) { @@ -160,6 +152,7 @@ LOOKUP *list ; } l++; } + xf86loaderfree(exportname); } } @@ -167,13 +160,13 @@ LOOKUP *list ; * Allocate the exports list item first. */ if (exports) { - exportsItem = xf86loadermalloc( sizeof( itemRec )) ; - exportsItem->name = exports->symName ; - exportsItem->address = (char *) exports->offset ; - exportsItem->handle = handle ; - exportsItem->module = module ; + exportsItem = xf86loadermalloc(sizeof(itemRec)); + exportsItem->name = exports->symName; + exportsItem->address = (char *)exports->offset; + exportsItem->handle = handle; + exportsItem->module = module; exportsItem->exports = NULL; - LoaderHashAdd( exportsItem ); + LoaderHashAdd(exportsItem); } /* @@ -181,107 +174,106 @@ LOOKUP *list ; * reference to the export list, if present. */ l = list; - while ( l->symName ) { + while (l->symName) { if (l != exports) { - i = xf86loadermalloc( sizeof( itemRec )) ; - i->name = l->symName ; - i->address = (char *) l->offset ; - i->handle = handle ; - i->module = module ; + i = xf86loadermalloc(sizeof(itemRec)); + i->name = l->symName; + i->address = (char *)l->offset; + i->handle = handle; + i->module = module; i->exports = exportsItem; - LoaderHashAdd( i ); + LoaderHashAdd(i); } - l ++ ; + l++; } } itemPtr -LoaderHashDelete(string) -const char *string; +LoaderHashDelete(const char *string) { - int bucket = hashFunc( string ) ; - itemPtr entry; - itemPtr *entry2; - - entry = LoaderhashTable[ bucket ] ; - entry2= &(LoaderhashTable[ bucket ]); - while ( entry ) { - if (! strcmp( entry->name, string )) { - *entry2=entry->next; - xf86loaderfree(entry->name); - xf86loaderfree( entry ) ; - return 0 ; + int bucket = hashFunc(string); + itemPtr entry; + itemPtr *entry2; + + entry = LoaderhashTable[bucket]; + entry2 = &(LoaderhashTable[bucket]); + while (entry) { + if (!strcmp(entry->name, string)) { + *entry2 = entry->next; + xf86loaderfree(entry->name); + xf86loaderfree(entry); + return 0; + } + entry2 = &(entry->next); + entry = entry->next; } - entry2 = &(entry->next) ; - entry = entry->next ; - } - return 0 ; + return 0; } itemPtr -LoaderHashFind(string) -const char *string; +LoaderHashFind(const char *string) { - int bucket = hashFunc( string ) ; - itemPtr entry ; - entry = LoaderhashTable[ bucket ] ; - while ( entry ) { - if (!strcmp(entry->name, string)) { - return entry; - } - entry = entry->next; + int bucket = hashFunc(string); + itemPtr entry; + + entry = LoaderhashTable[bucket]; + while (entry) { + if (!strcmp(entry->name, string)) { + return entry; } + entry = entry->next; + } return 0; } static itemPtr -LoaderHashFindNearest(address) -unsigned long address; +LoaderHashFindNearest(unsigned long address) { - int i ; - itemPtr entry, best_entry = 0 ; - long best_difference = MAXINT; - - for ( i = 0 ; i < HASHSIZE ; i ++ ) { - entry = LoaderhashTable[ i ] ; - while ( entry ) { - long difference = (long) address - (long) entry->address ; - if ( difference >= 0 ) { - if ( best_entry ) { - if ( difference < best_difference ) { - best_entry = entry ; - best_difference = difference ; - } - } - else { - best_entry = entry ; - best_difference = difference ; + int i; + itemPtr entry, best_entry = 0; + long best_difference = MAXINT; + + for (i = 0; i < HASHSIZE; i++) { + entry = LoaderhashTable[i]; + while (entry) { + long difference = (long)address - (long)entry->address; + + if (difference >= 0) { + if (best_entry) { + if (difference < best_difference) { + best_entry = entry; + best_difference = difference; + } + } else { + best_entry = entry; + best_difference = difference; + } + } + entry = entry->next; } - } - entry = entry->next ; } - } - return best_entry ; + return best_entry; } void -LoaderPrintSymbol(address) -unsigned long address; +LoaderPrintSymbol(unsigned long address) { - itemPtr entry; - entry=LoaderHashFindNearest(address); + itemPtr entry; + + entry = LoaderHashFindNearest(address); if (entry) { const char *module, *section; + #if defined(__alpha__) || defined(__ia64__) - ErrorF("0x%016lx %s+%lx\n", entry->address, entry->name, - address - (unsigned long) entry->address); + ErrorF("0x%016lx %s+%lx\n", (unsigned long)entry->address, + entry->name, address - (unsigned long)entry->address); #else - ErrorF("0x%x %s+%x\n", entry->address, entry->name, - address - (unsigned long) entry->address); + ErrorF("0x%lx %s+%lx\n", (unsigned long)entry->address, entry->name, + address - (unsigned long)entry->address); #endif - if ( _LoaderAddressToSection(address, &module, §ion) ) - ErrorF("\tModule \"%s\"\n\tSection \"%s\"\n",module, section ); + if (_LoaderAddressToSection(address, &module, §ion)) + ErrorF("\tModule \"%s\"\n\tSection \"%s\"\n", module, section); } else { ErrorF("(null)\n"); } @@ -292,73 +284,70 @@ LoaderPrintItem(itemPtr pItem) { if (pItem) { const char *module, *section; + #if defined(__alpha__) || defined(__ia64__) - ErrorF("0x%016lx %s\n", pItem->address, pItem->name); + ErrorF("0x%016lx %s\n", (unsigned long)pItem->address, pItem->name); #else - ErrorF("0x%lx %s\n", pItem->address, pItem->name); + ErrorF("0x%lx %s\n", (unsigned long)pItem->address, pItem->name); #endif - if ( _LoaderAddressToSection((unsigned long)pItem->address, - &module, §ion) ) - ErrorF("\tModule \"%s\"\n\tSection \"%s\"\n",module, section ); + if (_LoaderAddressToSection((unsigned long)pItem->address, + &module, §ion)) + ErrorF("\tModule \"%s\"\n\tSection \"%s\"\n", module, section); } else ErrorF("(null)\n"); } - + void -LoaderPrintAddress(symbol) -const char *symbol; +LoaderPrintAddress(const char *symbol) { - itemPtr entry; + itemPtr entry; + entry = LoaderHashFind(symbol); LoaderPrintItem(entry); } void -LoaderHashTraverse(card, fnp) - void *card; - int (*fnp)(void *, itemPtr); +LoaderHashTraverse(void *card, int (*fnp)(void *, itemPtr)) { - int i ; - itemPtr entry, last_entry = 0 ; - - for ( i = 0 ; i < HASHSIZE ; i ++ ) { - last_entry = 0 ; - entry = LoaderhashTable[ i ] ; - while ( entry ) { - if (( * fnp )( card, entry )) { - if ( last_entry ) { - last_entry->next = entry->next ; - xf86loaderfree( entry->name ) ; - xf86loaderfree( entry ) ; - entry = last_entry->next ; - } - else { - LoaderhashTable[ i ] = entry->next ; - xf86loaderfree( entry->name ) ; - xf86loaderfree( entry ) ; - entry = LoaderhashTable[ i ] ; + int i; + itemPtr entry, last_entry = 0; + + for (i = 0; i < HASHSIZE; i++) { + last_entry = 0; + entry = LoaderhashTable[i]; + while (entry) { + if ((*fnp) (card, entry)) { + if (last_entry) { + last_entry->next = entry->next; + xf86loaderfree(entry->name); + xf86loaderfree(entry); + entry = last_entry->next; + } else { + LoaderhashTable[i] = entry->next; + xf86loaderfree(entry->name); + xf86loaderfree(entry); + entry = LoaderhashTable[i]; + } + } else { + last_entry = entry; + entry = entry->next; + } } - } - else { - last_entry = entry ; - entry = entry->next ; - } } - } } void LoaderDumpSymbols() { - itemPtr entry; - int j; - - for (j=0; j<HASHSIZE; j++) { - entry = LoaderhashTable[j]; - while (entry) { - LoaderPrintItem(entry); - entry = entry->next; - } + itemPtr entry; + int j; + + for (j = 0; j < HASHSIZE; j++) { + entry = LoaderhashTable[j]; + while (entry) { + LoaderPrintItem(entry); + entry = entry->next; } - + } + } diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c index e09fa50b0..39ba510a1 100644 --- a/hw/xfree86/loader/loader.c +++ b/hw/xfree86/loader/loader.c @@ -1,7 +1,6 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.63 2002/11/25 14:05:03 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.71 2003/11/06 18:38:13 tsi Exp $ */ /* - * * Copyright 1995-1998 by Metro Link, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -22,6 +21,33 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -35,7 +61,7 @@ #include <string.h> #if defined(linux) && \ (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \ - || defined(__x86_64__)) + || defined(__AMD64__)) #include <malloc.h> #endif #include <stdarg.h> @@ -73,7 +99,7 @@ int check_unresolved_sema = 0; #endif #ifdef __UNIXOS2__ -void * os2ldcalloc(size_t,size_t); +void *os2ldcalloc(size_t, size_t); #endif #ifdef HANDLE_IN_HASH_ENTRY @@ -84,11 +110,11 @@ void * os2ldcalloc(size_t,size_t); #define MAX_HANDLE 256 #define HANDLE_FREE 0 #define HANDLE_USED 1 -static char freeHandles[MAX_HANDLE] ; -static int refCount[MAX_HANDLE] ; +static char freeHandles[MAX_HANDLE]; +static int refCount[MAX_HANDLE]; #endif -#if defined(__sparc__) && defined(__GNUC__) +#if defined(__sparc__) && defined(__GNUC__) && !defined(__FreeBSD__) # define SYMFUNCDOT(func) { "." #func, (funcptr)&__sparc_dot_ ## func }, # if !defined(__OpenBSD__) # define SYMFUNCDOT89(func) { "." #func, (funcptr)&func ## _sparcv89 }, @@ -108,24 +134,25 @@ DEFFUNCDOT(div) DEFFUNCDOT(udiv) #ifdef linux static LOOKUP SparcV89LookupTab[] = { - SYMFUNCDOT89(rem) - SYMFUNCDOT89(urem) - SYMFUNCDOT89(mul) - SYMFUNCDOT89(umul) - SYMFUNCDOT89(div) - SYMFUNCDOT89(udiv) - { 0, 0 } + SYMFUNCDOT89(rem) + SYMFUNCDOT89(urem) + SYMFUNCDOT89(mul) + SYMFUNCDOT89(umul) + SYMFUNCDOT89(div) + SYMFUNCDOT89(udiv) + {0, 0} }; #endif static LOOKUP SparcLookupTab[] = { - SYMFUNCDOT(rem) - SYMFUNCDOT(urem) - SYMFUNCDOT(mul) - SYMFUNCDOT(umul) - SYMFUNCDOT(div) - SYMFUNCDOT(udiv) - { 0, 0 } + SYMFUNCDOT(rem) + SYMFUNCDOT(urem) + SYMFUNCDOT(mul) + SYMFUNCDOT(umul) + SYMFUNCDOT(div) + SYMFUNCDOT(udiv) + {0, 0} }; + #ifdef linux #if defined(__GNUC__) && defined(__GLIBC__) #define HWCAP_SPARC_MULDIV 8 @@ -138,29 +165,32 @@ sparcUseHWMulDiv(void) FILE *f; char buffer[1024]; char *p; + #if defined(__GNUC__) && defined(__GLIBC__) unsigned long *hwcap; + __asm(".weak _dl_hwcap"); - + hwcap = &_dl_hwcap; - __asm("" : "=r" (hwcap) : "0" (hwcap)); + __asm("": "=r"(hwcap):"0"(hwcap)); if (hwcap) { - if (*hwcap & HWCAP_SPARC_MULDIV) - return 1; - else - return 0; + if (*hwcap & HWCAP_SPARC_MULDIV) + return 1; + else + return 0; } #endif - f = fopen("/proc/cpuinfo","r"); - if (!f) return 0; + f = fopen("/proc/cpuinfo", "r"); + if (!f) + return 0; while (fgets(buffer, 1024, f) != NULL) { - if (!strncmp (buffer, "type", 4)) { - p = strstr (buffer, "sun4"); - if (p && (p[4] == 'u' || p[4] == 'd' || p[4] == 'm')) { - fclose(f); - return 1; - } - } + if (!strncmp(buffer, "type", 4)) { + p = strstr(buffer, "sun4"); + if (p && (p[4] == 'u' || p[4] == 'd' || p[4] == 'm')) { + fclose(f); + return 1; + } + } } fclose(f); return 0; @@ -191,8 +221,8 @@ LDRCommonPtr ldrCommons; int nCommons; typedef struct { - int num; - const char ** list; + int num; + const char **list; } symlist; /* @@ -210,119 +240,127 @@ static int fatalReqSym = 0; static int _GetModuleType(int, long); static loaderPtr _LoaderListPush(void); static loaderPtr _LoaderListPop(int); -/*ARGSUSED*/ -static void ARCHIVEResolveSymbols(void *unused) {} -/*ARGSUSED*/ -static int ARCHIVECheckForUnresolved(void *v) { return 0; } -/*ARGSUSED*/ -static char *ARCHIVEAddressToSection(void *modptr, unsigned long address) -{ return NULL; } -/*ARGSUSED*/ -static void ARCHIVEUnload(void *unused2) {} + /*ARGSUSED*/ static void +ARCHIVEResolveSymbols(void *unused) +{ +} + /*ARGSUSED*/ static int +ARCHIVECheckForUnresolved(void *v) +{ + return 0; +} + /*ARGSUSED*/ static char * +ARCHIVEAddressToSection(void *modptr, unsigned long address) +{ + return NULL; +} + /*ARGSUSED*/ static void +ARCHIVEUnload(void *unused2) +{ +} /* * Array containing entry points for different formats. */ static loader_funcs funcs[] = { - /* LD_ARCHIVE */ - {ARCHIVELoadModule, - ARCHIVEResolveSymbols, - ARCHIVECheckForUnresolved, - ARCHIVEAddressToSection, - ARCHIVEUnload, {0,0,0,0,0}}, - /* LD_ELFOBJECT */ - {ELFLoadModule, - ELFResolveSymbols, - ELFCheckForUnresolved, - ELFAddressToSection, - ELFUnloadModule, {0,0,0,0,0}}, - /* LD_COFFOBJECT */ - {COFFLoadModule, - COFFResolveSymbols, - COFFCheckForUnresolved, - COFFAddressToSection, - COFFUnloadModule, {0,0,0,0,0}}, - /* LD_XCOFFOBJECT */ - {COFFLoadModule, - COFFResolveSymbols, - COFFCheckForUnresolved, - COFFAddressToSection, - COFFUnloadModule, {0,0,0,0,0}}, - /* LD_AOUTOBJECT */ - {AOUTLoadModule, - AOUTResolveSymbols, - AOUTCheckForUnresolved, - AOUTAddressToSection, - AOUTUnloadModule, {0,0,0,0,0}}, - /* LD_AOUTDLOBJECT */ + /* LD_ARCHIVE */ + {ARCHIVELoadModule, + ARCHIVEResolveSymbols, + ARCHIVECheckForUnresolved, + ARCHIVEAddressToSection, + ARCHIVEUnload, {0, 0, 0, 0, 0}}, + /* LD_ELFOBJECT */ + {ELFLoadModule, + ELFResolveSymbols, + ELFCheckForUnresolved, + ELFAddressToSection, + ELFUnloadModule, {0, 0, 0, 0, 0}}, + /* LD_COFFOBJECT */ + {COFFLoadModule, + COFFResolveSymbols, + COFFCheckForUnresolved, + COFFAddressToSection, + COFFUnloadModule, {0, 0, 0, 0, 0}}, + /* LD_XCOFFOBJECT */ + {COFFLoadModule, + COFFResolveSymbols, + COFFCheckForUnresolved, + COFFAddressToSection, + COFFUnloadModule, {0, 0, 0, 0, 0}}, + /* LD_AOUTOBJECT */ + {AOUTLoadModule, + AOUTResolveSymbols, + AOUTCheckForUnresolved, + AOUTAddressToSection, + AOUTUnloadModule, {0, 0, 0, 0, 0}}, + /* LD_AOUTDLOBJECT */ #ifdef DLOPEN_SUPPORT - {DLLoadModule, - DLResolveSymbols, - DLCheckForUnresolved, - ARCHIVEAddressToSection, - DLUnloadModule, {0,0,0,0,0}}, + {DLLoadModule, + DLResolveSymbols, + DLCheckForUnresolved, + ARCHIVEAddressToSection, + DLUnloadModule, {0, 0, 0, 0, 0}}, #else - {AOUTLoadModule, - AOUTResolveSymbols, - AOUTCheckForUnresolved, - AOUTAddressToSection, - AOUTUnloadModule, {0,0,0,0,0}}, + {AOUTLoadModule, + AOUTResolveSymbols, + AOUTCheckForUnresolved, + AOUTAddressToSection, + AOUTUnloadModule, {0, 0, 0, 0, 0}}, #endif - /* LD_ELFDLOBJECT */ + /* LD_ELFDLOBJECT */ #ifdef DLOPEN_SUPPORT - {DLLoadModule, - DLResolveSymbols, - DLCheckForUnresolved, - ARCHIVEAddressToSection, - DLUnloadModule, {0,0,0,0,0}}, + {DLLoadModule, + DLResolveSymbols, + DLCheckForUnresolved, + ARCHIVEAddressToSection, + DLUnloadModule, {0, 0, 0, 0, 0}}, #else - {ELFLoadModule, - ELFResolveSymbols, - ELFCheckForUnresolved, - ELFAddressToSection, - ELFUnloadModule, {0,0,0,0,0}}, + {ELFLoadModule, + ELFResolveSymbols, + ELFCheckForUnresolved, + ELFAddressToSection, + ELFUnloadModule, {0, 0, 0, 0, 0}}, #endif - }; - -int numloaders=sizeof(funcs)/sizeof(loader_funcs); +}; +int numloaders = sizeof(funcs) / sizeof(loader_funcs); void LoaderInit(void) { const char *osname = NULL; - LoaderAddSymbols(-1, -1, miLookupTab ) ; - LoaderAddSymbols(-1, -1, xfree86LookupTab ) ; - LoaderAddSymbols(-1, -1, dixLookupTab ) ; - LoaderAddSymbols(-1, -1, fontLookupTab ) ; - LoaderAddSymbols(-1, -1, extLookupTab ); -#ifdef __sparc__ + LoaderAddSymbols(-1, -1, miLookupTab); + LoaderAddSymbols(-1, -1, xfree86LookupTab); + LoaderAddSymbols(-1, -1, dixLookupTab); + LoaderAddSymbols(-1, -1, fontLookupTab); + LoaderAddSymbols(-1, -1, extLookupTab); +#if defined(__sparc__) && !defined(__FreeBSD__) #ifdef linux if (sparcUseHWMulDiv()) - LoaderAddSymbols(-1, -1, SparcV89LookupTab ) ; + LoaderAddSymbols(-1, -1, SparcV89LookupTab); else #endif - LoaderAddSymbols(-1, -1, SparcLookupTab ) ; -#endif + LoaderAddSymbols(-1, -1, SparcLookupTab); +#endif xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n"); xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC, - GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), - GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); + GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), + GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV, - GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), - GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); + GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), + GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT, - GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), - GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); + GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), + GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION, - GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), - GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); + GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), + GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_FONT, - GET_ABI_MAJOR(LoaderVersionInfo.fontVersion), - GET_ABI_MINOR(LoaderVersionInfo.fontVersion)); + GET_ABI_MAJOR(LoaderVersionInfo.fontVersion), + GET_ABI_MINOR(LoaderVersionInfo.fontVersion)); LoaderGetOS(&osname, NULL, NULL, NULL); if (osname) @@ -330,13 +368,13 @@ LoaderInit(void) #if defined(linux) && \ (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \ - || ( defined __x86_64__ && ! defined UseMMAP && ! defined DoMMAPedMerge)) + || ( defined __AMD64__ && ! defined UseMMAP && ! defined DoMMAPedMerge)) /* * The glibc malloc uses mmap for large allocations anyway. This breaks * some relocation types because the offset overflow. See loader.h for more * details. We need to turn off this behavior here. */ - mallopt(M_MMAP_MAX,0); + mallopt(M_MMAP_MAX, 0); #endif } @@ -350,84 +388,83 @@ LoaderInit(void) static int _GetModuleType(int fd, long offset) { - unsigned char buf[256]; /* long enough for the largest magic type */ + unsigned char buf[256]; /* long enough for the largest magic type */ - if( read(fd,buf,sizeof(buf)) < 0 ) { + if (read(fd, buf, sizeof(buf)) < 0) { return -1; } - #ifdef DEBUG - ErrorF("Checking module type %10s\n", buf ); - ErrorF("Checking module type %x %x %x %x\n", buf[0], buf[1], buf[2], buf[3] ); + ErrorF("Checking module type %10s\n", buf); + ErrorF("Checking module type %x %x %x %x\n", buf[0], buf[1], buf[2], + buf[3]); #endif - lseek(fd,offset,SEEK_SET); + lseek(fd, offset, SEEK_SET); - if (strncmp((char *) buf, ARMAG, SARMAG) == 0) { + if (strncmp((char *)buf, ARMAG, SARMAG) == 0) { return LD_ARCHIVE; } - #if defined(AIAMAG) /* LynxOS PPC style archives */ - if (strncmp((char *) buf, AIAMAG, SAIAMAG) == 0) { + if (strncmp((char *)buf, AIAMAG, SAIAMAG) == 0) { return LD_ARCHIVE; } #endif - if (strncmp((char *) buf, ELFMAG, SELFMAG) == 0) { - if( *((Elf32_Half *)(buf + ELFDLOFF)) == ELFDLMAG ) { + if (strncmp((char *)buf, ELFMAG, SELFMAG) == 0) { + if (*((Elf32_Half *) (buf + ELFDLOFF)) == ELFDLMAG) { return LD_ELFDLOBJECT; } else { return LD_ELFOBJECT; } } - if( buf[0] == 0x4c && buf[1] == 0x01 ) { + if (buf[0] == 0x4c && buf[1] == 0x01) { /* I386MAGIC */ return LD_COFFOBJECT; } - if( buf[0] == 0x01 && buf[1] == 0xdf ) { + if (buf[0] == 0x01 && buf[1] == 0xdf) { /* XCOFFMAGIC */ return LD_COFFOBJECT; - } - if( buf[0] == 0x0d && buf[1] == 0x01 ) { + } + if (buf[0] == 0x0d && buf[1] == 0x01) { /* ZCOFFMAGIC (LynxOS) */ return LD_COFFOBJECT; } - if( buf[0] == 0x00 && buf[1] == 0x86 && buf[2] == 0x01 && buf[3] == 0x07) { - /* AOUTMAGIC */ - return LD_AOUTOBJECT; + if (buf[0] == 0x00 && buf[1] == 0x86 && buf[2] == 0x01 && buf[3] == 0x07) { + /* AOUTMAGIC */ + return LD_AOUTOBJECT; } - if (buf[0] == 0x07 && buf[1] == 0x01 && (buf[2] == 0x64 || buf[2] == 0x86)) - { - /* AOUTMAGIC, (Linux OMAGIC, old impure format, also used by OS/2 */ - return LD_AOUTOBJECT; + if (buf[0] == 0x07 && buf[1] == 0x01 + && (buf[2] == 0x64 || buf[2] == 0x86)) { + /* AOUTMAGIC, (Linux OMAGIC, old impure format, also used by OS/2 */ + return LD_AOUTOBJECT; } - if (buf[0] == 0x07 && buf[1] == 0x01 && buf[2] == 0x00 && buf[3] == 0x00) - { - /* AOUTMAGIC, BSDI */ - return LD_AOUTOBJECT; + if (buf[0] == 0x07 && buf[1] == 0x01 && buf[2] == 0x00 && buf[3] == 0x00) { + /* AOUTMAGIC, BSDI */ + return LD_AOUTOBJECT; } - if ((buf[0] == 0xc0 && buf[1] == 0x86) || /* big endian form */ - (buf[3] == 0xc0 && buf[2] == 0x86)) { /* little endian form */ - /* i386 shared object */ - return LD_AOUTDLOBJECT; + if ((buf[0] == 0xc0 && buf[1] == 0x86) || /* big endian form */ + (buf[3] == 0xc0 && buf[2] == 0x86)) { /* little endian form */ + /* i386 shared object */ + return LD_AOUTDLOBJECT; } return LD_UNKNOWN; } +static int offsetbias = 0; /* offset into archive */ -static int offsetbias=0; /* offset into archive */ /* * _LoaderFileToMem() loads the contents of a file into memory using * the most efficient method for a platform. */ void * -_LoaderFileToMem(int fd, unsigned long offset,int size, char *label) +_LoaderFileToMem(int fd, unsigned long offset, int size, char *label) { #ifdef UseMMAP - unsigned long ret; + unsigned long ret; + # ifdef MmapPageAlign unsigned long pagesize; unsigned long new_size; @@ -437,7 +474,8 @@ _LoaderFileToMem(int fd, unsigned long offset,int size, char *label) # define MMAP_PROT (PROT_READ|PROT_WRITE|PROT_EXEC) # ifdef DEBUGMEM - ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)",fd,offset,offsetbias,size,label); + ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)", fd, offset, offsetbias, size, + label); # endif # ifdef MmapPageAlign pagesize = getpagesize(); @@ -446,81 +484,84 @@ _LoaderFileToMem(int fd, unsigned long offset,int size, char *label) new_off = (offset + offsetbias) / pagesize; new_off *= pagesize; new_off_bias = (offset + offsetbias) - new_off; - if ((new_off_bias + size) > new_size) new_size += pagesize; - ret = (unsigned long) mmap(0,new_size,MMAP_PROT,MAP_PRIVATE -# ifdef __x86_64__ - | MAP_32BIT + if ((new_off_bias + size) > new_size) + new_size += pagesize; + ret = (unsigned long)mmap(0, new_size, MMAP_PROT, MAP_PRIVATE +# ifdef __AMD64__ + | MAP_32BIT # endif - , - fd,new_off); - if(ret == -1) - FatalError("mmap() failed: %s\n", strerror(errno) ); + , fd, new_off); + if (ret == -1) + FatalError("mmap() failed: %s\n", strerror(errno)); return (void *)(ret + new_off_bias); # else - ret = (unsigned long) mmap(0,size,MMAP_PROT,MAP_PRIVATE -# ifdef __x86_64__ - | MAP_32BIT + ret = (unsigned long)mmap(0, size, MMAP_PROT, MAP_PRIVATE +# ifdef __AMD64__ + | MAP_32BIT # endif - , - fd,offset + offsetbias); - if(ret == -1) - FatalError("mmap() failed: %s\n", strerror(errno) ); + , fd, offset + offsetbias); + if (ret == -1) + FatalError("mmap() failed: %s\n", strerror(errno)); return (void *)ret; # endif #else char *ptr; # ifdef DEBUGMEM - ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)",fd,offset,offsetbias,size,label); + ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)", fd, offset, offsetbias, size, + label); # endif - if(size == 0){ + if (size == 0) { # ifdef DEBUGMEM - ErrorF("=NULL\n",ptr); + ErrorF("=NULL\n", ptr); # endif return NULL; } - # ifndef __UNIXOS2__ - if( (ptr=xf86loadercalloc(size,1)) == NULL ) - FatalError("_LoaderFileToMem() malloc failed\n" ); + if ((ptr = xf86loadercalloc(size, 1)) == NULL) + FatalError("_LoaderFileToMem() malloc failed\n"); # else - if( (ptr=os2ldcalloc(size,1)) == NULL ) - FatalError("_LoaderFileToMem() malloc failed\n" ); + if ((ptr = os2ldcalloc(size, 1)) == NULL) + FatalError("_LoaderFileToMem() malloc failed\n"); # endif # if defined(linux) && defined(__ia64__) { unsigned long page_size = getpagesize(); unsigned long round; - round = (unsigned long)ptr & (page_size-1); - mprotect(ptr - round, (size+round+page_size-1) & ~(page_size-1), - PROT_READ|PROT_WRITE|PROT_EXEC); + round = (unsigned long)ptr & (page_size - 1); + mprotect(ptr - round, + (size + round + page_size - 1) & ~(page_size - 1), + PROT_READ | PROT_WRITE | PROT_EXEC); } # endif - if(lseek(fd,offset+offsetbias,SEEK_SET)<0) - FatalError("\n_LoaderFileToMem() lseek() failed: %s\n",strerror(errno)); + if (lseek(fd, offset + offsetbias, SEEK_SET) < 0) + FatalError("\n_LoaderFileToMem() lseek() failed: %s\n", + strerror(errno)); - if(read(fd,ptr,size)!=size) - FatalError("\n_LoaderFileToMem() read() failed: %s\n",strerror(errno)); + if (read(fd, ptr, size) != size) + FatalError("\n_LoaderFileToMem() read() failed: %s\n", + strerror(errno)); # if (defined(linux) || defined(__NetBSD__) || defined(__OpenBSD__)) \ - && defined(__powerpc__) + && defined(__powerpc__) /* * Keep the instruction cache in sync with changes in the * main memory. */ - { - int i; - for (i = 0; i < size; i += 16) - ppc_flush_icache(ptr+i); - ppc_flush_icache(ptr+size-1); - } + { + int i; + + for (i = 0; i < size; i += 16) + ppc_flush_icache(ptr + i); + ppc_flush_icache(ptr + size - 1); + } # endif # ifdef DEBUGMEM - ErrorF("=%lx\n",ptr); + ErrorF("=%lx\n", ptr); # endif return (void *)ptr; @@ -535,25 +576,26 @@ _LoaderFreeFileMem(void *addr, int size) { #if defined (UseMMAP) && defined (MmapPageAlign) unsigned long pagesize = getpagesize(); - memType i_addr = (memType)addr; + memType i_addr = (memType) addr; unsigned long new_size; #endif #ifdef DEBUGMEM - ErrorF("_LoaderFreeFileMem(%x,%d)\n",addr,size); + ErrorF("_LoaderFreeFileMem(%x,%d)\n", addr, size); #endif #ifdef UseMMAP # if defined (MmapPageAlign) - i_addr /= pagesize; - i_addr *= pagesize; + i_addr /= pagesize; + i_addr *= pagesize; new_size = (size + pagesize - 1) / pagesize; new_size *= pagesize; - if (((memType)addr - i_addr + size) > new_size) new_size += pagesize; - munmap((void *)i_addr,new_size); + if (((memType) addr - i_addr + size) > new_size) + new_size += pagesize; + munmap((void *)i_addr, new_size); # else - munmap((void *)addr,size); + munmap((void *)addr, size); # endif #else - if(size == 0) + if (size == 0) return; xf86loaderfree(addr); @@ -565,43 +607,44 @@ _LoaderFreeFileMem(void *addr, int size) int _LoaderFileRead(int fd, unsigned int offset, void *buf, int size) { - if(lseek(fd,offset+offsetbias,SEEK_SET)<0) - FatalError("_LoaderFileRead() lseek() failed: %s\n", strerror(errno) ); + if (lseek(fd, offset + offsetbias, SEEK_SET) < 0) + FatalError("_LoaderFileRead() lseek() failed: %s\n", strerror(errno)); - if(read(fd,buf,size)!=size) - FatalError("_LoaderFileRead() read() failed: %s\n", strerror(errno) ); + if (read(fd, buf, size) != size) + FatalError("_LoaderFileRead() read() failed: %s\n", strerror(errno)); return size; } -static loaderPtr listHead = (loaderPtr) 0 ; +static loaderPtr listHead = (loaderPtr) 0; static loaderPtr _LoaderListPush() { - loaderPtr item = xf86loadercalloc(1, sizeof (struct _loader)); - item->next = listHead ; - listHead = item; + loaderPtr item = xf86loadercalloc(1, sizeof(struct _loader)); - return item; + item->next = listHead; + listHead = item; + + return item; } static loaderPtr _LoaderListPop(int handle) { - loaderPtr item=listHead; - loaderPtr *bptr=&listHead; /* pointer to previous node */ + loaderPtr item = listHead; + loaderPtr *bptr = &listHead; /* pointer to previous node */ - while(item) { - if( item->handle == handle ) { - *bptr=item->next; /* remove this from the list */ + while (item) { + if (item->handle == handle) { + *bptr = item->next; /* remove this from the list */ return item; - } - bptr=&(item->next); - item=item->next; } + bptr = &(item->next); + item = item->next; + } - return 0; + return 0; } /* @@ -612,30 +655,30 @@ _LoaderListPop(int handle) char * _LoaderHandleToName(int handle) { - loaderPtr item=listHead; - loaderPtr aritem=NULL; - loaderPtr lastitem=NULL; + loaderPtr item = listHead; + loaderPtr aritem = NULL; + loaderPtr lastitem = NULL; - if ( handle < 0 ) { + if (handle < 0) { return "(built-in)"; - } - while(item) { - if( item->handle == handle ) { - if( strchr(item->name,':') == NULL ) - aritem=item; + } + while (item) { + if (item->handle == handle) { + if (strchr(item->name, ':') == NULL) + aritem = item; else - lastitem=item; - } - item=item->next; + lastitem = item; } + item = item->next; + } - if( aritem ) - return aritem->name; + if (aritem) + return aritem->name; - if( lastitem ) - return lastitem->name; + if (lastitem) + return lastitem->name; - return 0; + return 0; } /* @@ -646,23 +689,23 @@ _LoaderHandleToName(int handle) char * _LoaderHandleToCanonicalName(int handle) { - loaderPtr item=listHead; - loaderPtr lastitem=NULL; + loaderPtr item = listHead; + loaderPtr lastitem = NULL; - if ( handle < 0 ) { + if (handle < 0) { return "(built-in)"; - } - while(item) { - if( item->handle == handle ) { - lastitem=item; + } + while (item) { + if (item->handle == handle) { + lastitem = item; } - item=item->next; - } + item = item->next; + } - if( lastitem ) - return lastitem->cname; + if (lastitem) + return lastitem->cname; - return NULL; + return NULL; } /* @@ -673,30 +716,30 @@ _LoaderHandleToCanonicalName(int handle) char * _LoaderModuleToName(int module) { - loaderPtr item=listHead; - loaderPtr aritem=NULL; - loaderPtr lastitem=NULL; + loaderPtr item = listHead; + loaderPtr aritem = NULL; + loaderPtr lastitem = NULL; - if ( module < 0 ) { + if (module < 0) { return "(built-in)"; - } - while(item) { - if( item->module == module ) { - if( strchr(item->name,':') == NULL ) - aritem=item; + } + while (item) { + if (item->module == module) { + if (strchr(item->name, ':') == NULL) + aritem = item; else - lastitem=item; + lastitem = item; } - item=item->next; - } + item = item->next; + } - if( aritem ) - return aritem->name; + if (aritem) + return aritem->name; - if( lastitem ) - return lastitem->name; + if (lastitem) + return lastitem->name; - return 0; + return 0; } /* @@ -705,28 +748,28 @@ _LoaderModuleToName(int module) */ int _LoaderAddressToSection(const unsigned long address, const char **module, - const char ** section) + const char **section) { - loaderPtr item=listHead; + loaderPtr item = listHead; - while(item) { - if( (*section=item->funcs->AddressToSection(item->private, address)) != NULL ) { - *module=_LoaderModuleToName(item->module); - return 1; + while (item) { + if ((*section = + item->funcs->AddressToSection(item->private, address)) != NULL) { + *module = _LoaderModuleToName(item->module); + return 1; } - item=item->next; - } + item = item->next; + } - return 0; + return 0; } - /* * Add a list of symbols to the referenced list. */ static void -AppendSymbol(symlist *list, const char *sym) +AppendSymbol(symlist * list, const char *sym) { list->list = xnfrealloc(list->list, (list->num + 1) * sizeof(char **)); list->list[list->num] = sym; @@ -734,7 +777,7 @@ AppendSymbol(symlist *list, const char *sym) } static void -AppendSymList(symlist *list, const char **syms) +AppendSymList(symlist * list, const char **syms) { while (*syms) { AppendSymbol(list, *syms); @@ -743,7 +786,7 @@ AppendSymList(symlist *list, const char **syms) } static int -SymInList(symlist *list, char *sym) +SymInList(symlist * list, char *sym) { int i; @@ -760,12 +803,12 @@ LoaderVRefSymbols(const char *sym0, va_list args) const char *s; if (sym0 == NULL) - return; + return; s = sym0; do { - AppendSymbol(&refList, s); - s = va_arg(args, const char *); + AppendSymbol(&refList, s); + s = va_arg(args, const char *); } while (s != NULL); } @@ -877,112 +920,110 @@ _LoaderHandleUnresolved(char *symbol, char *module) symbol, module); } } - return(fatalsym); + return (fatalsym); } /* * Handle an archive. */ void * -ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP **ppLookup) +ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup) { loaderPtr tmp = NULL; void *ret = NULL; - unsigned char magic[SARMAG]; - struct ar_hdr hdr; + unsigned char magic[SARMAG]; + struct ar_hdr hdr; + #if defined(__powerpc__) && defined(Lynx) - struct fl_hdr fhdr; - char name[255]; - int namlen; + struct fl_hdr fhdr; + char name[255]; + int namlen; #endif - unsigned int size; - unsigned int offset; - int arnamesize, modnamesize; - char *slash, *longname; - char *nametable = NULL; - int nametablelen = 0; + unsigned int size; + unsigned int offset; + int arnamesize, modnamesize; + char *slash, *longname; + char *nametable = NULL; + int nametablelen = 0; LOOKUP *lookup_ret, *p; - LOOKUP *myLookup = NULL; /* Does realloc behave if ptr == 0? */ + LOOKUP *myLookup = NULL; /* Does realloc behave if ptr == 0? */ int modtype; int i; int numsyms = 0; - int resetoff; /* lookup_ret = xf86loadermalloc(sizeof (LOOKUP *)); */ - arnamesize=strlen(modrec->name); + arnamesize = strlen(modrec->name); #if !(defined(__powerpc__) && defined(Lynx)) - read(arfd,magic,SARMAG); + read(arfd, magic, SARMAG); - if(strncmp((const char *)magic,ARMAG,SARMAG) != 0 ) { - ErrorF("ARCHIVELoadModule: wrong magic!!\n" ); + if (strncmp((const char *)magic, ARMAG, SARMAG) != 0) { + ErrorF("ARCHIVELoadModule: wrong magic!!\n"); return NULL; } - resetoff=SARMAG; #else - read(arfd,&fhdr,FL_HSZ); + read(arfd, &fhdr, FL_HSZ); - if(strncmp(fhdr.fl_magic,AIAMAG,SAIAMAG) != 0 ) { - ErrorF("ARCHIVELoadModule: wrong magic!!\n" ); + if (strncmp(fhdr.fl_magic, AIAMAG, SAIAMAG) != 0) { + ErrorF("ARCHIVELoadModule: wrong magic!!\n"); return NULL; } - resetoff=FL_HSZ; #endif /* __powerpc__ && Lynx */ #ifdef DEBUGAR - ErrorF("Looking for archive members starting at offset %o\n", offset ); + ErrorF("Looking for archive members starting at offset %o\n", offset); #endif - while( read(arfd,&hdr,sizeof(struct ar_hdr)) ) { + while (read(arfd, &hdr, sizeof(struct ar_hdr))) { longname = NULL; - sscanf(hdr.ar_size,"%d",&size); + sscanf(hdr.ar_size, "%u", &size); #if defined(__powerpc__) && defined(Lynx) - sscanf(hdr.ar_namlen,"%d",&namlen); - name[0]=hdr.ar_name[0]; - name[1]=hdr.ar_name[1]; - read(arfd,&name[2],namlen); - name[namlen]='\0'; - offset=lseek(arfd,0,SEEK_CUR); - if( offset&0x1 ) /* odd value */ - offset=lseek(arfd,1,SEEK_CUR); /* make it an even boundary */ + sscanf(hdr.ar_namlen, "%d", &namlen); + name[0] = hdr.ar_name[0]; + name[1] = hdr.ar_name[1]; + read(arfd, &name[2], namlen); + name[namlen] = '\0'; + offset = lseek(arfd, 0, SEEK_CUR); + if (offset & 0x1) /* odd value */ + offset = lseek(arfd, 1, SEEK_CUR); /* make it an even boundary */ #endif - offset=lseek(arfd,0,SEEK_CUR); + offset = lseek(arfd, 0, SEEK_CUR); /* Check for a Symbol Table */ - if( (hdr.ar_name[0] == '/' && hdr.ar_name[1] == ' ') || + if ((hdr.ar_name[0] == '/' && hdr.ar_name[1] == ' ') || #if defined(__powerpc__) && defined(Lynx) namlen == 0 || #endif - strncmp(hdr.ar_name, "__.SYMDEF", 9) == 0 ) { + strncmp(hdr.ar_name, "__.SYMDEF", 9) == 0) { /* If the file name is NULL, then it is a symbol table */ #ifdef DEBUGAR ErrorF("Symbol Table Member '%16.16s', size %d, offset %d\n", - hdr.ar_name, size, offset ); - ErrorF("Symbol table size %d\n", size ); + hdr.ar_name, size, offset); + ErrorF("Symbol table size %d\n", size); #endif - offset=lseek(arfd,offset+size,SEEK_SET); - if( offset&0x1 ) /* odd value */ - offset=lseek(arfd,1,SEEK_CUR); /* make it an even boundary */ + offset = lseek(arfd, offset + size, SEEK_SET); + if (offset & 0x1) /* odd value */ + offset = lseek(arfd, 1, SEEK_CUR); /* make it an even boundary */ continue; } /* Check for a String Table */ - if( hdr.ar_name[0] == '/' && hdr.ar_name[1] == '/') { + if (hdr.ar_name[0] == '/' && hdr.ar_name[1] == '/') { /* If the file name is '/', then it is a string table */ #ifdef DEBUGAR ErrorF("String Table Member '%16.16s', size %d, offset %d\n", - hdr.ar_name, size, offset ); - ErrorF("String table size %d\n", size ); + hdr.ar_name, size, offset); + ErrorF("String table size %d\n", size); #endif nametablelen = size; - nametable=(char *)xf86loadermalloc(nametablelen); + nametable = (char *)xf86loadermalloc(nametablelen); read(arfd, nametable, size); - offset=lseek(arfd,0,SEEK_CUR); + offset = lseek(arfd, 0, SEEK_CUR); /* offset=lseek(arfd,offset+size,SEEK_SET); */ - if( offset&0x1 ) /* odd value */ - offset=lseek(arfd,1,SEEK_CUR); /* make it an even boundary */ + if (offset & 0x1) /* odd value */ + offset = lseek(arfd, 1, SEEK_CUR); /* make it an even boundary */ continue; } @@ -990,50 +1031,50 @@ ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP **ppLookup) /* SYS V r4 style long member name */ int nameoffset = atol(&hdr.ar_name[1]); char *membername; + if (!nametable) { - ErrorF( "Missing string table whilst processing %s\n", - modrec->name ) ; + ErrorF("Missing string table whilst processing %s\n", + modrec->name); offsetbias = 0; return NULL; } if (nameoffset > nametablelen) { - ErrorF( "Invalid string table offset (%s) whilst processing %s\n", - hdr.ar_name, modrec->name ) ; + ErrorF("Invalid string table offset (%s) whilst processing %s\n", hdr.ar_name, modrec->name); offsetbias = 0; xf86loaderfree(nametable); return NULL; } membername = nametable + nameoffset; - slash=strchr(membername,'/'); + slash = strchr(membername, '/'); if (slash) *slash = '\0'; longname = xf86loadermalloc(arnamesize + strlen(membername) + 2); - strcpy(longname,modrec->name); - strcat(longname,":"); - strcat(longname,membername); + strcpy(longname, modrec->name); + strcat(longname, ":"); + strcat(longname, membername); } else if (hdr.ar_name[0] == '#' && hdr.ar_name[1] == '1' && hdr.ar_name[2] == '/') { /* BSD 4.4 style long member name */ - if (sscanf(hdr.ar_name+3, "%d", &modnamesize) != 1) { + if (sscanf(hdr.ar_name + 3, "%d", &modnamesize) != 1) { ErrorF("Bad archive member %s\n", hdr.ar_name); offsetbias = 0; return NULL; } /* allocate space for fully qualified name */ longname = xf86loadermalloc(arnamesize + modnamesize + 2); - strcpy(longname,modrec->name); - strcat(longname,":"); - i = read(arfd, longname+modnamesize+1, modnamesize); + strcpy(longname, modrec->name); + strcat(longname, ":"); + i = read(arfd, longname + modnamesize + 1, modnamesize); if (i != modnamesize) { - ErrorF("Bad archive member %d\n", hdr.ar_name); + ErrorF("Bad archive member %s\n", hdr.ar_name); xf86loaderfree(longname); offsetbias = 0; return NULL; - } + } longname[i] = '\0'; offset += i; size -= i; - } else { + } else { /* Regular archive member */ #ifdef DEBUGAR ErrorF("Member '%16.16s', size %d, offset %x\n", @@ -1042,87 +1083,85 @@ ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP **ppLookup) #else name, #endif - size, offset ); + size, offset); #endif - slash=strchr(hdr.ar_name,'/'); + slash = strchr(hdr.ar_name, '/'); if (slash == NULL) { /* BSD format without trailing slash */ - slash = strchr(hdr.ar_name,' '); - } + slash = strchr(hdr.ar_name, ' '); + } /* SM: Make sure we do not overwrite other parts of struct */ - - if((slash - hdr.ar_name) > sizeof(hdr.ar_name)) - slash = hdr.ar_name + sizeof(hdr.ar_name) -1; - *slash='\000'; + + if ((slash - hdr.ar_name) > sizeof(hdr.ar_name)) + slash = hdr.ar_name + sizeof(hdr.ar_name) - 1; + *slash = '\000'; } - if( (modtype=_GetModuleType(arfd,offset)) < 0 ) { - ErrorF( "%s is an unrecognized module type\n", hdr.ar_name ) ; - offsetbias=0; + if ((modtype = _GetModuleType(arfd, offset)) < 0) { + ErrorF("%s is an unrecognized module type\n", hdr.ar_name); + offsetbias = 0; if (nametable) xf86loaderfree(nametable); return NULL; } - tmp=_LoaderListPush(); + tmp = _LoaderListPush(); tmp->handle = modrec->handle; tmp->module = moduleseq++; tmp->cname = xf86loadermalloc(strlen(modrec->cname) + 1); strcpy(tmp->cname, modrec->cname); - tmp->funcs=&funcs[modtype]; + tmp->funcs = &funcs[modtype]; if (longname == NULL) { - modnamesize=strlen(hdr.ar_name); - tmp->name=(char *)xf86loadermalloc(arnamesize+modnamesize+2 ); - strcpy(tmp->name,modrec->name); - strcat(tmp->name,":"); - strcat(tmp->name,hdr.ar_name); - + modnamesize = strlen(hdr.ar_name); + tmp->name = + (char *)xf86loadermalloc(arnamesize + modnamesize + 2); + strcpy(tmp->name, modrec->name); + strcat(tmp->name, ":"); + strcat(tmp->name, hdr.ar_name); + } else { tmp->name = longname; } - offsetbias=offset; + offsetbias = offset; - if((tmp->private = funcs[modtype].LoadModule(tmp, arfd, - &lookup_ret)) - == NULL) { - ErrorF( "Failed to load %s\n", hdr.ar_name ) ; - offsetbias=0; + if ((tmp->private = funcs[modtype].LoadModule(tmp, arfd, &lookup_ret)) + == NULL) { + ErrorF("Failed to load %s\n", hdr.ar_name); + offsetbias = 0; if (nametable) xf86loaderfree(nametable); return NULL; } - offset=lseek(arfd,offset+size,SEEK_SET); - if( offset&0x1 ) /* odd value */ - lseek(arfd,1,SEEK_CUR); /* make it an even boundary */ + offset = lseek(arfd, offset + size, SEEK_SET); + if (offset & 0x1) /* odd value */ + lseek(arfd, 1, SEEK_CUR); /* make it an even boundary */ - if (tmp->private == (void *) -1L) { + if (tmp->private == (void *)-1L) { ErrorF("Skipping \"%s\": No symbols found\n", tmp->name); continue; - } - else + } else ret = tmp->private; /* Add the lookup table returned from funcs.LoadModule to the * one we're going to return. */ - for (i = 0, p = lookup_ret; p && p->symName; i++, p++) - ; + for (i = 0, p = lookup_ret; p && p->symName; i++, p++) ; if (i) { myLookup = xf86loaderrealloc(myLookup, (numsyms + i + 1) - * sizeof (LOOKUP)); + * sizeof(LOOKUP)); if (!myLookup) - continue; /* Oh well! */ + continue; /* Oh well! */ - memcpy(&(myLookup[numsyms]), lookup_ret, i * sizeof (LOOKUP)); + memcpy(&(myLookup[numsyms]), lookup_ret, i * sizeof(LOOKUP)); numsyms += i; myLookup[numsyms].symName = 0; } xf86loaderfree(lookup_ret); } /* xf86loaderfree(lookup_ret); */ - offsetbias=0; + offsetbias = 0; *ppLookup = myLookup; if (nametable) @@ -1141,9 +1180,9 @@ ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP **ppLookup) LoaderRelocPtr _LoaderGetRelocations(void *mod) { - loader_funcs *formatrec = (loader_funcs *)mod; + loader_funcs *formatrec = (loader_funcs *) mod; - return &(formatrec->pRelocs); + return &(formatrec->pRelocs); } /* @@ -1154,13 +1193,13 @@ int LoaderOpen(const char *module, const char *cname, int handle, int *errmaj, int *errmin, int *wasLoaded) { - loaderPtr tmp ; - int new_handle, modtype ; + loaderPtr tmp; + int new_handle, modtype; int fd; LOOKUP *pLookup; #if defined(DEBUG) - ErrorF("LoaderOpen(%s)\n", module ); + ErrorF("LoaderOpen(%s)\n", module); #endif /* @@ -1171,26 +1210,26 @@ LoaderOpen(const char *module, const char *cname, int handle, */ if (handle >= 0) { tmp = listHead; - while ( tmp ) { + while (tmp) { #ifdef DEBUGLIST - ErrorF("strcmp(%x(%s),{%x} %x(%s))\n", module,module,&(tmp->name), - tmp->name,tmp->name ); + ErrorF("strcmp(%x(%s),{%x} %x(%s))\n", module, module, + &(tmp->name), tmp->name, tmp->name); #endif - if ( ! strcmp( module, tmp->name )) { + if (!strcmp(module, tmp->name)) { refCount[tmp->handle]++; if (wasLoaded) *wasLoaded = 1; xf86MsgVerb(X_INFO, 2, "Reloading %s\n", module); return tmp->handle; } - tmp = tmp->next ; + tmp = tmp->next; } } /* * OK, it's a new one. Add it. */ - xf86Msg(X_INFO, "Loading %s\n", module ) ; + xf86Msg(X_INFO, "Loading %s\n", module); if (wasLoaded) *wasLoaded = 0; @@ -1198,54 +1237,62 @@ LoaderOpen(const char *module, const char *cname, int handle, * Find a free handle. */ new_handle = 1; - while ( freeHandles[new_handle] && new_handle < MAX_HANDLE ) - new_handle ++ ; - - if ( new_handle == MAX_HANDLE ) { - xf86Msg(X_ERROR, "Out of loader space\n" ) ; /* XXX */ - if(errmaj) *errmaj = LDR_NOSPACE; - if(errmin) *errmin = LDR_NOSPACE; - return -1 ; + while (freeHandles[new_handle] && new_handle < MAX_HANDLE) + new_handle++; + + if (new_handle == MAX_HANDLE) { + xf86Msg(X_ERROR, "Out of loader space\n"); /* XXX */ + if (errmaj) + *errmaj = LDR_NOSPACE; + if (errmin) + *errmin = LDR_NOSPACE; + return -1; } - freeHandles[new_handle] = HANDLE_USED ; + freeHandles[new_handle] = HANDLE_USED; refCount[new_handle] = 1; - if( (fd=open(module, O_RDONLY)) < 0 ) { - xf86Msg(X_ERROR, "Unable to open %s\n", module ); - freeHandles[new_handle] = HANDLE_FREE ; - if(errmaj) *errmaj = LDR_NOMODOPEN; - if(errmin) *errmin = errno; - return -1 ; + if ((fd = open(module, O_RDONLY)) < 0) { + xf86Msg(X_ERROR, "Unable to open %s\n", module); + freeHandles[new_handle] = HANDLE_FREE; + if (errmaj) + *errmaj = LDR_NOMODOPEN; + if (errmin) + *errmin = errno; + return -1; } - if( (modtype=_GetModuleType(fd,0)) < 0 ) { - xf86Msg(X_ERROR, "%s is an unrecognized module type\n", module ) ; - freeHandles[new_handle] = HANDLE_FREE ; - if(errmaj) *errmaj = LDR_UNKTYPE; - if(errmin) *errmin = LDR_UNKTYPE; + if ((modtype = _GetModuleType(fd, 0)) < 0) { + xf86Msg(X_ERROR, "%s is an unrecognized module type\n", module); + freeHandles[new_handle] = HANDLE_FREE; + if (errmaj) + *errmaj = LDR_UNKTYPE; + if (errmin) + *errmin = LDR_UNKTYPE; return -1; } - tmp=_LoaderListPush(); + tmp = _LoaderListPush(); tmp->name = xf86loadermalloc(strlen(module) + 1); strcpy(tmp->name, module); tmp->cname = xf86loadermalloc(strlen(cname) + 1); strcpy(tmp->cname, cname); tmp->handle = new_handle; tmp->module = moduleseq++; - tmp->funcs=&funcs[modtype]; + tmp->funcs = &funcs[modtype]; - if((tmp->private = funcs[modtype].LoadModule(tmp,fd, &pLookup)) == NULL) { - xf86Msg(X_ERROR, "Failed to load %s\n", module ) ; + if ((tmp->private = funcs[modtype].LoadModule(tmp, fd, &pLookup)) == NULL) { + xf86Msg(X_ERROR, "Failed to load %s\n", module); _LoaderListPop(new_handle); - freeHandles[new_handle] = HANDLE_FREE ; - if(errmaj) *errmaj = LDR_NOLOAD; - if(errmin) *errmin = LDR_NOLOAD; + freeHandles[new_handle] = HANDLE_FREE; + if (errmaj) + *errmaj = LDR_NOLOAD; + if (errmin) + *errmin = LDR_NOLOAD; return -1; } - if (tmp->private != (void *) -1L) { + if (tmp->private != (void *)-1L) { LoaderAddSymbols(new_handle, tmp->module, pLookup); xf86loaderfree(pLookup); } @@ -1273,16 +1320,17 @@ LoaderSymbol(const char *sym) { int i; itemPtr item = NULL; + for (i = 0; i < numloaders; i++) funcs[i].ResolveSymbols(&funcs[i]); item = (itemPtr) LoaderHashFind(sym); - if ( item ) - return item->address ; + if (item) + return item->address; else #ifdef DLOPEN_SUPPORT - return(DLFindSymbol(sym)); + return (DLFindSymbol(sym)); #else return NULL; #endif @@ -1292,36 +1340,37 @@ int LoaderResolveSymbols(void) { int i; - for(i=0;i<numloaders;i++) + + for (i = 0; i < numloaders; i++) funcs[i].ResolveSymbols(&funcs[i]); return 0; } int -LoaderCheckUnresolved(int delay_flag ) +LoaderCheckUnresolved(int delay_flag) { - int i,ret=0; - LoaderResolveOptions delayFlag = delay_flag; + int i, ret = 0; + LoaderResolveOptions delayFlag = (LoaderResolveOptions)delay_flag; - LoaderResolveSymbols(); + LoaderResolveSymbols(); - if (delayFlag == LD_RESOLV_NOW) { - if (check_unresolved_sema > 0) - check_unresolved_sema--; - else - xf86Msg(X_WARNING, "LoaderCheckUnresolved: not enough " - "MAGIC_DONT_CHECK_UNRESOLVED\n"); - } + if (delayFlag == LD_RESOLV_NOW) { + if (check_unresolved_sema > 0) + check_unresolved_sema--; + else + xf86Msg(X_WARNING, "LoaderCheckUnresolved: not enough " + "MAGIC_DONT_CHECK_UNRESOLVED\n"); + } - if (!check_unresolved_sema || delayFlag == LD_RESOLV_FORCE) - for(i=0;i<numloaders;i++) - if (funcs[i].CheckForUnresolved(&funcs[i])) - ret=1; + if (!check_unresolved_sema || delayFlag == LD_RESOLV_FORCE) + for (i = 0; i < numloaders; i++) + if (funcs[i].CheckForUnresolved(&funcs[i])) + ret = 1; - if (fatalReqSym) - FatalError("Some required symbols were unresolved\n"); + if (fatalReqSym) + FatalError("Some required symbols were unresolved\n"); - return ret; + return ret; } void xf86LoaderTrap(void); @@ -1334,59 +1383,60 @@ xf86LoaderTrap(void) void LoaderDefaultFunc(void) { - ErrorF("\n\n\tThis should not happen!\n" - "\tAn unresolved function was called!\n"); + ErrorF("\n\n\tThis should not happen!\n" + "\tAn unresolved function was called!\n"); - xf86LoaderTrap(); - - FatalError("\n"); + xf86LoaderTrap(); + + FatalError("\n"); } int LoaderUnload(int handle) { - loaderRec fakeHead ; - loaderPtr tmp = & fakeHead ; + loaderRec fakeHead; + loaderPtr tmp = &fakeHead; - if ( handle < 0 || handle > MAX_HANDLE ) + if (handle < 0 || handle > MAX_HANDLE) return -1; - /* - * check the reference count, only free it if it goes to zero - */ - if (--refCount[handle]) + /* + * check the reference count, only free it if it goes to zero + */ + if (--refCount[handle]) return 0; - /* - * find the loaderRecs associated with this handle. - */ - - while( (tmp=_LoaderListPop(handle)) != NULL ) { - if( strchr(tmp->name,':') == NULL ) { - /* It is not a member of an archive */ - xf86Msg(X_INFO, "Unloading %s\n", tmp->name ) ; + /* + * find the loaderRecs associated with this handle. + */ + + while ((tmp = _LoaderListPop(handle)) != NULL) { + if (strchr(tmp->name, ':') == NULL) { + /* It is not a member of an archive */ + xf86Msg(X_INFO, "Unloading %s\n", tmp->name); } tmp->funcs->LoaderUnload(tmp->private); xf86loaderfree(tmp->name); xf86loaderfree(tmp->cname); xf86loaderfree(tmp); - } - - freeHandles[handle] = HANDLE_FREE ; + } + + freeHandles[handle] = HANDLE_FREE; -return 0; + return 0; } void LoaderDuplicateSymbol(const char *symbol, const int handle) { ErrorF("Duplicate symbol %s in %s\n", symbol, - listHead ? listHead->name : "(built-in)"); + listHead ? listHead->name : "(built-in)"); ErrorF("Also defined in %s\n", _LoaderHandleToName(handle)); FatalError("Module load failure\n"); } /* GDB Sync function */ -void _loader_debug_state() +void +_loader_debug_state() { } @@ -1395,18 +1445,17 @@ unsigned long LoaderOptions = 0; void LoaderResetOptions(void) { - LoaderOptions = 0; + LoaderOptions = 0; } void LoaderSetOptions(unsigned long opts) { - LoaderOptions |= opts; + LoaderOptions |= opts; } void LoaderClearOptions(unsigned long opts) { - LoaderOptions &= ~opts; + LoaderOptions &= ~opts; } - diff --git a/hw/xfree86/loader/loader.h b/hw/xfree86/loader/loader.h index a814544b8..f48aadb02 100644 --- a/hw/xfree86/loader/loader.h +++ b/hw/xfree86/loader/loader.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.h,v 1.25 2001/02/22 23:17:09 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.h,v 1.28 2003/11/06 18:38:14 tsi Exp $ */ /* * @@ -22,6 +22,33 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ +/* + * Copyright (c) 1997-2001 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + #ifndef _LOADER_H #define _LOADER_H @@ -30,18 +57,14 @@ #if defined(Lynx) && defined(sun) #define const /**/ #endif - #if (defined(__i386__) || defined(__ix86)) && !defined(i386) #define i386 #endif - #include <X11/Xosdefs.h> #include <X11/Xfuncproto.h> #include <X11/Xmd.h> - /* For LOOKUP definition */ #include "sym.h" - #define LD_UNKNOWN -1 #define LD_ARCHIVE 0 #define LD_ELFOBJECT 1 @@ -50,12 +73,9 @@ #define LD_AOUTOBJECT 4 #define LD_AOUTDLOBJECT 5 #define LD_ELFDLOBJECT 6 - #define LD_PROCESSED_ARCHIVE -1 - /* #define UNINIT_SECTION */ #define HANDLE_IN_HASH_ENTRY - /* * COFF Section nmumbers */ @@ -63,18 +83,15 @@ #define N_DATA 2 #define N_BSS 3 #define N_COMMENT 4 - #define TestFree(a) if (a) { xfree (a); a = NULL; } - #define HASHDIV 10 #define HASHSIZE (1<<HASHDIV) - -typedef struct _elf_reloc *ELFRelocPtr; -typedef struct _elf_COMMON *ELFCommonPtr; -typedef struct _coff_reloc *COFFRelocPtr; +typedef struct _elf_reloc *ELFRelocPtr; +typedef struct _elf_COMMON *ELFCommonPtr; +typedef struct _coff_reloc *COFFRelocPtr; typedef struct _coff_COMMON *COFFCommonPtr; -typedef struct AOUT_RELOC *AOUTRelocPtr; -typedef struct AOUT_COMMON *AOUTCommonPtr; +typedef struct AOUT_RELOC *AOUTRelocPtr; +typedef struct AOUT_COMMON *AOUTCommonPtr; typedef struct _LoaderReloc { int modtype; @@ -86,52 +103,52 @@ typedef struct _LoaderReloc { typedef struct _loader_item *itemPtr; typedef struct _loader_item { - char *name ; - void *address ; - itemPtr next ; - int handle ; - int module ; - itemPtr exports; + char *name; + void *address; + itemPtr next; + int handle; + int module; + itemPtr exports; #if defined(__powerpc__) - /* - * PowerPC file formats require special routines in some circumstances - * to assist in the linking process. See the specific loader for - * more details. - */ - union { - unsigned short plt[8]; /* ELF */ - unsigned short glink[14]; /* XCOFF */ - } code ; + /* + * PowerPC file formats require special routines in some circumstances + * to assist in the linking process. See the specific loader for + * more details. + */ + union { + unsigned short plt[8]; /* ELF */ + unsigned short glink[14]; /* XCOFF */ + } code; #endif - } itemRec ; +} itemRec; /* The following structures provide an interface to GDB (note that GDB has copies of the definitions - if you change anything here make sure that the changes are also made to GDB */ -typedef struct { - char *name; /* Name of this symbol */ - unsigned int namelen; /* Name of this module */ - void *addr; /* Start address of the .text section */ +typedef struct { + char *name; /* Name of this symbol */ + unsigned int namelen; /* Name of this module */ + void *addr; /* Start address of the .text section */ } LDRCommon, *LDRCommonPtr; -typedef struct x_LDRModuleRec{ - unsigned int version; /* Version of this struct */ - char *name; /* Name of this module */ - unsigned int namelen; /* Length of name */ - void *text; /* Start address of the .text section */ - void *data; /* Start address of the .data section */ - void *rodata; /* Start address of the .rodata section */ - void *bss; /* Start address of the .bss section */ - LDRCommonPtr commons; /* List of commmon symbols */ - int commonslen; /* Number of common symbols */ - struct x_LDRModuleRec *next; /* Next module record in chain */ +typedef struct x_LDRModuleRec { + unsigned int version; /* Version of this struct */ + char *name; /* Name of this module */ + unsigned int namelen; /* Length of name */ + void *text; /* Start address of the .text section */ + void *data; /* Start address of the .data section */ + void *rodata; /* Start address of the .rodata section */ + void *bss; /* Start address of the .bss section */ + LDRCommonPtr commons; /* List of commmon symbols */ + int commonslen; /* Number of common symbols */ + struct x_LDRModuleRec *next; /* Next module record in chain */ } LDRModuleRec, *LDRModulePtr; -extern char DebuggerPresent; -extern LDRModulePtr ModList; -extern LDRCommonPtr ldrCommons; -extern int nCommons; +extern char DebuggerPresent; +extern LDRModulePtr ModList; +extern LDRCommonPtr ldrCommons; +extern int nCommons; /* * The loader uses loader specific alloc/calloc/free functions that @@ -172,41 +189,41 @@ typedef struct _loader *loaderPtr; * _loader_funcs hold the entry points for a module format. */ -typedef void * (*LoadModuleProcPtr)(loaderPtr modrec, int fd, LOOKUP **); -typedef void (*ResolveSymbolsProcPtr)(void *); -typedef int (*CheckForUnresolvedProcPtr)(void *); -typedef char * (*AddressToSectionProcPtr)(void *, unsigned long); -typedef void (*LoaderUnloadProcPtr)(void *); +typedef void *(*LoadModuleProcPtr) (loaderPtr modrec, int fd, LOOKUP **); +typedef void (*ResolveSymbolsProcPtr) (void *); +typedef int (*CheckForUnresolvedProcPtr) (void *); +typedef char *(*AddressToSectionProcPtr) (void *, unsigned long); +typedef void (*LoaderUnloadProcPtr) (void *); typedef struct _loader_funcs { - LoadModuleProcPtr LoadModule; - ResolveSymbolsProcPtr ResolveSymbols; - CheckForUnresolvedProcPtr CheckForUnresolved; - AddressToSectionProcPtr AddressToSection; - LoaderUnloadProcPtr LoaderUnload; - LoaderRelocRec pRelocs; /* type specific relocations */ + LoadModuleProcPtr LoadModule; + ResolveSymbolsProcPtr ResolveSymbols; + CheckForUnresolvedProcPtr CheckForUnresolved; + AddressToSectionProcPtr AddressToSection; + LoaderUnloadProcPtr LoaderUnload; + LoaderRelocRec pRelocs; /* type specific relocations */ } loader_funcs; /* Each module loaded has a loaderRec */ typedef struct _loader { - int handle; /* Unique id used to remove symbols from - this module when it is unloaded */ - int module; /* Unique id to identify compilation units */ - char *name; - char *cname; - void *private; /* format specific data */ - loader_funcs *funcs; /* funcs for operating on this module */ - loaderPtr next; + int handle; /* Unique id used to remove symbols from + * this module when it is unloaded */ + int module; /* Unique id to identify compilation units */ + char *name; + char *cname; + void *private; /* format specific data */ + loader_funcs *funcs; /* funcs for operating on this module */ + loaderPtr next; } loaderRec; /* Compiled-in version information */ typedef struct { - INT32 xf86Version; - INT32 ansicVersion; - INT32 videodrvVersion; - INT32 xinputVersion; - INT32 extensionVersion; - INT32 fontVersion; + int xf86Version; + int ansicVersion; + int videodrvVersion; + int xinputVersion; + int extensionVersion; + int fontVersion; } ModuleVersions; extern ModuleVersions LoaderVersionInfo; @@ -217,6 +234,7 @@ extern unsigned long LoaderOptions; void LoaderAddSymbols(int, int, LOOKUP *); void LoaderDefaultFunc(void); void LoaderDuplicateSymbol(const char *, const int); + #if 0 void LoaderFixups(void); #endif @@ -232,7 +250,8 @@ void LoaderPrintItem(itemPtr); void LoaderPrintSymbol(unsigned long); void LoaderDumpSymbols(void); char *_LoaderModuleToName(int); -int _LoaderAddressToSection(const unsigned long, const char **, const char **); +int _LoaderAddressToSection(const unsigned long, const char **, + const char **); int LoaderOpen(const char *, const char *, int, int *, int *, int *); int LoaderHandleOpen(int); @@ -251,8 +270,8 @@ LoaderRelocPtr _LoaderGetRelocations(void *); /* * object to name lookup routines */ -char * _LoaderHandleToName(int handle); -char * _LoaderHandleToCanonicalName(int handle); +char *_LoaderHandleToName(int handle); +char *_LoaderHandleToCanonicalName(int handle); /* * Entry points for the different loader types diff --git a/hw/xfree86/loader/loaderProcs.h b/hw/xfree86/loader/loaderProcs.h index ff6c64b07..d2779812f 100644 --- a/hw/xfree86/loader/loaderProcs.h +++ b/hw/xfree86/loader/loaderProcs.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h,v 1.19 2002/07/30 18:36:18 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h,v 1.21 2003/10/15 16:29:04 dawes Exp $ */ /* * @@ -22,6 +22,32 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ #ifndef _LOADERPROCS_H #define _LOADERPROCS_H @@ -31,24 +57,23 @@ #include "fontmod.h" typedef struct module_desc { - struct module_desc *child; - struct module_desc *sib; - struct module_desc *parent; - struct module_desc *demand_next; - char *name; - char *filename; - char *identifier; - XID client_id; - int in_use; - int handle; - ModuleSetupProc SetupProc; - ModuleTearDownProc TearDownProc; - void *TearDownData; /* returned from SetupProc */ - const char *path; - const XF86ModuleVersionInfo *VersionInfo; + struct module_desc *child; + struct module_desc *sib; + struct module_desc *parent; + struct module_desc *demand_next; + char *name; + char *filename; + char *identifier; + XID client_id; + int in_use; + int handle; + ModuleSetupProc SetupProc; + ModuleTearDownProc TearDownProc; + void *TearDownData; /* returned from SetupProc */ + const char *path; + const XF86ModuleVersionInfo *VersionInfo; } ModuleDesc, *ModuleDescPtr; - /* * Extenal API for the loader */ @@ -64,17 +89,16 @@ ModuleDescPtr LoadSubModule(ModuleDescPtr, const char *, const char **, const char **, pointer, const XF86ModReqInfo *, int *, int *); ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent); -void LoadFont (FontModule *); -void UnloadModule (ModuleDescPtr); -void UnloadSubModule (ModuleDescPtr); -void UnloadDriver (ModuleDescPtr); -void FreeModuleDesc (ModuleDescPtr mod); -ModuleDescPtr NewModuleDesc (const char *); -ModuleDescPtr AddSibling (ModuleDescPtr head, ModuleDescPtr new); +void LoadFont(FontModule *); +void UnloadModule(ModuleDescPtr); +void UnloadSubModule(ModuleDescPtr); +void UnloadDriver(ModuleDescPtr); +void FreeModuleDesc(ModuleDescPtr mod); +ModuleDescPtr NewModuleDesc(const char *); +ModuleDescPtr AddSibling(ModuleDescPtr head, ModuleDescPtr new); void LoaderSetPath(const char *path); void LoaderSortExtensions(void); - void LoaderVReqSymLists(const char **, va_list args); void LoaderVReqSymbols(const char *, va_list args); void LoaderVRefSymLists(const char **, va_list args); @@ -92,5 +116,4 @@ void LoaderClearOptions(unsigned long); /* Options for LoaderSetOptions */ #define LDR_OPT_ABI_MISMATCH_NONFATAL 0x0001 - #endif /* _LOADERPROCS_H */ diff --git a/hw/xfree86/loader/loadext.c b/hw/xfree86/loader/loadext.c index 206c8296a..ffc98b243 100644 --- a/hw/xfree86/loader/loadext.c +++ b/hw/xfree86/loader/loadext.c @@ -1,6 +1,30 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadext.c,v 1.6 2000/02/08 17:19:19 dawes Exp $ */ - -/* Copyright 2000 by The XFree86 Project, Inc */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadext.c,v 1.8 2003/10/15 16:29:04 dawes Exp $ */ +/* + * Copyright (c) 2000 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ /* Maybe this file belongs elsewhere? */ @@ -12,58 +36,56 @@ ExtensionModule *ExtensionModuleList = NULL; static int numExtensionModules = 0; - static ExtensionModule * NewExtensionModule(void) { - ExtensionModule *save = ExtensionModuleList; - int n; - - /* Sanity check */ - if (!ExtensionModuleList) - numExtensionModules = 0; - - n = numExtensionModules + 1; - ExtensionModuleList = xrealloc(ExtensionModuleList, - (n + 1) * sizeof(ExtensionModule)); - if (ExtensionModuleList == NULL) { - ExtensionModuleList = save; - return NULL; - } else { - numExtensionModules++; - ExtensionModuleList[numExtensionModules].name = NULL; - return ExtensionModuleList + (numExtensionModules - 1); - } + ExtensionModule *save = ExtensionModuleList; + int n; + + /* Sanity check */ + if (!ExtensionModuleList) + numExtensionModules = 0; + + n = numExtensionModules + 1; + ExtensionModuleList = xrealloc(ExtensionModuleList, + (n + 1) * sizeof(ExtensionModule)); + if (ExtensionModuleList == NULL) { + ExtensionModuleList = save; + return NULL; + } else { + numExtensionModules++; + ExtensionModuleList[numExtensionModules].name = NULL; + return ExtensionModuleList + (numExtensionModules - 1); + } } void -LoadExtension(ExtensionModule *e, Bool builtin) +LoadExtension(ExtensionModule * e, Bool builtin) { - ExtensionModule *newext; + ExtensionModule *newext; - if (e == NULL || e->name == NULL) - return; + if (e == NULL || e->name == NULL) + return; - if (!(newext = NewExtensionModule())) - return; + if (!(newext = NewExtensionModule())) + return; - if (builtin) - xf86MsgVerb(X_INFO, 2, "Initializing built-in extension %s\n", - e->name); - else - xf86MsgVerb(X_INFO, 2, "Loading extension %s\n", e->name); + if (builtin) + xf86MsgVerb(X_INFO, 2, "Initializing built-in extension %s\n", + e->name); + else + xf86MsgVerb(X_INFO, 2, "Loading extension %s\n", e->name); - newext->name = e->name; - newext->initFunc = e->initFunc; - newext->disablePtr = e->disablePtr; - newext->setupFunc = e->setupFunc; - newext->initDependencies = e->initDependencies; + newext->name = e->name; + newext->initFunc = e->initFunc; + newext->disablePtr = e->disablePtr; + newext->setupFunc = e->setupFunc; + newext->initDependencies = e->initDependencies; - if (e->setupFunc != NULL) - e->setupFunc(); + if (e->setupFunc != NULL) + e->setupFunc(); } - /* * Sort ExtensionModuleList according to the initialisation order * dependencies. The code for this is taken from BSD's tsort, @@ -105,21 +127,20 @@ LoadExtension(ExtensionModule *e, Bool builtin) * SUCH DAMAGE. */ - -#define NF_MARK 0x1 /* marker for cycle detection */ -#define NF_ACYCLIC 0x2 /* this node is cycle free */ -#define NF_NODEST 0x4 /* Unreachable */ +#define NF_MARK 0x1 /* marker for cycle detection */ +#define NF_ACYCLIC 0x2 /* this node is cycle free */ +#define NF_NODEST 0x4 /* Unreachable */ typedef struct node_str NODE; struct node_str { - NODE **n_prevp; /* pointer to previous node's n_next */ - NODE *n_next; /* next node in graph */ - NODE **n_arcs; /* array of arcs to other nodes */ - int n_narcs; /* number of arcs in n_arcs[] */ - int n_arcsize; /* size of n_arcs[] array */ - int n_refcnt; /* # of arcs pointing to this node */ - int n_flags; /* NF_* */ - const char *n_name; /* name of this node */ + NODE **n_prevp; /* pointer to previous node's n_next */ + NODE *n_next; /* next node in graph */ + NODE **n_arcs; /* array of arcs to other nodes */ + int n_narcs; /* number of arcs in n_arcs[] */ + int n_arcsize; /* size of n_arcs[] array */ + int n_refcnt; /* # of arcs pointing to this node */ + int n_flags; /* NF_* */ + const char *n_name; /* name of this node */ }; static NODE *graph = NULL, **cycle_buf = NULL, **longest_cycle = NULL; @@ -130,32 +151,31 @@ static NODE *sorted = NULL, *last = NULL; static NODE * get_node(const char *name) { - NODE *n; + NODE *n; - for (n = graph; n && n->n_name && strcmp(n->n_name, name); n = n->n_next) - ; - if (n) - return (n); + for (n = graph; n && n->n_name && strcmp(n->n_name, name); + n = n->n_next) ; + if (n) + return (n); - n = xnfalloc(sizeof(NODE)); + n = xnfalloc(sizeof(NODE)); - n->n_narcs = 0; - n->n_arcsize = 0; - n->n_arcs = NULL; - n->n_refcnt = 0; - n->n_flags = 0; - n->n_name = name; + n->n_narcs = 0; + n->n_arcsize = 0; + n->n_arcs = NULL; + n->n_refcnt = 0; + n->n_flags = 0; + n->n_name = name; - /* Add to linked list. */ - if ((n->n_next = graph) != NULL) - graph->n_prevp = &n->n_next; - n->n_prevp = &graph; - graph = n; + /* Add to linked list. */ + if ((n->n_next = graph) != NULL) + graph->n_prevp = &n->n_next; + n->n_prevp = &graph; + graph = n; - return (n); + return (n); } - /* * add an arc from node s1 to node s2 in the graph. If s1 or s2 are not in * the graph, then add them. @@ -163,35 +183,35 @@ get_node(const char *name) static void add_arc(const char *s1, const char *s2) { - NODE *n1; - NODE *n2; - int bsize, i; - - n1 = get_node(s1); - - if (!strcmp(s1, s2)) - return; - - n2 = get_node(s2); - - /* - * Check if this arc is already here. - */ - for (i = 0; i < n1->n_narcs; i++) - if (n1->n_arcs[i] == n2) - return; - /* - * Add it. - */ - if (n1->n_narcs == n1->n_arcsize) { - if (!n1->n_arcsize) - n1->n_arcsize = 10; - bsize = n1->n_arcsize * sizeof(*n1->n_arcs) * 2; - n1->n_arcs = xnfrealloc(n1->n_arcs, bsize); - n1->n_arcsize = bsize / sizeof(*n1->n_arcs); - } - n1->n_arcs[n1->n_narcs++] = n2; - ++n2->n_refcnt; + NODE *n1; + NODE *n2; + int bsize, i; + + n1 = get_node(s1); + + if (!strcmp(s1, s2)) + return; + + n2 = get_node(s2); + + /* + * Check if this arc is already here. + */ + for (i = 0; i < n1->n_narcs; i++) + if (n1->n_arcs[i] == n2) + return; + /* + * Add it. + */ + if (n1->n_narcs == n1->n_arcsize) { + if (!n1->n_arcsize) + n1->n_arcsize = 10; + bsize = n1->n_arcsize * sizeof(*n1->n_arcs) * 2; + n1->n_arcs = xnfrealloc(n1->n_arcs, bsize); + n1->n_arcsize = bsize / sizeof(*n1->n_arcs); + } + n1->n_arcs[n1->n_narcs++] = n2; + ++n2->n_refcnt; } /* @@ -200,220 +220,214 @@ add_arc(const char *s1, const char *s2) static void clear_cycle(void) { - NODE *n; + NODE *n; - for (n = graph; n != NULL; n = n->n_next) - n->n_flags &= ~NF_NODEST; + for (n = graph; n != NULL; n = n->n_next) + n->n_flags &= ~NF_NODEST; } /* print node and remove from graph (does not actually free node) */ static void -remove_node(NODE *n) +remove_node(NODE * n) { - NODE **np; - NODE *newnode; - int i; + NODE **np; + NODE *newnode; + int i; #ifdef DEBUG - ErrorF("%s\n", n->n_name); + ErrorF("%s\n", n->n_name); #endif - newnode = xnfalloc(sizeof(NODE)); - memcpy(newnode, n, sizeof(NODE)); - if (last) - last->n_next = newnode; - else - sorted = newnode; - last = newnode; - newnode->n_next = NULL; - - for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++) - --(*np)->n_refcnt; - n->n_narcs = 0; - *n->n_prevp = n->n_next; - if (n->n_next) - n->n_next->n_prevp = n->n_prevp; + newnode = xnfalloc(sizeof(NODE)); + memcpy(newnode, n, sizeof(NODE)); + if (last) + last->n_next = newnode; + else + sorted = newnode; + last = newnode; + newnode->n_next = NULL; + + for (np = n->n_arcs, i = n->n_narcs; --i >= 0; np++) + --(*np)->n_refcnt; + n->n_narcs = 0; + *n->n_prevp = n->n_next; + if (n->n_next) + n->n_next->n_prevp = n->n_prevp; } - static void -free_nodes(NODE *nodelist) +free_nodes(NODE * nodelist) { - NODE *n, *nextnode; + NODE *n, *nextnode; - for (n = nodelist; n;) { - nextnode = n->n_next; - xfree(n); - n = nextnode; - } + for (n = nodelist; n;) { + nextnode = n->n_next; + xfree(n); + n = nextnode; + } } - /* look for the longest? cycle from node from to node to. */ static int -find_cycle(NODE *from, NODE *to, int longest_len, int depth) +find_cycle(NODE * from, NODE * to, int longest_len, int depth) { - NODE **np; - int i, len; - - /* - * avoid infinite loops and ignore portions of the graph known - * to be acyclic - */ - if (from->n_flags & (NF_NODEST|NF_MARK|NF_ACYCLIC)) - return (0); - from->n_flags |= NF_MARK; - - for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) { - cycle_buf[depth] = *np; - if (*np == to) { - if (depth + 1 > longest_len) { - longest_len = depth + 1; - memcpy((char *)longest_cycle, - (char *)cycle_buf, - longest_len * sizeof(NODE *)); - } - } else { - if ((*np)->n_flags & (NF_MARK|NF_ACYCLIC|NF_NODEST)) - continue; - len = find_cycle(*np, to, longest_len, depth + 1); + NODE **np; + int i, len; + + /* + * avoid infinite loops and ignore portions of the graph known + * to be acyclic + */ + if (from->n_flags & (NF_NODEST | NF_MARK | NF_ACYCLIC)) + return (0); + from->n_flags |= NF_MARK; + + for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) { + cycle_buf[depth] = *np; + if (*np == to) { + if (depth + 1 > longest_len) { + longest_len = depth + 1; + memcpy((char *)longest_cycle, + (char *)cycle_buf, longest_len * sizeof(NODE *)); + } + } else { + if ((*np)->n_flags & (NF_MARK | NF_ACYCLIC | NF_NODEST)) + continue; + len = find_cycle(*np, to, longest_len, depth + 1); #ifdef DEBUG - ErrorF("%*s %s->%s %d\n", depth, "", - from->n_name, to->n_name, len); + ErrorF("%*s %s->%s %d\n", depth, "", + from->n_name, to->n_name, len); #endif - if (len == 0) - (*np)->n_flags |= NF_NODEST; + if (len == 0) + (*np)->n_flags |= NF_NODEST; - if (len > longest_len) - longest_len = len; + if (len > longest_len) + longest_len = len; - if (len > 0 && !longest) - break; - } + if (len > 0 && !longest) + break; } - from->n_flags &= ~NF_MARK; - return (longest_len); + } + from->n_flags &= ~NF_MARK; + return (longest_len); } - /* do topological sort on graph */ static void tsort(void) { - NODE *n, *next; - int cnt, i; - - while (graph != NULL) { - /* - * Keep getting rid of simple cases until there are none left, - * if there are any nodes still in the graph, then there is - * a cycle in it. - */ - do { - for (cnt = 0, n = graph; n != NULL; n = next) { - next = n->n_next; - if (n->n_refcnt == 0) { - remove_node(n); - ++cnt; - } - } - } while (graph != NULL && cnt); - - if (graph == NULL) - break; - - if (!cycle_buf) { - /* - * Allocate space for two cycle logs - one to be used - * as scratch space, the other to save the longest - * cycle. - */ - for (cnt = 0, n = graph; n != NULL; n = n->n_next) - ++cnt; - cycle_buf = xnfalloc(sizeof(NODE *) * cnt); - longest_cycle = xnfalloc(sizeof(NODE *) * cnt); - if (cycle_buf == NULL || longest_cycle == NULL) - return; + NODE *n, *next; + int cnt, i; + + while (graph != NULL) { + /* + * Keep getting rid of simple cases until there are none left, + * if there are any nodes still in the graph, then there is + * a cycle in it. + */ + do { + for (cnt = 0, n = graph; n != NULL; n = next) { + next = n->n_next; + if (n->n_refcnt == 0) { + remove_node(n); + ++cnt; } - for (n = graph; n != NULL; n = n->n_next) - if (!(n->n_flags & NF_ACYCLIC)) { - if ((cnt = find_cycle(n, n, 0, 0))) { - ErrorF("tsort: cycle in data"); - for (i = 0; i < cnt; i++) - ErrorF("%s", - longest_cycle[i]->n_name); - remove_node(n); - clear_cycle(); - break; - } else { - /* to avoid further checks */ - n->n_flags |= NF_ACYCLIC; - clear_cycle(); - } - } - - if (n == NULL) - ErrorF("tsort: internal error -- could not find cycle"); + } + } while (graph != NULL && cnt); + + if (graph == NULL) + break; + + if (!cycle_buf) { + /* + * Allocate space for two cycle logs - one to be used + * as scratch space, the other to save the longest + * cycle. + */ + for (cnt = 0, n = graph; n != NULL; n = n->n_next) + ++cnt; + cycle_buf = xnfalloc(sizeof(NODE *) * cnt); + longest_cycle = xnfalloc(sizeof(NODE *) * cnt); + if (cycle_buf == NULL || longest_cycle == NULL) + return; } - if (cycle_buf) - xfree(cycle_buf); - if (longest_cycle) - xfree(longest_cycle); - if (graph) - free_nodes(graph); + for (n = graph; n != NULL; n = n->n_next) + if (!(n->n_flags & NF_ACYCLIC)) { + if ((cnt = find_cycle(n, n, 0, 0))) { + ErrorF("tsort: cycle in data"); + for (i = 0; i < cnt; i++) + ErrorF("%s", longest_cycle[i]->n_name); + remove_node(n); + clear_cycle(); + break; + } else { + /* to avoid further checks */ + n->n_flags |= NF_ACYCLIC; + clear_cycle(); + } + } + + if (n == NULL) + ErrorF("tsort: internal error -- could not find cycle"); + } + if (cycle_buf) + xfree(cycle_buf); + if (longest_cycle) + xfree(longest_cycle); + if (graph) + free_nodes(graph); } void LoaderSortExtensions() { - int i, j; - ExtensionModule *ext, *newList; - NODE *node; - - graph = NULL; - longest = 0; - sorted = NULL; - last = NULL; - cycle_buf = NULL; - longest_cycle = NULL; - - /* - * Parse list and build the graph. Enter them in reverse order - * because tsort() will reverse those that have no depedencies. - */ - for (i = numExtensionModules - 1; i >= 0; i--) { - ext = &ExtensionModuleList[i]; - add_arc(ext->name, ext->name); + int i, j; + ExtensionModule *ext, *newList; + NODE *node; + + graph = NULL; + longest = 0; + sorted = NULL; + last = NULL; + cycle_buf = NULL; + longest_cycle = NULL; + + /* + * Parse list and build the graph. Enter them in reverse order + * because tsort() will reverse those that have no depedencies. + */ + for (i = numExtensionModules - 1; i >= 0; i--) { + ext = &ExtensionModuleList[i]; + add_arc(ext->name, ext->name); #ifdef DEBUG - ErrorF("Extension %s:\n", ext->name); + ErrorF("Extension %s:\n", ext->name); #endif - if (ext->initDependencies) - for (j = 0; ext->initDependencies[j]; j++) { - add_arc(ext->initDependencies[j], ext->name); + if (ext->initDependencies) + for (j = 0; ext->initDependencies[j]; j++) { + add_arc(ext->initDependencies[j], ext->name); #ifdef DEBUG - ErrorF("\t%s\n", ext->initDependencies[j]); + ErrorF("\t%s\n", ext->initDependencies[j]); #endif - } - } - tsort(); - newList = xnfalloc((numExtensionModules + 1) * sizeof(ExtensionModule)); - i = 0; - for (node = sorted; node; node = node->n_next) { - for (j = 0; j < numExtensionModules; j++) - if (!strcmp(node->n_name, ExtensionModuleList[j].name)) - break; - if (j != numExtensionModules) - newList[i++] = ExtensionModuleList[j]; - } - if (sorted) - free_nodes(sorted); - newList[i].name = NULL; - xfree(ExtensionModuleList); - ExtensionModuleList = newList; + } + } + tsort(); + newList = xnfalloc((numExtensionModules + 1) * sizeof(ExtensionModule)); + i = 0; + for (node = sorted; node; node = node->n_next) { + for (j = 0; j < numExtensionModules; j++) + if (!strcmp(node->n_name, ExtensionModuleList[j].name)) + break; + if (j != numExtensionModules) + newList[i++] = ExtensionModuleList[j]; + } + if (sorted) + free_nodes(sorted); + newList[i].name = NULL; + xfree(ExtensionModuleList); + ExtensionModuleList = newList; #ifdef DEBUG - for (i = 0; ExtensionModuleList[i].name; i++) - ErrorF("Extension %s\n", ExtensionModuleList[i].name); + for (i = 0; ExtensionModuleList[i].name; i++) + ErrorF("Extension %s\n", ExtensionModuleList[i].name); #endif } - diff --git a/hw/xfree86/loader/loadfont.c b/hw/xfree86/loader/loadfont.c index 8ab5d0d6e..6886692da 100644 --- a/hw/xfree86/loader/loadfont.c +++ b/hw/xfree86/loader/loadfont.c @@ -1,4 +1,30 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadfont.c,v 1.2 1998/12/13 12:42:41 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadfont.c,v 1.4 2003/10/15 16:29:04 dawes Exp $ */ +/* + * Copyright (c) 1998 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ /* Maybe this file belongs in lib/font/fontfile/module/ ? */ @@ -10,44 +36,42 @@ FontModule *FontModuleList = NULL; static int numFontModules = 0; - static FontModule * NewFontModule(void) { - FontModule *save = FontModuleList; - int n; - - /* Sanity check */ - if (!FontModuleList) - numFontModules = 0; - - n = numFontModules + 1; - FontModuleList = xrealloc(FontModuleList, (n + 1) * sizeof(FontModule)); - if (FontModuleList == NULL) { - FontModuleList = save; - return NULL; - } else { - numFontModules++; - FontModuleList[numFontModules].name = NULL; - return FontModuleList + (numFontModules - 1); - } + FontModule *save = FontModuleList; + int n; + + /* Sanity check */ + if (!FontModuleList) + numFontModules = 0; + + n = numFontModules + 1; + FontModuleList = xrealloc(FontModuleList, (n + 1) * sizeof(FontModule)); + if (FontModuleList == NULL) { + FontModuleList = save; + return NULL; + } else { + numFontModules++; + FontModuleList[numFontModules].name = NULL; + return FontModuleList + (numFontModules - 1); + } } void -LoadFont(FontModule *f) +LoadFont(FontModule * f) { - FontModule *newfont; + FontModule *newfont; - if (f == NULL) - return; + if (f == NULL) + return; - if (!(newfont = NewFontModule())) - return; + if (!(newfont = NewFontModule())) + return; - xf86MsgVerb(X_INFO, 2, "Loading font %s\n", f->name); + xf86MsgVerb(X_INFO, 2, "Loading font %s\n", f->name); - newfont->name = f->name; - newfont->initFunc = f->initFunc; - newfont->module = f->module; + newfont->name = f->name; + newfont->initFunc = f->initFunc; + newfont->module = f->module; } - diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index deba80643..733f6feb1 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.68 2002/07/30 18:36:18 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.73 2003/11/03 05:11:51 tsi Exp $ */ /* * @@ -22,8 +22,32 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ - -/* This file is best viewed with tab stops set to 4 spaces */ +/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ #include "os.h" /* For stat() and related stuff */ @@ -48,50 +72,51 @@ extern int check_unresolved_sema; typedef struct _pattern { - const char * pattern; - regex_t rex; + const char *pattern; + regex_t rex; } PatternRec, *PatternPtr; /* Prototypes for static functions */ -static char *FindModule (const char *, const char *, const char **, PatternPtr); -static Bool CheckVersion (const char *, XF86ModuleVersionInfo *, - const XF86ModReqInfo *); -static void UnloadModuleOrDriver (ModuleDescPtr mod); +static char *FindModule(const char *, const char *, const char **, + PatternPtr); +static Bool CheckVersion(const char *, XF86ModuleVersionInfo *, + const XF86ModReqInfo *); +static void UnloadModuleOrDriver(ModuleDescPtr mod); static char *LoaderGetCanonicalName(const char *, PatternPtr); static void RemoveChild(ModuleDescPtr); ModuleVersions LoaderVersionInfo = { - XF86_VERSION_CURRENT, - ABI_ANSIC_VERSION, - ABI_VIDEODRV_VERSION, - ABI_XINPUT_VERSION, - ABI_EXTENSION_VERSION, - ABI_FONT_VERSION + XF86_VERSION_CURRENT, + ABI_ANSIC_VERSION, + ABI_VIDEODRV_VERSION, + ABI_XINPUT_VERSION, + ABI_EXTENSION_VERSION, + ABI_FONT_VERSION }; #if 0 void -LoaderFixups (void) +LoaderFixups(void) { - /* Need to call LRS here because the frame buffers get loaded last, - * and the drivers depend on them. */ + /* Need to call LRS here because the frame buffers get loaded last, + * and the drivers depend on them. */ - LoaderResolveSymbols (); + LoaderResolveSymbols(); } #endif static void FreeStringList(char **paths) { - char **p; + char **p; - if (!paths) - return; + if (!paths) + return; - for (p = paths; *p; p++) - xfree(*p); + for (p = paths; *p; p++) + xfree(*p); - xfree(paths); + xfree(paths); } static char **defaultPathList = NULL; @@ -104,90 +129,89 @@ static char **defaultPathList = NULL; static char ** InitPathList(const char *path) { - char *fullpath = NULL; - char *elem = NULL; - char **list = NULL, **save = NULL; - int len; - int addslash; - int n = 0; - - if (!path) - return defaultPathList; - - fullpath = xstrdup(path); - if (!fullpath) - return NULL; - elem = strtok(fullpath, ","); - while (elem) { - /* Only allow fully specified paths */ + char *fullpath = NULL; + char *elem = NULL; + char **list = NULL, **save = NULL; + int len; + int addslash; + int n = 0; + + if (!path) + return defaultPathList; + + fullpath = xstrdup(path); + if (!fullpath) + return NULL; + elem = strtok(fullpath, ","); + while (elem) { + /* Only allow fully specified paths */ #ifndef __UNIXOS2__ - if (*elem == '/') + if (*elem == '/') #else - if (*elem == '/' || (strlen(elem) > 2 && isalpha(elem[0]) && - elem[1] == ':' && elem[2] == '/')) + if (*elem == '/' || (strlen(elem) > 2 && isalpha(elem[0]) && + elem[1] == ':' && elem[2] == '/')) #endif - { - len = strlen(elem); - addslash = (elem[len - 1] != '/'); - if (addslash) - len++; - save = list; - list = xrealloc(list, (n + 2) * sizeof(char *)); - if (!list) { - if (save) { - save[n] = NULL; - FreeStringList(save); - } - xfree(fullpath); - return NULL; - } - list[n] = xalloc(len + 1); - if (!list[n]) { - FreeStringList(list); - xfree(fullpath); - return NULL; - } - strcpy(list[n], elem); - if (addslash) { - list[n][len - 1] = '/'; - list[n][len] = '\0'; - } - n++; + { + len = strlen(elem); + addslash = (elem[len - 1] != '/'); + if (addslash) + len++; + save = list; + list = xrealloc(list, (n + 2) * sizeof(char *)); + if (!list) { + if (save) { + save[n] = NULL; + FreeStringList(save); } - elem = strtok(NULL, ","); + xfree(fullpath); + return NULL; + } + list[n] = xalloc(len + 1); + if (!list[n]) { + FreeStringList(list); + xfree(fullpath); + return NULL; + } + strcpy(list[n], elem); + if (addslash) { + list[n][len - 1] = '/'; + list[n][len] = '\0'; + } + n++; } - if (list) - list[n] = NULL; - return list; + elem = strtok(NULL, ","); + } + if (list) + list[n] = NULL; + return list; } static void FreePathList(char **pathlist) { - if (pathlist && pathlist != defaultPathList) - FreeStringList(pathlist); + if (pathlist && pathlist != defaultPathList) + FreeStringList(pathlist); } void LoaderSetPath(const char *path) { - if (!path) - return; + if (!path) + return; - defaultPathList = InitPathList(path); + defaultPathList = InitPathList(path); } /* Standard set of module subdirectories to search, in order of preference */ -static const char *stdSubdirs[] = -{ - "drivers/", - "input/", - "multimedia/", - "extensions/", - "fonts/", - "internal/", - "", - NULL +static const char *stdSubdirs[] = { + "drivers/", + "input/", + "multimedia/", + "extensions/", + "fonts/", + "internal/", + "", + NULL }; /* @@ -195,519 +219,529 @@ static const char *stdSubdirs[] = * These are regular expressions (suitable for use with POSIX regex(3)). */ static PatternRec stdPatterns[] = { - { "^lib(.*)\\.so$", }, - { "^lib(.*)\\.a$", }, - { "(.*)_drv\\.so$", }, - { "(.*)_drv\\.o$", }, - { "(.*)\\.so$", }, - { "(.*)\\.a$", }, - { "(.*)\\.o$", }, - { NULL, } + {"^lib(.*)\\.so$",}, + {"^lib(.*)\\.a$",}, + {"(.*)_drv\\.so$",}, + {"(.*)_drv\\.o$",}, + {"(.*)\\.so$",}, + {"(.*)\\.a$",}, + {"(.*)\\.o$",}, + {NULL,} }; static PatternPtr InitPatterns(const char **patternlist) { - char errmsg[80]; - int i, e; - PatternPtr patterns = NULL; - PatternPtr p = NULL; - static int firstTime = 1; - const char **s; - - if (firstTime) { - /* precompile stdPatterns */ - firstTime = 0; - for (p = stdPatterns; p->pattern; p++) - if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) { - regerror(e, &p->rex, errmsg, sizeof(errmsg)); - FatalError("InitPatterns: regcomp error for `%s': %s\n", - p->pattern, errmsg); - } + char errmsg[80]; + int i, e; + PatternPtr patterns = NULL; + PatternPtr p = NULL; + static int firstTime = 1; + const char **s; + + if (firstTime) { + /* precompile stdPatterns */ + firstTime = 0; + for (p = stdPatterns; p->pattern; p++) + if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) { + regerror(e, &p->rex, errmsg, sizeof(errmsg)); + FatalError("InitPatterns: regcomp error for `%s': %s\n", + p->pattern, errmsg); + } + } + + if (patternlist) { + for (i = 0, s = patternlist; *s; i++, s++) + if (*s == DEFAULT_LIST) + i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1; + patterns = xalloc((i + 1) * sizeof(PatternRec)); + if (!patterns) { + return NULL; } - - if (patternlist) { - for (i = 0, s = patternlist; *s; i++, s++) - if (*s == DEFAULT_LIST) - i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1; - patterns = xalloc((i + 1) * sizeof(PatternRec)); - if (!patterns) { - return NULL; + for (i = 0, s = patternlist; *s; i++, s++) + if (*s != DEFAULT_LIST) { + p = patterns + i; + p->pattern = *s; + if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) { + regerror(e, &p->rex, errmsg, sizeof(errmsg)); + ErrorF("InitPatterns: regcomp error for `%s': %s\n", + p->pattern, errmsg); + i--; } - for (i = 0, s = patternlist; *s; i++, s++) - if (*s != DEFAULT_LIST) { - p = patterns + i; - p->pattern = *s; - if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) { - regerror(e, &p->rex, errmsg, sizeof(errmsg)); - ErrorF("InitPatterns: regcomp error for `%s': %s\n", - p->pattern, errmsg); - i--; - } - } else { - for (p = stdPatterns; p->pattern; p++, i++) - patterns[i] = *p; - if (p != stdPatterns) - i--; - } - patterns[i].pattern = NULL; - } else - patterns = stdPatterns; - return patterns; + } else { + for (p = stdPatterns; p->pattern; p++, i++) + patterns[i] = *p; + if (p != stdPatterns) + i--; + } + patterns[i].pattern = NULL; + } else + patterns = stdPatterns; + return patterns; } static void FreePatterns(PatternPtr patterns) { - if (patterns && patterns != stdPatterns) - xfree(patterns); + if (patterns && patterns != stdPatterns) + xfree(patterns); } static const char ** InitSubdirs(const char **subdirlist) { - int i; - char **subdirs = NULL; - const char **s, **stmp = NULL; + int i; + const char **tmp_subdirlist = NULL; + char **subdirs = NULL; + const char **s, **stmp = NULL; const char *osname; const char *slash; int oslen = 0, len; Bool indefault; if (subdirlist == NULL) { - subdirlist = xalloc(2 * sizeof(char *)); - if (subdirlist == NULL) - return NULL; - subdirlist[0] = DEFAULT_LIST; - subdirlist[1] = NULL; - } - + subdirlist = tmp_subdirlist = xalloc(2 * sizeof(char *)); + if (subdirlist == NULL) + return NULL; + subdirlist[0] = DEFAULT_LIST; + subdirlist[1] = NULL; + } + LoaderGetOS(&osname, NULL, NULL, NULL); oslen = strlen(osname); { - /* Count number of entries and check for invalid paths */ - for (i = 0, s = subdirlist; *s; i++, s++) { - if (*s == DEFAULT_LIST) { - i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1; - } else { - /* - * Path validity check. Don't allow absolute paths, or - * paths containing "..". To catch absolute paths on - * platforms that use driver letters, don't allow the ':' - * character to appear at all. - */ - if (**s == '/' || **s == '\\' || strchr(*s, ':') || - strstr(*s, "..")) { - xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s); - return NULL; - } - } + /* Count number of entries and check for invalid paths */ + for (i = 0, s = subdirlist; *s; i++, s++) { + if (*s == DEFAULT_LIST) { + i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1; + } else { + /* + * Path validity check. Don't allow absolute paths, or + * paths containing "..". To catch absolute paths on + * platforms that use driver letters, don't allow the ':' + * character to appear at all. + */ + if (**s == '/' || **s == '\\' || strchr(*s, ':') || + strstr(*s, "..")) { + xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s); + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return NULL; } - subdirs = xalloc((i * 2 + 1) * sizeof(char *)); - if (!subdirs) - return NULL; - i = 0; - s = subdirlist; + } + } + subdirs = xalloc((i * 2 + 1) * sizeof(char *)); + if (!subdirs) { + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return NULL; + } + i = 0; + s = subdirlist; + indefault = FALSE; + while (*s) { + if (*s == DEFAULT_LIST) { + /* Divert to the default list */ + indefault = TRUE; + stmp = ++s; + s = stdSubdirs; + } + len = strlen(*s); + if (**s && (*s)[len - 1] != '/') { + slash = "/"; + len++; + } else + slash = ""; + len += oslen + 2; + if (!(subdirs[i] = xalloc(len))) { + while (--i >= 0) + xfree(subdirs[i]); + xfree(subdirs); + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return NULL; + } + /* tack on the OS name */ + sprintf(subdirs[i], "%s%s%s/", *s, slash, osname); + i++; + /* path as given */ + subdirs[i] = xstrdup(*s); + i++; + s++; + if (indefault && !s) { + /* revert back to the main list */ indefault = FALSE; - while (*s) { - if (*s == DEFAULT_LIST) { - /* Divert to the default list */ - indefault = TRUE; - stmp = ++s; - s = stdSubdirs; - } - len = strlen(*s); - if (**s && (*s)[len - 1] != '/') { - slash = "/"; - len++; - } else - slash = ""; - len += oslen + 2; - if (!(subdirs[i] = xalloc(len))) - return NULL; - /* tack on the OS name */ - sprintf(subdirs[i], "%s%s%s/", *s, slash, osname); - i++; - /* path as given */ - subdirs[i] = xstrdup(*s); - i++; - s++; - if (indefault && !s) { - /* revert back to the main list */ - indefault = FALSE; - s = stmp; - } - } - subdirs[i] = NULL; + s = stmp; + } } - return (const char **)subdirs; + subdirs[i] = NULL; + } + if (tmp_subdirlist) + xfree(tmp_subdirlist); + return (const char **)subdirs; } static void FreeSubdirs(const char **subdirs) { - const char **s; + const char **s; - if (subdirs) { - for (s = subdirs; *s; s++) - xfree(*s); - xfree(subdirs); - } + if (subdirs) { + for (s = subdirs; *s; s++) + xfree(*s); + xfree(subdirs); + } } static char * -FindModule (const char *module, const char *dir, const char **subdirlist, - PatternPtr patterns) +FindModule(const char *module, const char *dir, const char **subdirlist, + PatternPtr patterns) { - char buf[PATH_MAX + 1]; - char *dirpath = NULL; - char *name = NULL; - struct stat stat_buf; - int len, dirlen; - char *fp; - DIR *d; - const char **subdirs = NULL; - PatternPtr p = NULL; - const char **s; - struct dirent *dp; - regmatch_t match[2]; - - subdirs = InitSubdirs(subdirlist); - if (!subdirs) - return NULL; + char buf[PATH_MAX + 1]; + char *dirpath = NULL; + char *name = NULL; + struct stat stat_buf; + int len, dirlen; + char *fp; + DIR *d; + const char **subdirs = NULL; + PatternPtr p = NULL; + const char **s; + struct dirent *dp; + regmatch_t match[2]; + + subdirs = InitSubdirs(subdirlist); + if (!subdirs) + return NULL; #ifndef __EMX__ - dirpath = (char *)dir; + dirpath = (char *)dir; #else - dirpath = xalloc(strlen(dir) + 10); - strcpy(dirpath, (char *) __XOS2RedirRoot (dir)); + dirpath = xalloc(strlen(dir) + 10); + strcpy(dirpath, (char *)__XOS2RedirRoot(dir)); #endif - if (strlen(dirpath) > PATH_MAX) - return NULL; - /*xf86Msg(X_INFO,"OS2DIAG: FindModule: dirpath=%s\n",dirpath);*/ - - for (s = subdirs; *s; s++) { - if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX) - continue; - strcpy(buf, dirpath); - strcat(buf, *s); - /*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf);*/ - fp = buf + dirlen; - if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && - (d = opendir(buf))) { - if (buf[dirlen - 1] != '/') { - buf[dirlen++] = '/'; - fp++; - } - while ((dp = readdir(d))) { - if (dirlen + strlen(dp->d_name) + 1 > PATH_MAX) - continue; - strcpy(fp, dp->d_name); - if (!(stat(buf, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode))) - continue; - for (p = patterns; p->pattern; p++) { - if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && - match[1].rm_so != -1) { - len = match[1].rm_eo - match[1].rm_so; - if (len == strlen(module) && - strncmp(module, dp->d_name + match[1].rm_so, len) == 0) { - /*xf86Msg(X_INFO,"OS2DIAG: matching %s\n",buf);*/ - name = buf; - break; - } - } - } - if (name) - break; + if (strlen(dirpath) > PATH_MAX) + return NULL; + /*xf86Msg(X_INFO,"OS2DIAG: FindModule: dirpath=%s\n",dirpath); */ + + for (s = subdirs; *s; s++) { + if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX) + continue; + strcpy(buf, dirpath); + strcat(buf, *s); + /*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf); */ + fp = buf + dirlen; + if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && + (d = opendir(buf))) { + if (buf[dirlen - 1] != '/') { + buf[dirlen++] = '/'; + fp++; + } + while ((dp = readdir(d))) { + if (dirlen + strlen(dp->d_name) + 1 > PATH_MAX) + continue; + strcpy(fp, dp->d_name); + if (!(stat(buf, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode))) + continue; + for (p = patterns; p->pattern; p++) { + if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && + match[1].rm_so != -1) { + len = match[1].rm_eo - match[1].rm_so; + if (len == strlen(module) && + strncmp(module, dp->d_name + match[1].rm_so, + len) == 0) { + /*xf86Msg(X_INFO,"OS2DIAG: matching %s\n",buf); */ + name = buf; + break; } - closedir(d); - if (name) - break; + } } + if (name) + break; + } + closedir(d); + if (name) + break; } - FreeSubdirs(subdirs); - if (dirpath != dir) - xfree(dirpath); - - if (name) { - return xstrdup(name); - } - return NULL; + } + FreeSubdirs(subdirs); + if (dirpath != dir) + xfree(dirpath); + + if (name) { + return xstrdup(name); + } + return NULL; } char ** LoaderListDirs(const char **subdirlist, const char **patternlist) { - char buf[PATH_MAX + 1]; - char **pathlist; - char **elem; - const char **subdirs; - const char **s; - PatternPtr patterns; - PatternPtr p; - DIR *d; - struct dirent *dp; - regmatch_t match[2]; - struct stat stat_buf; - int len, dirlen; - char *fp; - char **listing = NULL; - char **save; - int n = 0; - - if (!(pathlist = InitPathList(NULL))) - return NULL; - if (!(subdirs = InitSubdirs(subdirlist))) { - FreePathList(pathlist); - return NULL; - } - if (!(patterns = InitPatterns(patternlist))) { - FreePathList(pathlist); - FreeSubdirs(subdirs); - return NULL; - } + char buf[PATH_MAX + 1]; + char **pathlist; + char **elem; + const char **subdirs; + const char **s; + PatternPtr patterns; + PatternPtr p; + DIR *d; + struct dirent *dp; + regmatch_t match[2]; + struct stat stat_buf; + int len, dirlen; + char *fp; + char **listing = NULL; + char **save; + int n = 0; + + if (!(pathlist = InitPathList(NULL))) + return NULL; + if (!(subdirs = InitSubdirs(subdirlist))) { + FreePathList(pathlist); + return NULL; + } + if (!(patterns = InitPatterns(patternlist))) { + FreePathList(pathlist); + FreeSubdirs(subdirs); + return NULL; + } - for (elem = pathlist; *elem; elem++) { - for (s = subdirs; *s; s++) { - if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX) - continue; - strcpy(buf, *elem); - strcat(buf, *s); - fp = buf + dirlen; - if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && - (d = opendir(buf))) { - if (buf[dirlen - 1] != '/') { - buf[dirlen++] = '/'; - fp++; - } - while ((dp = readdir(d))) { - if (dirlen + strlen(dp->d_name) > PATH_MAX) - continue; - strcpy(fp, dp->d_name); - if (!(stat(buf, &stat_buf) == 0 && - S_ISREG(stat_buf.st_mode))) - continue; - for (p = patterns; p->pattern; p++) { - if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && - match[1].rm_so != -1) { - len = match[1].rm_eo - match[1].rm_so; - save = listing; - listing = xrealloc(listing, - (n + 2) * sizeof(char *)); - if (!listing) { - if (save) { - save[n] = NULL; - FreeStringList(save); - } - FreePathList(pathlist); - FreeSubdirs(subdirs); - FreePatterns(patterns); - return NULL; - } - listing[n] = xalloc(len + 1); - if (!listing[n]) { - FreeStringList(listing); - FreePathList(pathlist); - FreeSubdirs(subdirs); - FreePatterns(patterns); - return NULL; - } - strncpy(listing[n], dp->d_name + match[1].rm_so, - len); - listing[n][len] = '\0'; - n++; - break; - } - } + for (elem = pathlist; *elem; elem++) { + for (s = subdirs; *s; s++) { + if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX) + continue; + strcpy(buf, *elem); + strcat(buf, *s); + fp = buf + dirlen; + if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && + (d = opendir(buf))) { + if (buf[dirlen - 1] != '/') { + buf[dirlen++] = '/'; + fp++; + } + while ((dp = readdir(d))) { + if (dirlen + strlen(dp->d_name) > PATH_MAX) + continue; + strcpy(fp, dp->d_name); + if (!(stat(buf, &stat_buf) == 0 && + S_ISREG(stat_buf.st_mode))) + continue; + for (p = patterns; p->pattern; p++) { + if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && + match[1].rm_so != -1) { + len = match[1].rm_eo - match[1].rm_so; + save = listing; + listing = xrealloc(listing, + (n + 2) * sizeof(char *)); + if (!listing) { + if (save) { + save[n] = NULL; + FreeStringList(save); } - closedir(d); + FreePathList(pathlist); + FreeSubdirs(subdirs); + FreePatterns(patterns); + return NULL; + } + listing[n] = xalloc(len + 1); + if (!listing[n]) { + FreeStringList(listing); + FreePathList(pathlist); + FreeSubdirs(subdirs); + FreePatterns(patterns); + return NULL; + } + strncpy(listing[n], dp->d_name + match[1].rm_so, + len); + listing[n][len] = '\0'; + n++; + break; } + } } + closedir(d); + } } - if (listing) - listing[n] = NULL; - return listing; + } + if (listing) + listing[n] = NULL; + return listing; } void LoaderFreeDirList(char **list) { - FreeStringList(list); + FreeStringList(list); } - static Bool -CheckVersion (const char *module, XF86ModuleVersionInfo *data, - const XF86ModReqInfo *req) +CheckVersion(const char *module, XF86ModuleVersionInfo * data, + const XF86ModReqInfo * req) { - int vercode[4]; - char verstr[4]; - long ver = data->xf86version; - int errtype = 0; - - xf86Msg (X_INFO, "Module %s: vendor=\"%s\"\n", - data->modname ? data->modname : "UNKNOWN!", - data->vendor ? data->vendor : "UNKNOWN!"); - - if (ver > (4 << 24)) { - /* 4.0.x and earlier */ - verstr[1] = verstr[3] = 0; - verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0; - ver >>= 5; - verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0; - ver >>= 5; - vercode[2] = ver & 0x7f; - ver >>= 7; - vercode[1] = ver & 0x7f; - ver >>= 7; - vercode[0] = ver; - xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]); - if (vercode[2] != 0) - xf86ErrorF(".%d", vercode[2]); - xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2, - data->majorversion, data->minorversion, data->patchlevel); - } else { - vercode[0] = ver / 10000000; - vercode[1] = (ver / 100000) % 100; - vercode[2] = (ver / 1000) % 100; - vercode[3] = ver % 1000; - xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1], - vercode[2]); - if (vercode[3] != 0) - xf86ErrorF(".%d", vercode[3]); - xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion, - data->minorversion, data->patchlevel); - } + int vercode[4]; + char verstr[4]; + long ver = data->xf86version; + MessageType errtype; + + xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n", + data->modname ? data->modname : "UNKNOWN!", + data->vendor ? data->vendor : "UNKNOWN!"); + + if (ver > (4 << 24)) { + /* 4.0.x and earlier */ + verstr[1] = verstr[3] = 0; + verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0; + ver >>= 5; + verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0; + ver >>= 5; + vercode[2] = ver & 0x7f; + ver >>= 7; + vercode[1] = ver & 0x7f; + ver >>= 7; + vercode[0] = ver; + xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]); + if (vercode[2] != 0) + xf86ErrorF(".%d", vercode[2]); + xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2, + data->majorversion, data->minorversion, data->patchlevel); + } else { + vercode[0] = ver / 10000000; + vercode[1] = (ver / 100000) % 100; + vercode[2] = (ver / 1000) % 100; + vercode[3] = ver % 1000; + xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1], + vercode[2]); + if (vercode[3] != 0) + xf86ErrorF(".%d", vercode[3]); + xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion, + data->minorversion, data->patchlevel); + } if (data->moduleclass) - xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass); - - ver = -1; - if (data->abiclass) { - int abimaj, abimin; - int vermaj, vermin; - - if (!strcmp(data->abiclass, ABI_CLASS_ANSIC)) - ver = LoaderVersionInfo.ansicVersion; - else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV)) - ver = LoaderVersionInfo.videodrvVersion; - else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT)) - ver = LoaderVersionInfo.xinputVersion; - else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION)) - ver = LoaderVersionInfo.extensionVersion; - else if (!strcmp(data->abiclass, ABI_CLASS_FONT)) - ver = LoaderVersionInfo.fontVersion; - - abimaj = GET_ABI_MAJOR(data->abiversion); - abimin = GET_ABI_MINOR(data->abiversion); - xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n", - data->abiclass, abimaj, abimin); - if (ver != -1) { - vermaj = GET_ABI_MAJOR(ver); - vermin = GET_ABI_MINOR(ver); - if (abimaj != vermaj) { - if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) - errtype = X_WARNING; - else - errtype = X_ERROR; - xf86MsgVerb(errtype, 0, - "module ABI major version (%d) doesn't" - " match the server's version (%d)\n", - abimaj, vermaj); - if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) - return FALSE; - } else if (abimin > vermin) { - if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) - errtype = X_WARNING; - else - errtype = X_ERROR; - xf86MsgVerb(errtype, 0, - "module ABI minor version (%d) is " - "newer than the server's version " - "(%d)\n", abimin, vermin); - if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) - return FALSE; - } - } + xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass); + + ver = -1; + if (data->abiclass) { + int abimaj, abimin; + int vermaj, vermin; + + if (!strcmp(data->abiclass, ABI_CLASS_ANSIC)) + ver = LoaderVersionInfo.ansicVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV)) + ver = LoaderVersionInfo.videodrvVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT)) + ver = LoaderVersionInfo.xinputVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION)) + ver = LoaderVersionInfo.extensionVersion; + else if (!strcmp(data->abiclass, ABI_CLASS_FONT)) + ver = LoaderVersionInfo.fontVersion; + + abimaj = GET_ABI_MAJOR(data->abiversion); + abimin = GET_ABI_MINOR(data->abiversion); + xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n", + data->abiclass, abimaj, abimin); + if (ver != -1) { + vermaj = GET_ABI_MAJOR(ver); + vermin = GET_ABI_MINOR(ver); + if (abimaj != vermaj) { + if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) + errtype = X_WARNING; + else + errtype = X_ERROR; + xf86MsgVerb(errtype, 0, + "module ABI major version (%d) doesn't" + " match the server's version (%d)\n", + abimaj, vermaj); + if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) + return FALSE; + } else if (abimin > vermin) { + if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) + errtype = X_WARNING; + else + errtype = X_ERROR; + xf86MsgVerb(errtype, 0, + "module ABI minor version (%d) is " + "newer than the server's version " + "(%d)\n", abimin, vermin); + if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)) + return FALSE; + } } - - /* Check against requirements that the caller has specified */ - if (req) { - if (req->majorversion != MAJOR_UNSPEC) { - if (data->majorversion != req->majorversion) { - xf86MsgVerb(X_WARNING, 2, "module major version (%d) " - "doesn't match required major version (%d)\n", - data->majorversion, req->majorversion); - return FALSE; - } else if (req->minorversion != MINOR_UNSPEC) { - if (data->minorversion < req->minorversion) { - xf86MsgVerb(X_WARNING, 2, "module minor version (%d) " - "is less than the required minor version (%d)\n", - data->minorversion, req->minorversion); - return FALSE; - } else if (data->minorversion == req->minorversion && - req->patchlevel != PATCH_UNSPEC) { - if (data->patchlevel < req->patchlevel) { - xf86MsgVerb(X_WARNING, 2, "module patch level (%d) " - "is less than the required patch level (%d)\n", - data->patchlevel, req->patchlevel); - return FALSE; - } - } - } - } - if (req->moduleclass) { - if (!data->moduleclass || - strcmp(req->moduleclass, data->moduleclass)) { - xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match " - "the required class (%s)\n", - data->moduleclass ? data->moduleclass : "<NONE>", - req->moduleclass); - return FALSE; - } - } else if (req->abiclass != ABI_CLASS_NONE) { - if (!data->abiclass || strcmp(req->abiclass, data->moduleclass)) { - xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the " - "required ABI class (%s)\n", - data->abiclass ? data->abiclass : "<NONE>", - req->abiclass); - return FALSE; - } - } - if ((req->abiclass != ABI_CLASS_NONE) && - req->abiversion != ABI_VERS_UNSPEC) { - int reqmaj, reqmin, maj, min; - reqmaj = GET_ABI_MAJOR(req->abiversion); - reqmin = GET_ABI_MINOR(req->abiversion); - maj = GET_ABI_MAJOR(data->abiversion); - min = GET_ABI_MINOR(data->abiversion); - if (maj != reqmaj) { - xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't " - "match the required ABI major version (%d)\n", - maj, reqmaj); - return FALSE; - } - /* XXX Maybe this should be the other way around? */ - if (min > reqmin) { - xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) " - "is new than that available (%d)\n", - min, reqmin); - return FALSE; - } + } + + /* Check against requirements that the caller has specified */ + if (req) { + if (req->majorversion != MAJOR_UNSPEC) { + if (data->majorversion != req->majorversion) { + xf86MsgVerb(X_WARNING, 2, "module major version (%d) " + "doesn't match required major version (%d)\n", + data->majorversion, req->majorversion); + return FALSE; + } else if (req->minorversion != MINOR_UNSPEC) { + if (data->minorversion < req->minorversion) { + xf86MsgVerb(X_WARNING, 2, "module minor version (%d) " + "is less than the required minor version (%d)\n", + data->minorversion, req->minorversion); + return FALSE; + } else if (data->minorversion == req->minorversion && + req->patchlevel != PATCH_UNSPEC) { + if (data->patchlevel < req->patchlevel) { + xf86MsgVerb(X_WARNING, 2, "module patch level (%d) " + "is less than the required patch level (%d)\n", + data->patchlevel, req->patchlevel); + return FALSE; + } } + } } - -#ifdef NOTYET - if (data->checksum) - { - /* verify the checksum field */ - /* TO BE DONE */ + if (req->moduleclass) { + if (!data->moduleclass || + strcmp(req->moduleclass, data->moduleclass)) { + xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match " + "the required class (%s)\n", + data->moduleclass ? data->moduleclass : "<NONE>", + req->moduleclass); + return FALSE; + } + } else if (req->abiclass != ABI_CLASS_NONE) { + if (!data->abiclass || strcmp(req->abiclass, data->moduleclass)) { + xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the " + "required ABI class (%s)\n", + data->abiclass ? data->abiclass : "<NONE>", + req->abiclass); + return FALSE; + } } - else - { - ErrorF ("\t*** Checksum field is 0 - this module is untrusted!\n"); + if ((req->abiclass != ABI_CLASS_NONE) && + req->abiversion != ABI_VERS_UNSPEC) { + int reqmaj, reqmin, maj, min; + + reqmaj = GET_ABI_MAJOR(req->abiversion); + reqmin = GET_ABI_MINOR(req->abiversion); + maj = GET_ABI_MAJOR(data->abiversion); + min = GET_ABI_MINOR(data->abiversion); + if (maj != reqmaj) { + xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't " + "match the required ABI major version (%d)\n", + maj, reqmaj); + return FALSE; + } + /* XXX Maybe this should be the other way around? */ + if (min > reqmin) { + xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) " + "is new than that available (%d)\n", min, reqmin); + return FALSE; + } } + } +#ifdef NOTYET + if (data->checksum) { + /* verify the checksum field */ + /* TO BE DONE */ + } else { + ErrorF("\t*** Checksum field is 0 - this module is untrusted!\n"); + } #endif return TRUE; } @@ -715,69 +749,69 @@ CheckVersion (const char *module, XF86ModuleVersionInfo *data, ModuleDescPtr LoadSubModule(ModuleDescPtr parent, const char *module, const char **subdirlist, const char **patternlist, - pointer options, const XF86ModReqInfo *modreq, + pointer options, const XF86ModReqInfo * modreq, int *errmaj, int *errmin) { - ModuleDescPtr submod; + ModuleDescPtr submod; - xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module); + xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module); - /* Absolute module paths are not allowed here */ + /* Absolute module paths are not allowed here */ #ifndef __UNIXOS2__ - if (module[0] == '/') + if (module[0] == '/') #else - if (isalpha (module[0]) && module[1] == ':' && module[2] == '/') + if (isalpha(module[0]) && module[1] == ':' && module[2] == '/') #endif - { - xf86Msg(X_ERROR, - "LoadSubModule: Absolute module path not permitted: \"%s\"\n", - module); - if (errmaj) - *errmaj = LDR_BADUSAGE; - if (errmin) - *errmin = 0; - return NULL; - } - - submod = LoadModule (module, NULL, subdirlist, patternlist, options, - modreq, errmaj, errmin); - if (submod) { - parent->child = AddSibling (parent->child, submod); - submod->parent = parent; - } - return submod; + { + xf86Msg(X_ERROR, + "LoadSubModule: Absolute module path not permitted: \"%s\"\n", + module); + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 0; + return NULL; + } + + submod = LoadModule(module, NULL, subdirlist, patternlist, options, + modreq, errmaj, errmin); + if (submod) { + parent->child = AddSibling(parent->child, submod); + submod->parent = parent; + } + return submod; } ModuleDescPtr DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) { - ModuleDescPtr ret; + ModuleDescPtr ret; - if (!mod) - return NULL; + if (!mod) + return NULL; - ret = NewModuleDesc(mod->name); - if (ret == NULL) - return NULL; + ret = NewModuleDesc(mod->name); + if (ret == NULL) + return NULL; - if (LoaderHandleOpen(mod->handle) == -1) - return NULL; + if (LoaderHandleOpen(mod->handle) == -1) + return NULL; - ret->filename = xstrdup(mod->filename); - ret->identifier = mod->identifier; - ret->client_id = mod->client_id; - ret->in_use = mod->in_use; - ret->handle = mod->handle; - ret->SetupProc = mod->SetupProc; - ret->TearDownProc = mod->TearDownProc; - ret->TearDownData = NULL; - ret->path = mod->path; - ret->child = DuplicateModule(mod->child, ret); - ret->sib = DuplicateModule(mod->sib, parent); - ret->parent = parent; - ret->VersionInfo = mod->VersionInfo; - - return ret; + ret->filename = xstrdup(mod->filename); + ret->identifier = mod->identifier; + ret->client_id = mod->client_id; + ret->in_use = mod->in_use; + ret->handle = mod->handle; + ret->SetupProc = mod->SetupProc; + ret->TearDownProc = mod->TearDownProc; + ret->TearDownData = NULL; + ret->path = mod->path; + ret->child = DuplicateModule(mod->child, ret); + ret->sib = DuplicateModule(mod->sib, parent); + ret->parent = parent; + ret->VersionInfo = mod->VersionInfo; + + return ret; } /* @@ -819,241 +853,227 @@ DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent) */ ModuleDescPtr -LoadModule (const char *module, const char *path, const char **subdirlist, - const char **patternlist, pointer options, - const XF86ModReqInfo * modreq, - int *errmaj, int *errmin) +LoadModule(const char *module, const char *path, const char **subdirlist, + const char **patternlist, pointer options, + const XF86ModReqInfo * modreq, int *errmaj, int *errmin) { - XF86ModuleData *initdata = NULL; - char **pathlist = NULL; - char *found = NULL; - char *name = NULL; - char **path_elem = NULL; - char *p = NULL; - ModuleDescPtr ret = NULL; - int wasLoaded = 0; - PatternPtr patterns = NULL; - int noncanonical = 0; - char *m = NULL; - - /*xf86Msg(X_INFO,"OS2DIAG: LoadModule: %s\n",module);*/ - xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module); - - patterns = InitPatterns(patternlist); - name = LoaderGetCanonicalName(module, patterns); - noncanonical = (name && strcmp(module, name) != 0); - if (noncanonical) - { - xf86ErrorFVerb(3, " (%s)\n", name); - xf86MsgVerb(X_WARNING, 1, - "LoadModule: given non-canonical module name \"%s\"\n", - module); - m = name; - } - else - { - xf86ErrorFVerb(3, "\n"); - m = (char *)module; - } - if (!name) { - if (errmaj) - *errmaj = LDR_BADUSAGE; - if (errmin) - *errmin = 0; - goto LoadModule_fail; - } - ret = NewModuleDesc (name); - if (!ret) { - if (errmaj) - *errmaj = LDR_NOMEM; - if (errmin) - *errmin = 0; - goto LoadModule_fail; - } - - pathlist = InitPathList(path); - if (!pathlist) { - /* This could be a malloc failure too */ - if (errmaj) - *errmaj = LDR_BADUSAGE; - if (errmin) - *errmin = 1; - goto LoadModule_fail; - } - - /* - * if the module name is not a full pathname, we need to - * check the elements in the path - */ + XF86ModuleData *initdata = NULL; + char **pathlist = NULL; + char *found = NULL; + char *name = NULL; + char **path_elem = NULL; + char *p = NULL; + ModuleDescPtr ret = NULL; + int wasLoaded = 0; + PatternPtr patterns = NULL; + int noncanonical = 0; + char *m = NULL; + + /*xf86Msg(X_INFO,"OS2DIAG: LoadModule: %s\n",module); */ + xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module); + + patterns = InitPatterns(patternlist); + name = LoaderGetCanonicalName(module, patterns); + noncanonical = (name && strcmp(module, name) != 0); + if (noncanonical) { + xf86ErrorFVerb(3, " (%s)\n", name); + xf86MsgVerb(X_WARNING, 1, + "LoadModule: given non-canonical module name \"%s\"\n", + module); + m = name; + } else { + xf86ErrorFVerb(3, "\n"); + m = (char *)module; + } + if (!name) { + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + ret = NewModuleDesc(name); + if (!ret) { + if (errmaj) + *errmaj = LDR_NOMEM; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + + pathlist = InitPathList(path); + if (!pathlist) { + /* This could be a malloc failure too */ + if (errmaj) + *errmaj = LDR_BADUSAGE; + if (errmin) + *errmin = 1; + goto LoadModule_fail; + } + + /* + * if the module name is not a full pathname, we need to + * check the elements in the path + */ #ifndef __UNIXOS2__ - if (module[0] == '/') - found = xstrdup(module); + if (module[0] == '/') + found = xstrdup(module); #else - /* accept a drive name here */ - if (isalpha (module[0]) && module[1] == ':' && module[2] == '/') - found = xstrdup(module); + /* accept a drive name here */ + if (isalpha(module[0]) && module[1] == ':' && module[2] == '/') + found = xstrdup(module); #endif - path_elem = pathlist; - while (!found && *path_elem != NULL) - { - found = FindModule (m, *path_elem, subdirlist, patterns); - path_elem++; - /* - * When the module name isn't the canonical name, search for the - * former if no match was found for the latter. - */ - if (!*path_elem && m == name) - { - path_elem = pathlist; - m = (char *)module; - } - } - - /* - * did we find the module? - */ - if (!found) - { - xf86Msg (X_WARNING, "Warning, couldn't open module %s\n", - module); - if (errmaj) - *errmaj = LDR_NOENT; - if (errmin) - *errmin = 0; - goto LoadModule_fail; - } - ret->handle = LoaderOpen (found, name, 0, errmaj, errmin, &wasLoaded); - if (ret->handle < 0) - goto LoadModule_fail; - - ret->filename = xstrdup(found); - + path_elem = pathlist; + while (!found && *path_elem != NULL) { + found = FindModule(m, *path_elem, subdirlist, patterns); + path_elem++; /* - * now check if the special data object <modulename>ModuleData is - * present. + * When the module name isn't the canonical name, search for the + * former if no match was found for the latter. */ - p = xalloc (strlen (name) + strlen ("ModuleData") + 1); - if (!p) { - if (errmaj) - *errmaj = LDR_NOMEM; - if (errmin) - *errmin = 0; - goto LoadModule_fail; + if (!*path_elem && m == name) { + path_elem = pathlist; + m = (char *)module; } - strcpy (p, name); - strcat (p, "ModuleData"); - initdata = LoaderSymbol (p); - if (initdata) - { - ModuleSetupProc setup; - ModuleTearDownProc teardown; - XF86ModuleVersionInfo *vers; - - vers = initdata->vers; - setup = initdata->setup; - teardown = initdata->teardown; - - if (!wasLoaded) { - if (vers) { - if (!CheckVersion (module, vers, modreq)) { - if (errmaj) - *errmaj = LDR_MISMATCH; - if (errmin) - *errmin = 0; - goto LoadModule_fail; - } - } else { - xf86Msg(X_ERROR, - "LoadModule: Module %s does not supply" - " version information\n", module); - if (errmaj) - *errmaj = LDR_INVALID; - if (errmin) - *errmin = 0; - goto LoadModule_fail; - } + } + + /* + * did we find the module? + */ + if (!found) { + xf86Msg(X_WARNING, "Warning, couldn't open module %s\n", module); + if (errmaj) + *errmaj = LDR_NOENT; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + ret->handle = LoaderOpen(found, name, 0, errmaj, errmin, &wasLoaded); + if (ret->handle < 0) + goto LoadModule_fail; + + ret->filename = xstrdup(found); + + /* + * now check if the special data object <modulename>ModuleData is + * present. + */ + p = xalloc(strlen(name) + strlen("ModuleData") + 1); + if (!p) { + if (errmaj) + *errmaj = LDR_NOMEM; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + strcpy(p, name); + strcat(p, "ModuleData"); + initdata = LoaderSymbol(p); + if (initdata) { + ModuleSetupProc setup; + ModuleTearDownProc teardown; + XF86ModuleVersionInfo *vers; + + vers = initdata->vers; + setup = initdata->setup; + teardown = initdata->teardown; + + if (!wasLoaded) { + if (vers) { + if (!CheckVersion(module, vers, modreq)) { + if (errmaj) + *errmaj = LDR_MISMATCH; + if (errmin) + *errmin = 0; + goto LoadModule_fail; } - if (setup) - ret->SetupProc = setup; - if (teardown) - ret->TearDownProc = teardown; - ret->path = path; - ret->VersionInfo = vers; - } - else - { - /* No initdata is OK for external modules */ - if (options == EXTERN_MODULE) - goto LoadModule_exit; - - /* no initdata, fail the load */ - xf86Msg (X_ERROR, "LoadModule: Module %s does not have a %s " - "data object.\n", module, p); + } else { + xf86Msg(X_ERROR, + "LoadModule: Module %s does not supply" + " version information\n", module); if (errmaj) - *errmaj = LDR_INVALID; + *errmaj = LDR_INVALID; if (errmin) - *errmin = 0; + *errmin = 0; goto LoadModule_fail; + } } - if (ret->SetupProc) - { - ret->TearDownData = ret->SetupProc (ret, options, errmaj, errmin); - if (!ret->TearDownData) - { - goto LoadModule_fail; - } - } - else if (options) - { - xf86Msg (X_WARNING, "Module Options present, but no SetupProc " - "available for %s\n", module); + if (setup) + ret->SetupProc = setup; + if (teardown) + ret->TearDownProc = teardown; + ret->path = path; + ret->VersionInfo = vers; + } else { + /* No initdata is OK for external modules */ + if (options == EXTERN_MODULE) + goto LoadModule_exit; + + /* no initdata, fail the load */ + xf86Msg(X_ERROR, "LoadModule: Module %s does not have a %s " + "data object.\n", module, p); + if (errmaj) + *errmaj = LDR_INVALID; + if (errmin) + *errmin = 0; + goto LoadModule_fail; + } + if (ret->SetupProc) { + ret->TearDownData = ret->SetupProc(ret, options, errmaj, errmin); + if (!ret->TearDownData) { + goto LoadModule_fail; } - goto LoadModule_exit; + } else if (options) { + xf86Msg(X_WARNING, "Module Options present, but no SetupProc " + "available for %s\n", module); + } + goto LoadModule_exit; LoadModule_fail: - UnloadModule (ret); - ret = NULL; + UnloadModule(ret); + ret = NULL; LoadModule_exit: - FreePathList(pathlist); - FreePatterns(patterns); - TestFree (found); - TestFree (name); - TestFree (p); - - /* - * If you need to do something to keep the - * instruction cache in sync with the main - * memory before jumping to that code, you may - * do it here. - */ + FreePathList(pathlist); + FreePatterns(patterns); + TestFree(found); + TestFree(name); + TestFree(p); + + /* + * If you need to do something to keep the + * instruction cache in sync with the main + * memory before jumping to that code, you may + * do it here. + */ #ifdef __alpha__ - istream_mem_barrier(); + istream_mem_barrier(); #endif - return ret; + return ret; } ModuleDescPtr -LoadDriver (const char *module, const char *path, int handle, pointer options, - int *errmaj, int *errmin) +LoadDriver(const char *module, const char *path, int handle, pointer options, + int *errmaj, int *errmin) { -return LoadModule (module, path, NULL, NULL, options, NULL, errmaj, errmin); + return LoadModule(module, path, NULL, NULL, options, NULL, errmaj, + errmin); } void -UnloadModule (ModuleDescPtr mod) +UnloadModule(ModuleDescPtr mod) { - UnloadModuleOrDriver (mod); + UnloadModuleOrDriver(mod); } void -UnloadDriver (ModuleDescPtr mod) +UnloadDriver(ModuleDescPtr mod) { - UnloadModuleOrDriver (mod); + UnloadModuleOrDriver(mod); } static void -UnloadModuleOrDriver (ModuleDescPtr mod) +UnloadModuleOrDriver(ModuleDescPtr mod) { if (mod == NULL || mod->name == NULL) return; @@ -1061,18 +1081,18 @@ UnloadModuleOrDriver (ModuleDescPtr mod) xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name); if ((mod->TearDownProc) && (mod->TearDownData)) - mod->TearDownProc (mod->TearDownData); - LoaderUnload (mod->handle); + mod->TearDownProc(mod->TearDownData); + LoaderUnload(mod->handle); if (mod->child) - UnloadModuleOrDriver (mod->child); + UnloadModuleOrDriver(mod->child); if (mod->sib) - UnloadModuleOrDriver (mod->sib); - TestFree (mod->name); - TestFree (mod->filename); - xfree (mod); + UnloadModuleOrDriver(mod->sib); + TestFree(mod->name); + TestFree(mod->filename); + xfree(mod); #ifdef __alpha__ - istream_mem_barrier(); + istream_mem_barrier(); #endif } @@ -1085,69 +1105,67 @@ UnloadSubModule(ModuleDescPtr mod) xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name); if ((mod->TearDownProc) && (mod->TearDownData)) - mod->TearDownProc (mod->TearDownData); - LoaderUnload (mod->handle); + mod->TearDownProc(mod->TearDownData); + LoaderUnload(mod->handle); RemoveChild(mod); if (mod->child) - UnloadModuleOrDriver (mod->child); + UnloadModuleOrDriver(mod->child); - TestFree (mod->name); - TestFree (mod->filename); - xfree (mod); + TestFree(mod->name); + TestFree(mod->filename); + xfree(mod); } void -FreeModuleDesc (ModuleDescPtr head) +FreeModuleDesc(ModuleDescPtr head) { - ModuleDescPtr sibs, prev; + ModuleDescPtr sibs, prev; - /* - * only free it if it's not marked as in use. In use means that it may - * be unloaded someday, and UnloadModule or UnloadDriver will free it - */ - if (head->in_use) - return; - if (head->child) - FreeModuleDesc (head->child); - sibs = head; - while (sibs) - { - prev = sibs; - sibs = sibs->sib; - TestFree (prev->name); - xfree (prev); - } + /* + * only free it if it's not marked as in use. In use means that it may + * be unloaded someday, and UnloadModule or UnloadDriver will free it + */ + if (head->in_use) + return; + if (head->child) + FreeModuleDesc(head->child); + sibs = head; + while (sibs) { + prev = sibs; + sibs = sibs->sib; + TestFree(prev->name); + xfree(prev); + } } ModuleDescPtr -NewModuleDesc (const char *name) +NewModuleDesc(const char *name) { - ModuleDescPtr mdp = xalloc (sizeof (ModuleDesc)); - - if (mdp) - { - mdp->child = NULL; - mdp->sib = NULL; - mdp->parent = NULL; - mdp->demand_next = NULL; - mdp->name = xstrdup (name); - mdp->filename = NULL; - mdp->identifier = NULL; - mdp->client_id = 0; - mdp->in_use = 0; - mdp->handle = -1; - mdp->SetupProc = NULL; - mdp->TearDownProc = NULL; - mdp->TearDownData = NULL; - } - - return (mdp); + ModuleDescPtr mdp = xalloc(sizeof(ModuleDesc)); + + if (mdp) { + mdp->child = NULL; + mdp->sib = NULL; + mdp->parent = NULL; + mdp->demand_next = NULL; + mdp->name = xstrdup(name); + mdp->filename = NULL; + mdp->identifier = NULL; + mdp->client_id = 0; + mdp->in_use = 0; + mdp->handle = -1; + mdp->SetupProc = NULL; + mdp->TearDownProc = NULL; + mdp->TearDownData = NULL; + } + + return (mdp); } ModuleDescPtr -AddSibling (ModuleDescPtr head, ModuleDescPtr new) +AddSibling(ModuleDescPtr head, ModuleDescPtr new) { new->sib = head; return (new); @@ -1155,142 +1173,140 @@ AddSibling (ModuleDescPtr head, ModuleDescPtr new) } static void -RemoveChild (ModuleDescPtr child) +RemoveChild(ModuleDescPtr child) { - ModuleDescPtr mdp; - ModuleDescPtr prevsib; - ModuleDescPtr parent; + ModuleDescPtr mdp; + ModuleDescPtr prevsib; + ModuleDescPtr parent; - if (!child->parent) - return; - - parent = child->parent; - if (parent->child == child) { - parent->child = child->sib; - return; - } + if (!child->parent) + return; - prevsib = parent->child; - mdp = prevsib->sib; - while (mdp && mdp != child) { - prevsib = mdp; - mdp = mdp->sib; - } - if (mdp == child) - prevsib->sib = child->sib; + parent = child->parent; + if (parent->child == child) { + parent->child = child->sib; return; + } + + prevsib = parent->child; + mdp = prevsib->sib; + while (mdp && mdp != child) { + prevsib = mdp; + mdp = mdp->sib; + } + if (mdp == child) + prevsib->sib = child->sib; + return; } void LoaderErrorMsg(const char *name, const char *modname, int errmaj, int errmin) { - const char *msg; - - switch (errmaj) { - case LDR_NOERROR: - msg = "no error"; - break; - case LDR_NOMEM: - msg = "out of memory"; - break; - case LDR_NOENT: - msg = "module does not exist"; - break; - case LDR_NOSUBENT: - msg = "a required submodule could not be loaded"; - break; - case LDR_NOSPACE: - msg = "too many modules"; - break; - case LDR_NOMODOPEN: - msg = "open failed"; - break; - case LDR_UNKTYPE: - msg = "unknown module type"; - break; - case LDR_NOLOAD: - msg = "loader failed"; - break; - case LDR_ONCEONLY: - msg = "once-only module"; - break; - case LDR_NOPORTOPEN: - msg = "port open failed"; - break; - case LDR_NOHARDWARE: - msg = "no hardware found"; - break; - case LDR_MISMATCH: - msg = "module requirement mismatch"; - break; - case LDR_BADUSAGE: - msg = "invalid argument(s) to LoadModule()"; - break; - case LDR_INVALID: - msg = "invalid module"; - break; - case LDR_BADOS: - msg = "module doesn't support this OS"; - break; - case LDR_MODSPECIFIC: - msg = "module-specific error"; - break; - default: - msg = "uknown error"; - } - if (name) - xf86Msg(X_ERROR, "%s: Failed to load module \"%s\" (%s, %d)\n", - name, modname, msg, errmin); - else - xf86Msg(X_ERROR, "Failed to load module \"%s\" (%s, %d)\n", - modname, msg, errmin); + const char *msg; + + switch (errmaj) { + case LDR_NOERROR: + msg = "no error"; + break; + case LDR_NOMEM: + msg = "out of memory"; + break; + case LDR_NOENT: + msg = "module does not exist"; + break; + case LDR_NOSUBENT: + msg = "a required submodule could not be loaded"; + break; + case LDR_NOSPACE: + msg = "too many modules"; + break; + case LDR_NOMODOPEN: + msg = "open failed"; + break; + case LDR_UNKTYPE: + msg = "unknown module type"; + break; + case LDR_NOLOAD: + msg = "loader failed"; + break; + case LDR_ONCEONLY: + msg = "once-only module"; + break; + case LDR_NOPORTOPEN: + msg = "port open failed"; + break; + case LDR_NOHARDWARE: + msg = "no hardware found"; + break; + case LDR_MISMATCH: + msg = "module requirement mismatch"; + break; + case LDR_BADUSAGE: + msg = "invalid argument(s) to LoadModule()"; + break; + case LDR_INVALID: + msg = "invalid module"; + break; + case LDR_BADOS: + msg = "module doesn't support this OS"; + break; + case LDR_MODSPECIFIC: + msg = "module-specific error"; + break; + default: + msg = "uknown error"; + } + if (name) + xf86Msg(X_ERROR, "%s: Failed to load module \"%s\" (%s, %d)\n", + name, modname, msg, errmin); + else + xf86Msg(X_ERROR, "Failed to load module \"%s\" (%s, %d)\n", + modname, msg, errmin); } - /* Given a module path or file name, return the module's canonical name */ static char * LoaderGetCanonicalName(const char *modname, PatternPtr patterns) { - char *str; - const char *s; - int len; - PatternPtr p; - regmatch_t match[2]; - - /* Strip off any leading path */ - s = strrchr(modname, '/'); - if (s == NULL) - s = modname; - else - s++; - - /* Find the first regex that is matched */ - for (p = patterns; p->pattern; p++) - if (regexec(&p->rex, s, 2, match, 0) == 0 && - match[1].rm_so != -1) { - len = match[1].rm_eo - match[1].rm_so; - str = xalloc(len + 1); - if (!str) - return NULL; - strncpy(str, s + match[1].rm_so, len); - str[len] = '\0'; - return str; - } + char *str; + const char *s; + int len; + PatternPtr p; + regmatch_t match[2]; + + /* Strip off any leading path */ + s = strrchr(modname, '/'); + if (s == NULL) + s = modname; + else + s++; + + /* Find the first regex that is matched */ + for (p = patterns; p->pattern; p++) + if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) { + len = match[1].rm_eo - match[1].rm_so; + str = xalloc(len + 1); + if (!str) + return NULL; + strncpy(str, s + match[1].rm_so, len); + str[len] = '\0'; + return str; + } - /* If there is no match, return the whole name minus the leading path */ - return xstrdup(s); + /* If there is no match, return the whole name minus the leading path */ + return xstrdup(s); } /* * Return the module version information. */ unsigned long -LoaderGetModuleVersion (ModuleDescPtr mod) +LoaderGetModuleVersion(ModuleDescPtr mod) { if (!mod || !mod->VersionInfo) - return 0; + return 0; return MODULE_VERSION_NUMERIC(mod->VersionInfo->majorversion, - mod->VersionInfo->minorversion, - mod->VersionInfo->patchlevel); + mod->VersionInfo->minorversion, + mod->VersionInfo->patchlevel); } diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c index 989978330..c2bf47587 100644 --- a/hw/xfree86/loader/misym.c +++ b/hw/xfree86/loader/misym.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.35 2002/09/16 18:06:11 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.38 2003/10/15 16:29:04 dawes Exp $ */ /* * @@ -22,6 +22,34 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ + +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + #include "sym.h" #include "misc.h" #include "mi.h" @@ -49,132 +77,133 @@ extern miPointerSpriteFuncRec miSpritePointerFuncs; LOOKUP miLookupTab[] = { - SYMFUNC(miClearToBackground) - SYMFUNC(miSendGraphicsExpose) - SYMFUNC(miModifyPixmapHeader) - SYMFUNC(miHandleValidateExposures) - SYMFUNC(miSetShape) - SYMFUNC(miChangeBorderWidth) - SYMFUNC(miShapedWindowIn) - SYMFUNC(miRectIn) - SYMFUNC(miZeroClipLine) - SYMFUNC(miZeroDashLine) - SYMFUNC(miClearDrawable) - SYMFUNC(miPolyPoint) - SYMFUNC(miStepDash) - SYMFUNC(miEmptyBox) - SYMFUNC(miEmptyData) - SYMFUNC(miIntersect) - SYMFUNC(miRegionAppend) - SYMFUNC(miRegionCopy) - SYMFUNC(miRegionDestroy) - SYMFUNC(miRegionEmpty) - SYMFUNC(miRegionExtents) - SYMFUNC(miRegionInit) - SYMFUNC(miRegionNotEmpty) - SYMFUNC(miRegionReset) - SYMFUNC(miRegionUninit) - SYMFUNC(miRegionValidate) - SYMFUNC(miTranslateRegion) - SYMFUNC(miHandleExposures) - SYMFUNC(miPolyFillRect) - SYMFUNC(miPolyFillArc) - SYMFUNC(miImageGlyphBlt) - SYMFUNC(miPolyGlyphBlt) - SYMFUNC(miFillPolygon) - SYMFUNC(miFillConvexPoly) - SYMFUNC(miPolySegment) - SYMFUNC(miZeroLine) - SYMFUNC(miWideLine) - SYMFUNC(miWideDash) - SYMFUNC(miZeroPolyArc) - SYMFUNC(miPolyArc) - SYMFUNC(miCreateGCOps) - SYMFUNC(miDestroyGCOps) - SYMFUNC(miComputeCompositeClip) - SYMFUNC(miChangeGC) - SYMFUNC(miCopyGC) - SYMFUNC(miDestroyGC) - SYMFUNC(miChangeClip) - SYMFUNC(miDestroyClip) - SYMFUNC(miCopyClip) - SYMFUNC(miPolyRectangle) - SYMFUNC(miPolyText8) - SYMFUNC(miPolyText16) - SYMFUNC(miImageText8) - SYMFUNC(miImageText16) - SYMFUNC(miRegionCreate) - SYMFUNC(miPaintWindow) - SYMFUNC(miZeroArcSetup) - SYMFUNC(miFillArcSetup) - SYMFUNC(miFillArcSliceSetup) - SYMFUNC(miFindMaxBand) - SYMFUNC(miClipSpans) - SYMFUNC(miAllocateGCPrivateIndex) - SYMFUNC(miScreenInit) - SYMFUNC(miGetScreenPixmap) - SYMFUNC(miSetScreenPixmap) - SYMFUNC(miPointerCurrentScreen) - SYMFUNC(miRectAlloc) - SYMFUNC(miInitializeBackingStore) - SYMFUNC(miInitializeBanking) - SYMFUNC(miModifyBanking) - SYMFUNC(miCopyPlane) - SYMFUNC(miCopyArea) - SYMFUNC(miCreateScreenResources) - SYMFUNC(miGetImage) - SYMFUNC(miPutImage) - SYMFUNC(miPushPixels) - SYMFUNC(miPointerInitialize) - SYMFUNC(miPointerPosition) - SYMFUNC(miRecolorCursor) - SYMFUNC(miPointerWarpCursor) - SYMFUNC(miDCInitialize) - SYMFUNC(miRectsToRegion) - SYMFUNC(miPointInRegion) - SYMFUNC(miInverse) - SYMFUNC(miSubtract) - SYMFUNC(miUnion) - SYMFUNC(miPolyBuildEdge) - SYMFUNC(miPolyBuildPoly) - SYMFUNC(miRoundJoinClip) - SYMFUNC(miRoundCapClip) - SYMFUNC(miSetZeroLineBias) - SYMFUNC(miResolveColor) - SYMFUNC(miInitializeColormap) - SYMFUNC(miInstallColormap) - SYMFUNC(miUninstallColormap) - SYMFUNC(miListInstalledColormaps) - SYMFUNC(miExpandDirectColors) - SYMFUNC(miCreateDefColormap) - SYMFUNC(miClearVisualTypes) - SYMFUNC(miSetVisualTypes) - SYMFUNC(miSetVisualTypesAndMasks) - SYMFUNC(miGetDefaultVisualMask) - SYMFUNC(miSetPixmapDepths) - SYMFUNC(miInitVisuals) - SYMFUNC(miWindowExposures) - SYMFUNC(miSegregateChildren) - SYMFUNC(miClipNotify) - SYMFUNC(miHookInitVisuals) - SYMFUNC(miPointerAbsoluteCursor) - SYMFUNC(miPointerGetMotionEvents) - SYMFUNC(miPointerGetMotionBufferSize) - SYMFUNC(miOverlayCopyUnderlay) - SYMFUNC(miOverlaySetTransFunction) - SYMFUNC(miOverlayCollectUnderlayRegions) - SYMFUNC(miInitOverlay) - SYMFUNC(miOverlayComputeCompositeClip) - SYMFUNC(miOverlayGetPrivateClips) - SYMFUNC(miOverlaySetRootClip) - SYMVAR(miZeroLineScreenIndex) - SYMVAR(miSpritePointerFuncs) - SYMVAR(miPointerScreenIndex) - SYMVAR(miInstalledMaps) - SYMVAR(miInitVisualsProc) + SYMFUNC(miClearToBackground) + SYMFUNC(miSendGraphicsExpose) + SYMFUNC(miModifyPixmapHeader) + SYMFUNC(miHandleValidateExposures) + SYMFUNC(miSetShape) + SYMFUNC(miChangeBorderWidth) + SYMFUNC(miShapedWindowIn) + SYMFUNC(miRectIn) + SYMFUNC(miZeroClipLine) + SYMFUNC(miZeroDashLine) + SYMFUNC(miClearDrawable) + SYMFUNC(miPolyPoint) + SYMFUNC(miStepDash) + SYMFUNC(miEmptyBox) + SYMFUNC(miEmptyData) + SYMFUNC(miIntersect) + SYMFUNC(miRegionAppend) + SYMFUNC(miRegionCopy) + SYMFUNC(miRegionDestroy) + SYMFUNC(miRegionEmpty) + SYMFUNC(miRegionExtents) + SYMFUNC(miRegionInit) + SYMFUNC(miRegionNotEmpty) + SYMFUNC(miRegionEqual) + SYMFUNC(miRegionReset) + SYMFUNC(miRegionUninit) + SYMFUNC(miRegionValidate) + SYMFUNC(miTranslateRegion) + SYMFUNC(miHandleExposures) + SYMFUNC(miPolyFillRect) + SYMFUNC(miPolyFillArc) + SYMFUNC(miImageGlyphBlt) + SYMFUNC(miPolyGlyphBlt) + SYMFUNC(miFillPolygon) + SYMFUNC(miFillConvexPoly) + SYMFUNC(miPolySegment) + SYMFUNC(miZeroLine) + SYMFUNC(miWideLine) + SYMFUNC(miWideDash) + SYMFUNC(miZeroPolyArc) + SYMFUNC(miPolyArc) + SYMFUNC(miCreateGCOps) + SYMFUNC(miDestroyGCOps) + SYMFUNC(miComputeCompositeClip) + SYMFUNC(miChangeGC) + SYMFUNC(miCopyGC) + SYMFUNC(miDestroyGC) + SYMFUNC(miChangeClip) + SYMFUNC(miDestroyClip) + SYMFUNC(miCopyClip) + SYMFUNC(miPolyRectangle) + SYMFUNC(miPolyText8) + SYMFUNC(miPolyText16) + SYMFUNC(miImageText8) + SYMFUNC(miImageText16) + SYMFUNC(miRegionCreate) + SYMFUNC(miPaintWindow) + SYMFUNC(miZeroArcSetup) + SYMFUNC(miFillArcSetup) + SYMFUNC(miFillArcSliceSetup) + SYMFUNC(miFindMaxBand) + SYMFUNC(miClipSpans) + SYMFUNC(miAllocateGCPrivateIndex) + SYMFUNC(miScreenInit) + SYMFUNC(miGetScreenPixmap) + SYMFUNC(miSetScreenPixmap) + SYMFUNC(miPointerCurrentScreen) + SYMFUNC(miRectAlloc) + SYMFUNC(miInitializeBackingStore) + SYMFUNC(miInitializeBanking) + SYMFUNC(miModifyBanking) + SYMFUNC(miCopyPlane) + SYMFUNC(miCopyArea) + SYMFUNC(miCreateScreenResources) + SYMFUNC(miGetImage) + SYMFUNC(miPutImage) + SYMFUNC(miPushPixels) + SYMFUNC(miPointerInitialize) + SYMFUNC(miPointerPosition) + SYMFUNC(miRecolorCursor) + SYMFUNC(miPointerWarpCursor) + SYMFUNC(miDCInitialize) + SYMFUNC(miRectsToRegion) + SYMFUNC(miPointInRegion) + SYMFUNC(miInverse) + SYMFUNC(miSubtract) + SYMFUNC(miUnion) + SYMFUNC(miPolyBuildEdge) + SYMFUNC(miPolyBuildPoly) + SYMFUNC(miRoundJoinClip) + SYMFUNC(miRoundCapClip) + SYMFUNC(miSetZeroLineBias) + SYMFUNC(miResolveColor) + SYMFUNC(miInitializeColormap) + SYMFUNC(miInstallColormap) + SYMFUNC(miUninstallColormap) + SYMFUNC(miListInstalledColormaps) + SYMFUNC(miExpandDirectColors) + SYMFUNC(miCreateDefColormap) + SYMFUNC(miClearVisualTypes) + SYMFUNC(miSetVisualTypes) + SYMFUNC(miSetVisualTypesAndMasks) + SYMFUNC(miGetDefaultVisualMask) + SYMFUNC(miSetPixmapDepths) + SYMFUNC(miInitVisuals) + SYMFUNC(miWindowExposures) + SYMFUNC(miSegregateChildren) + SYMFUNC(miClipNotify) + SYMFUNC(miHookInitVisuals) + SYMFUNC(miPointerAbsoluteCursor) + SYMFUNC(miPointerGetMotionEvents) + SYMFUNC(miPointerGetMotionBufferSize) + SYMFUNC(miOverlayCopyUnderlay) + SYMFUNC(miOverlaySetTransFunction) + SYMFUNC(miOverlayCollectUnderlayRegions) + SYMFUNC(miInitOverlay) + SYMFUNC(miOverlayComputeCompositeClip) + SYMFUNC(miOverlayGetPrivateClips) + SYMFUNC(miOverlaySetRootClip) + SYMVAR(miZeroLineScreenIndex) + SYMVAR(miSpritePointerFuncs) + SYMVAR(miPointerScreenIndex) + SYMVAR(miInstalledMaps) + SYMVAR(miInitVisualsProc) #ifdef RENDER - SYMVAR(miGlyphExtents) + SYMVAR(miGlyphExtents) #endif - { 0, 0 }, + {0, 0} }; diff --git a/hw/xfree86/loader/os.c b/hw/xfree86/loader/os.c index e2e710077..49f9c0d84 100644 --- a/hw/xfree86/loader/os.c +++ b/hw/xfree86/loader/os.c @@ -1,4 +1,31 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/os.c,v 1.2 2002/05/31 18:46:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/os.c,v 1.4 2003/10/15 16:29:04 dawes Exp $ */ + +/* + * Copyright (c) 1999-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ #include "loaderProcs.h" @@ -35,15 +62,13 @@ #define OSNAME "unknown" #endif - /* Return the OS name, and run-time OS version */ void LoaderGetOS(const char **name, int *major, int *minor, int *teeny) { - if (name) - *name = OSNAME; - - /* reporting runtime versions isn't supported yet */ -} + if (name) + *name = OSNAME; + /* reporting runtime versions isn't supported yet */ +} diff --git a/hw/xfree86/loader/sym.h b/hw/xfree86/loader/sym.h index 6ad38aa49..e937b9f08 100644 --- a/hw/xfree86/loader/sym.h +++ b/hw/xfree86/loader/sym.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/sym.h,v 1.6 2000/10/24 00:06:55 anderson Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/sym.h,v 1.7 2003/10/15 16:29:04 dawes Exp $ */ /* * @@ -31,11 +31,11 @@ * added to the symbol table. */ -typedef void (*funcptr)(void); +typedef void (*funcptr) (void); typedef struct { - char *symName; - funcptr offset; + char *symName; + funcptr offset; } LOOKUP; #define SYMFUNC( func ) { #func, (funcptr)&func }, diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 8e8bdadfc..b2823c2e5 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.227.2.1 2003/03/13 04:10:47 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.242 2003/10/27 20:51:16 herrb Exp $ */ /* * @@ -22,6 +22,32 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ #define INCLUDE_DEPRECATED 1 @@ -70,12 +96,6 @@ #endif #endif -#ifdef __FreeBSD__ -/* XXX used in drmOpen(). This should change to use a less os-specific - * method. */ -int sysctlbyname(const char*, void *, size_t *, void *, size_t); -#endif - #if defined(__alpha__) # ifdef linux extern unsigned long _bus_base(void); @@ -87,7 +107,7 @@ extern unsigned int _inw(unsigned short port); extern unsigned int _inl(unsigned short port); # endif -# ifdef __FreeBSD__ +# ifdef __FreeBSD__ # include <sys/types.h> extern void outb(u_int32_t port, u_int8_t val); extern void outw(u_int32_t port, u_int16_t val); @@ -97,25 +117,38 @@ extern u_int16_t inw(u_int32_t port); extern u_int32_t inl(u_int32_t port); # endif -extern void* __divl(long, long); -extern void* __reml(long, long); -extern void* __divlu(long, long); -extern void* __remlu(long, long); -extern void* __divq(long, long); -extern void* __divqu(long, long); -extern void* __remq(long, long); -extern void* __remqu(long, long); +extern void *__divl(long, long); +extern void *__reml(long, long); +extern void *__divlu(long, long); +extern void *__remlu(long, long); +extern void *__divq(long, long); +extern void *__divqu(long, long); +extern void *__remq(long, long); +extern void *__remqu(long, long); +#endif + +#if defined(__sparc__) && defined(__FreeBSD__) +extern float _Qp_qtos(unsigned int *); +extern double _Qp_qtod(unsigned int *); +extern unsigned long long _Qp_qtoux(unsigned int *); +extern void _Qp_dtoq(unsigned int *, double); +extern void _Qp_uitoq(unsigned int *, unsigned int); #endif #if defined(__GNUC__) +#ifndef __UNIXOS2__ extern long __div64(long, long); +#endif extern long __divdf3(long, long); extern long __divdi3(long, long); extern long __divsf3(long, long); extern long __divsi3(long, long); extern long __moddi3(long, long); extern long __modsi3(long, long); + +#ifndef __UNIXOS2__ extern long __mul64(long, long); +#endif extern long __muldf3(long, long); extern long __muldi3(long, long); extern long __mulsf3(long, long); @@ -124,14 +157,19 @@ extern long __udivdi3(long, long); extern long __udivsi3(long, long); extern long __umoddi3(long, long); extern long __umodsi3(long, long); + +#ifndef __UNIXOS2__ #pragma weak __div64 +#endif #pragma weak __divdf3 #pragma weak __divdi3 #pragma weak __divsf3 #pragma weak __divsi3 #pragma weak __moddi3 #pragma weak __modsi3 +#ifndef __UNIXOS2__ #pragma weak __mul64 +#endif #pragma weak __muldf3 #pragma weak __muldi3 #pragma weak __mulsf3 @@ -199,935 +237,912 @@ extern unsigned short ldw_brx(volatile unsigned char *, int); LOOKUP xfree86LookupTab[] = { - /* Public OSlib functions */ - SYMFUNC(xf86ReadBIOS) - SYMFUNC(xf86EnableIO) - SYMFUNC(xf86DisableIO) - SYMFUNC(xf86DisableInterrupts) - SYMFUNC(xf86EnableInterrupts) - SYMFUNC(xf86LinearVidMem) - SYMFUNC(xf86CheckMTRR) - SYMFUNC(xf86MapVidMem) - SYMFUNC(xf86UnMapVidMem) - SYMFUNC(xf86MapReadSideEffects) - SYMFUNC(xf86GetPciDomain) - SYMFUNC(xf86MapDomainMemory) - SYMFUNC(xf86MapDomainIO) - SYMFUNC(xf86ReadDomainMemory) - SYMFUNC(xf86UDelay) - SYMFUNC(xf86IODelay) - SYMFUNC(xf86SlowBcopy) + /* Public OSlib functions */ + SYMFUNC(xf86ReadBIOS) + SYMFUNC(xf86EnableIO) + SYMFUNC(xf86DisableIO) + SYMFUNC(xf86DisableInterrupts) + SYMFUNC(xf86EnableInterrupts) + SYMFUNC(xf86LinearVidMem) + SYMFUNC(xf86CheckMTRR) + SYMFUNC(xf86MapVidMem) + SYMFUNC(xf86UnMapVidMem) + SYMFUNC(xf86MapReadSideEffects) + SYMFUNC(xf86GetPciDomain) + SYMFUNC(xf86MapDomainMemory) + SYMFUNC(xf86MapDomainIO) + SYMFUNC(xf86ReadDomainMemory) + SYMFUNC(xf86UDelay) + SYMFUNC(xf86IODelay) + SYMFUNC(xf86SlowBcopy) #ifdef __alpha__ - SYMFUNC(xf86SlowBCopyToBus) - SYMFUNC(xf86SlowBCopyFromBus) + SYMFUNC(xf86SlowBCopyToBus) + SYMFUNC(xf86SlowBCopyFromBus) #endif - SYMFUNC(xf86BusToMem) - SYMFUNC(xf86MemToBus) - SYMFUNC(xf86OpenSerial) - SYMFUNC(xf86SetSerial) - SYMFUNC(xf86SetSerialSpeed) - SYMFUNC(xf86ReadSerial) - SYMFUNC(xf86WriteSerial) - SYMFUNC(xf86CloseSerial) - SYMFUNC(xf86GetErrno) - SYMFUNC(xf86WaitForInput) - SYMFUNC(xf86SerialSendBreak) - SYMFUNC(xf86FlushInput) - SYMFUNC(xf86SetSerialModemState) - SYMFUNC(xf86GetSerialModemState) - SYMFUNC(xf86SerialModemSetBits) - SYMFUNC(xf86SerialModemClearBits) - SYMFUNC(xf86LoadKernelModule) - SYMFUNC(xf86OSMouseInit) - SYMFUNC(xf86OSKbdPreInit) - SYMFUNC(xf86AgpGARTSupported) - SYMFUNC(xf86GetAGPInfo) - SYMFUNC(xf86AcquireGART) - SYMFUNC(xf86ReleaseGART) - SYMFUNC(xf86AllocateGARTMemory) - SYMFUNC(xf86BindGARTMemory) - SYMFUNC(xf86UnbindGARTMemory) - SYMFUNC(xf86EnableAGP) - SYMFUNC(xf86SoundKbdBell) - SYMFUNC(xf86GARTCloseScreen) + SYMFUNC(xf86BusToMem) + SYMFUNC(xf86MemToBus) + SYMFUNC(xf86OpenSerial) + SYMFUNC(xf86SetSerial) + SYMFUNC(xf86SetSerialSpeed) + SYMFUNC(xf86ReadSerial) + SYMFUNC(xf86WriteSerial) + SYMFUNC(xf86CloseSerial) + SYMFUNC(xf86GetErrno) + SYMFUNC(xf86WaitForInput) + SYMFUNC(xf86SerialSendBreak) + SYMFUNC(xf86FlushInput) + SYMFUNC(xf86SetSerialModemState) + SYMFUNC(xf86GetSerialModemState) + SYMFUNC(xf86SerialModemSetBits) + SYMFUNC(xf86SerialModemClearBits) + SYMFUNC(xf86LoadKernelModule) + SYMFUNC(xf86OSMouseInit) + SYMFUNC(xf86OSKbdPreInit) + SYMFUNC(xf86AgpGARTSupported) + SYMFUNC(xf86GetAGPInfo) + SYMFUNC(xf86AcquireGART) + SYMFUNC(xf86ReleaseGART) + SYMFUNC(xf86AllocateGARTMemory) + SYMFUNC(xf86BindGARTMemory) + SYMFUNC(xf86UnbindGARTMemory) + SYMFUNC(xf86EnableAGP) + SYMFUNC(xf86SoundKbdBell) + SYMFUNC(xf86GARTCloseScreen) #ifdef XINPUT -/* XISB routines (Merged from Metrolink tree) */ - SYMFUNC(XisbNew) - SYMFUNC(XisbFree) - SYMFUNC(XisbRead) - SYMFUNC(XisbWrite) - SYMFUNC(XisbTrace) - SYMFUNC(XisbBlockDuration) + /* XISB routines (Merged from Metrolink tree) */ + SYMFUNC(XisbNew) + SYMFUNC(XisbFree) + SYMFUNC(XisbRead) + SYMFUNC(XisbWrite) + SYMFUNC(XisbTrace) + SYMFUNC(XisbBlockDuration) #endif - /* xf86Bus.c */ - SYMFUNC(xf86CheckPciSlot) - SYMFUNC(xf86ClaimPciSlot) - SYMFUNC(xf86GetPciVideoInfo) - SYMFUNC(xf86GetPciEntity) - SYMFUNC(xf86GetPciConfigInfo) - SYMFUNC(xf86SetPciVideo) - SYMFUNC(xf86ClaimIsaSlot) - SYMFUNC(xf86ClaimFbSlot) - SYMFUNC(xf86ClaimNoSlot) - SYMFUNC(xf86ParsePciBusString) - SYMFUNC(xf86ComparePciBusString) - SYMFUNC(xf86FormatPciBusNumber) - SYMFUNC(xf86ParseIsaBusString) - SYMFUNC(xf86EnableAccess) - SYMFUNC(xf86SetCurrentAccess) - SYMFUNC(xf86IsPrimaryPci) - SYMFUNC(xf86IsPrimaryIsa) - SYMFUNC(xf86CheckPciGAType) - SYMFUNC(xf86PrintResList) - SYMFUNC(xf86AddResToList) - SYMFUNC(xf86JoinResLists) - SYMFUNC(xf86DupResList) - SYMFUNC(xf86FreeResList) - SYMFUNC(xf86ClaimFixedResources) - SYMFUNC(xf86AddEntityToScreen) - SYMFUNC(xf86SetEntityInstanceForScreen) - SYMFUNC(xf86RemoveEntityFromScreen) - SYMFUNC(xf86GetEntityInfo) - SYMFUNC(xf86GetNumEntityInstances) - SYMFUNC(xf86GetDevFromEntity) - SYMFUNC(xf86GetPciInfoForEntity) - SYMFUNC(xf86SetEntityFuncs) - SYMFUNC(xf86DeallocateResourcesForEntity) - SYMFUNC(xf86RegisterResources) - SYMFUNC(xf86CheckPciMemBase) - SYMFUNC(xf86SetAccessFuncs) - SYMFUNC(xf86IsEntityPrimary) - SYMFUNC(xf86FixPciResource) - SYMFUNC(xf86SetOperatingState) - SYMFUNC(xf86EnterServerState) - SYMFUNC(xf86GetBlock) - SYMFUNC(xf86GetSparse) - SYMFUNC(xf86ReallocatePciResources) - SYMFUNC(xf86ChkConflict) - SYMFUNC(xf86IsPciDevPresent) - SYMFUNC(xf86FindScreenForEntity) - SYMFUNC(xf86FindPciDeviceVendor) - SYMFUNC(xf86FindPciClass) + /* xf86Bus.c */ + SYMFUNC(xf86CheckPciSlot) + SYMFUNC(xf86ClaimPciSlot) + SYMFUNC(xf86GetPciVideoInfo) + SYMFUNC(xf86GetPciEntity) + SYMFUNC(xf86GetPciConfigInfo) + SYMFUNC(xf86SetPciVideo) + SYMFUNC(xf86ClaimIsaSlot) + SYMFUNC(xf86ClaimFbSlot) + SYMFUNC(xf86ClaimNoSlot) + SYMFUNC(xf86ParsePciBusString) + SYMFUNC(xf86ComparePciBusString) + SYMFUNC(xf86FormatPciBusNumber) + SYMFUNC(xf86ParseIsaBusString) + SYMFUNC(xf86EnableAccess) + SYMFUNC(xf86SetCurrentAccess) + SYMFUNC(xf86IsPrimaryPci) + SYMFUNC(xf86IsPrimaryIsa) + SYMFUNC(xf86CheckPciGAType) + SYMFUNC(xf86PrintResList) + SYMFUNC(xf86AddResToList) + SYMFUNC(xf86JoinResLists) + SYMFUNC(xf86DupResList) + SYMFUNC(xf86FreeResList) + SYMFUNC(xf86ClaimFixedResources) + SYMFUNC(xf86AddEntityToScreen) + SYMFUNC(xf86SetEntityInstanceForScreen) + SYMFUNC(xf86RemoveEntityFromScreen) + SYMFUNC(xf86GetEntityInfo) + SYMFUNC(xf86GetNumEntityInstances) + SYMFUNC(xf86GetDevFromEntity) + SYMFUNC(xf86GetPciInfoForEntity) + SYMFUNC(xf86SetEntityFuncs) + SYMFUNC(xf86DeallocateResourcesForEntity) + SYMFUNC(xf86RegisterResources) + SYMFUNC(xf86CheckPciMemBase) + SYMFUNC(xf86SetAccessFuncs) + SYMFUNC(xf86IsEntityPrimary) + SYMFUNC(xf86FixPciResource) + SYMFUNC(xf86SetOperatingState) + SYMFUNC(xf86EnterServerState) + SYMFUNC(xf86GetBlock) + SYMFUNC(xf86GetSparse) + SYMFUNC(xf86ReallocatePciResources) + SYMFUNC(xf86ChkConflict) + SYMFUNC(xf86IsPciDevPresent) + SYMFUNC(xf86FindScreenForEntity) + SYMFUNC(xf86FindPciDeviceVendor) + SYMFUNC(xf86FindPciClass) #ifdef INCLUDE_DEPRECATED - SYMFUNC(xf86EnablePciBusMaster) + SYMFUNC(xf86EnablePciBusMaster) #endif - SYMFUNC(xf86RegisterStateChangeNotificationCallback) - SYMFUNC(xf86DeregisterStateChangeNotificationCallback) - SYMFUNC(xf86NoSharedResources) + SYMFUNC(xf86RegisterStateChangeNotificationCallback) + SYMFUNC(xf86DeregisterStateChangeNotificationCallback) + SYMFUNC(xf86NoSharedResources) #ifdef async - SYMFUNC(xf86QueueAsyncEvent) + SYMFUNC(xf86QueueAsyncEvent) #endif - /* Shared Accel Accessor Functions */ - SYMFUNC(xf86GetLastScrnFlag) - SYMFUNC(xf86SetLastScrnFlag) - SYMFUNC(xf86IsEntityShared) - SYMFUNC(xf86SetEntityShared) - SYMFUNC(xf86IsEntitySharable) - SYMFUNC(xf86SetEntitySharable) - SYMFUNC(xf86IsPrimInitDone) - SYMFUNC(xf86SetPrimInitDone) - SYMFUNC(xf86ClearPrimInitDone) - SYMFUNC(xf86AllocateEntityPrivateIndex) - SYMFUNC(xf86GetEntityPrivate) - - /* xf86Configure.c */ - SYMFUNC(xf86AddDeviceToConfigure) - - /* xf86Cursor.c */ - SYMFUNC(xf86GetPointerScreenFuncs) + /* Shared Accel Accessor Functions */ + SYMFUNC(xf86GetLastScrnFlag) + SYMFUNC(xf86SetLastScrnFlag) + SYMFUNC(xf86IsEntityShared) + SYMFUNC(xf86SetEntityShared) + SYMFUNC(xf86IsEntitySharable) + SYMFUNC(xf86SetEntitySharable) + SYMFUNC(xf86IsPrimInitDone) + SYMFUNC(xf86SetPrimInitDone) + SYMFUNC(xf86ClearPrimInitDone) + SYMFUNC(xf86AllocateEntityPrivateIndex) + SYMFUNC(xf86GetEntityPrivate) + + /* xf86Configure.c */ + SYMFUNC(xf86AddDeviceToConfigure) + + /* xf86Cursor.c */ + SYMFUNC(xf86GetPointerScreenFuncs) - /* xf86DGA.c */ - /* For drivers */ - SYMFUNC(DGAInit) - /* For extmod */ - SYMFUNC(DGAAvailable) - SYMFUNC(DGAActive) - SYMFUNC(DGASetMode) - SYMFUNC(DGASetInputMode) - SYMFUNC(DGASelectInput) - SYMFUNC(DGAGetViewportStatus) - SYMFUNC(DGASetViewport) - SYMFUNC(DGAInstallCmap) - SYMFUNC(DGASync) - SYMFUNC(DGAFillRect) - SYMFUNC(DGABlitRect) - SYMFUNC(DGABlitTransRect) - SYMFUNC(DGAGetModes) - SYMFUNC(DGAGetOldDGAMode) - SYMFUNC(DGAGetModeInfo) - SYMFUNC(DGAChangePixmapMode) - SYMFUNC(DGACreateColormap) - SYMFUNC(DGAOpenFramebuffer) - SYMFUNC(DGACloseFramebuffer) + /* xf86DGA.c */ + /* For drivers */ + SYMFUNC(DGAInit) + /* For extmod */ + SYMFUNC(DGAAvailable) + SYMFUNC(DGAActive) + SYMFUNC(DGASetMode) + SYMFUNC(DGASetInputMode) + SYMFUNC(DGASelectInput) + SYMFUNC(DGAGetViewportStatus) + SYMFUNC(DGASetViewport) + SYMFUNC(DGAInstallCmap) + SYMFUNC(DGASync) + SYMFUNC(DGAFillRect) + SYMFUNC(DGABlitRect) + SYMFUNC(DGABlitTransRect) + SYMFUNC(DGAGetModes) + SYMFUNC(DGAGetOldDGAMode) + SYMFUNC(DGAGetModeInfo) + SYMFUNC(DGAChangePixmapMode) + SYMFUNC(DGACreateColormap) + SYMFUNC(DGAOpenFramebuffer) + SYMFUNC(DGACloseFramebuffer) - /* xf86DPMS.c */ - SYMFUNC(xf86DPMSInit) + /* xf86DPMS.c */ + SYMFUNC(xf86DPMSInit) - /* xf86Events.c */ - SYMFUNC(SetTimeSinceLastInputEvent) - SYMFUNC(xf86AddInputHandler) - SYMFUNC(xf86RemoveInputHandler) - SYMFUNC(xf86DisableInputHandler) - SYMFUNC(xf86EnableInputHandler) - SYMFUNC(xf86AddEnabledDevice) - SYMFUNC(xf86RemoveEnabledDevice) - SYMFUNC(xf86InterceptSignals) - SYMFUNC(xf86EnableVTSwitch) + /* xf86Events.c */ + SYMFUNC(SetTimeSinceLastInputEvent) + SYMFUNC(xf86AddInputHandler) + SYMFUNC(xf86RemoveInputHandler) + SYMFUNC(xf86DisableInputHandler) + SYMFUNC(xf86EnableInputHandler) + SYMFUNC(xf86AddEnabledDevice) + SYMFUNC(xf86RemoveEnabledDevice) + SYMFUNC(xf86InterceptSignals) + SYMFUNC(xf86EnableVTSwitch) - /* xf86Helper.c */ - SYMFUNC(xf86AddDriver) - SYMFUNC(xf86AddInputDriver) - SYMFUNC(xf86DeleteDriver) - SYMFUNC(xf86DeleteInput) - SYMFUNC(xf86AllocateInput) - SYMFUNC(xf86AllocateScreen) - SYMFUNC(xf86DeleteScreen) - SYMFUNC(xf86AllocateScrnInfoPrivateIndex) - SYMFUNC(xf86AddPixFormat) - SYMFUNC(xf86SetDepthBpp) - SYMFUNC(xf86PrintDepthBpp) - SYMFUNC(xf86SetWeight) - SYMFUNC(xf86SetDefaultVisual) - SYMFUNC(xf86SetGamma) - SYMFUNC(xf86SetDpi) - SYMFUNC(xf86SetBlackWhitePixels) - SYMFUNC(xf86EnableDisableFBAccess) - SYMFUNC(xf86VDrvMsgVerb) - SYMFUNC(xf86DrvMsgVerb) - SYMFUNC(xf86DrvMsg) - SYMFUNC(xf86MsgVerb) - SYMFUNC(xf86Msg) - SYMFUNC(xf86ErrorFVerb) - SYMFUNC(xf86ErrorF) - SYMFUNC(xf86TokenToString) - SYMFUNC(xf86StringToToken) - SYMFUNC(xf86ShowClocks) - SYMFUNC(xf86PrintChipsets) - SYMFUNC(xf86MatchDevice) - SYMFUNC(xf86MatchPciInstances) - SYMFUNC(xf86MatchIsaInstances) - SYMFUNC(xf86GetVerbosity) - SYMFUNC(xf86GetVisualName) - SYMFUNC(xf86GetPix24) - SYMFUNC(xf86GetDepth) - SYMFUNC(xf86GetWeight) - SYMFUNC(xf86GetGamma) - SYMFUNC(xf86GetFlipPixels) - SYMFUNC(xf86GetServerName) - SYMFUNC(xf86ServerIsExiting) - SYMFUNC(xf86ServerIsOnlyDetecting) - SYMFUNC(xf86ServerIsOnlyProbing) - SYMFUNC(xf86ServerIsResetting) - SYMFUNC(xf86CaughtSignal) - SYMFUNC(xf86GetVidModeAllowNonLocal) - SYMFUNC(xf86GetVidModeEnabled) - SYMFUNC(xf86GetModInDevAllowNonLocal) - SYMFUNC(xf86GetModInDevEnabled) - SYMFUNC(xf86GetAllowMouseOpenFail) - SYMFUNC(xf86CommonSpecialKey) - SYMFUNC(xf86IsPc98) - SYMFUNC(xf86DisableRandR) - SYMFUNC(xf86GetVersion) - SYMFUNC(xf86GetModuleVersion) - SYMFUNC(xf86GetClocks) - SYMFUNC(xf86SetPriority) - SYMFUNC(xf86LoadDrvSubModule) - SYMFUNC(xf86LoadSubModule) - SYMFUNC(xf86LoadOneModule) - SYMFUNC(xf86UnloadSubModule) - SYMFUNC(xf86LoaderCheckSymbol) - SYMFUNC(xf86LoaderRefSymLists) - SYMFUNC(xf86LoaderRefSymbols) - SYMFUNC(xf86LoaderReqSymLists) - SYMFUNC(xf86LoaderReqSymbols) - SYMFUNC(xf86SetBackingStore) - SYMFUNC(xf86SetSilkenMouse) - /* SYMFUNC(xf86NewSerialNumber) */ - SYMFUNC(xf86FindXvOptions) - SYMFUNC(xf86GetOS) - SYMFUNC(xf86ConfigPciEntity) - SYMFUNC(xf86ConfigIsaEntity) - SYMFUNC(xf86ConfigFbEntity) - SYMFUNC(xf86ConfigActivePciEntity) - SYMFUNC(xf86ConfigActiveIsaEntity) - SYMFUNC(xf86ConfigPciEntityInactive) - SYMFUNC(xf86ConfigIsaEntityInactive) - SYMFUNC(xf86IsScreenPrimary) - SYMFUNC(xf86RegisterRootWindowProperty) - SYMFUNC(xf86IsUnblank) - SYMFUNC(xf86AddModuleInfo) - SYMFUNC(xf86DeleteModuleInfo) + /* xf86Helper.c */ + SYMFUNC(xf86AddDriver) + SYMFUNC(xf86AddInputDriver) + SYMFUNC(xf86DeleteDriver) + SYMFUNC(xf86DeleteInput) + SYMFUNC(xf86AllocateInput) + SYMFUNC(xf86AllocateScreen) + SYMFUNC(xf86DeleteScreen) + SYMFUNC(xf86AllocateScrnInfoPrivateIndex) + SYMFUNC(xf86AddPixFormat) + SYMFUNC(xf86SetDepthBpp) + SYMFUNC(xf86PrintDepthBpp) + SYMFUNC(xf86SetWeight) + SYMFUNC(xf86SetDefaultVisual) + SYMFUNC(xf86SetGamma) + SYMFUNC(xf86SetDpi) + SYMFUNC(xf86SetBlackWhitePixels) + SYMFUNC(xf86EnableDisableFBAccess) + SYMFUNC(xf86VDrvMsgVerb) + SYMFUNC(xf86DrvMsgVerb) + SYMFUNC(xf86DrvMsg) + SYMFUNC(xf86MsgVerb) + SYMFUNC(xf86Msg) + SYMFUNC(xf86ErrorFVerb) + SYMFUNC(xf86ErrorF) + SYMFUNC(xf86TokenToString) + SYMFUNC(xf86StringToToken) + SYMFUNC(xf86ShowClocks) + SYMFUNC(xf86PrintChipsets) + SYMFUNC(xf86MatchDevice) + SYMFUNC(xf86MatchPciInstances) + SYMFUNC(xf86MatchIsaInstances) + SYMFUNC(xf86GetVerbosity) + SYMFUNC(xf86GetVisualName) + SYMFUNC(xf86GetPix24) + SYMFUNC(xf86GetDepth) + SYMFUNC(xf86GetWeight) + SYMFUNC(xf86GetGamma) + SYMFUNC(xf86GetFlipPixels) + SYMFUNC(xf86GetServerName) + SYMFUNC(xf86ServerIsExiting) + SYMFUNC(xf86ServerIsOnlyDetecting) + SYMFUNC(xf86ServerIsOnlyProbing) + SYMFUNC(xf86ServerIsResetting) + SYMFUNC(xf86CaughtSignal) + SYMFUNC(xf86GetVidModeAllowNonLocal) + SYMFUNC(xf86GetVidModeEnabled) + SYMFUNC(xf86GetModInDevAllowNonLocal) + SYMFUNC(xf86GetModInDevEnabled) + SYMFUNC(xf86GetAllowMouseOpenFail) + SYMFUNC(xf86CommonSpecialKey) + SYMFUNC(xf86IsPc98) + SYMFUNC(xf86DisableRandR) + SYMFUNC(xf86GetVersion) + SYMFUNC(xf86GetModuleVersion) + SYMFUNC(xf86GetClocks) + SYMFUNC(xf86SetPriority) + SYMFUNC(xf86LoadDrvSubModule) + SYMFUNC(xf86LoadSubModule) + SYMFUNC(xf86LoadOneModule) + SYMFUNC(xf86UnloadSubModule) + SYMFUNC(xf86LoaderCheckSymbol) + SYMFUNC(xf86LoaderRefSymLists) + SYMFUNC(xf86LoaderRefSymbols) + SYMFUNC(xf86LoaderReqSymLists) + SYMFUNC(xf86LoaderReqSymbols) + SYMFUNC(xf86SetBackingStore) + SYMFUNC(xf86SetSilkenMouse) + /* SYMFUNC(xf86NewSerialNumber) */ + SYMFUNC(xf86FindXvOptions) + SYMFUNC(xf86GetOS) + SYMFUNC(xf86ConfigPciEntity) + SYMFUNC(xf86ConfigIsaEntity) + SYMFUNC(xf86ConfigFbEntity) + SYMFUNC(xf86ConfigActivePciEntity) + SYMFUNC(xf86ConfigActiveIsaEntity) + SYMFUNC(xf86ConfigPciEntityInactive) + SYMFUNC(xf86ConfigIsaEntityInactive) + SYMFUNC(xf86IsScreenPrimary) + SYMFUNC(xf86RegisterRootWindowProperty) + SYMFUNC(xf86IsUnblank) + SYMFUNC(xf86AddModuleInfo) + SYMFUNC(xf86DeleteModuleInfo) #if defined(__sparc__) && !defined(__OpenBSD__) - /* xf86sbusBus.c */ - SYMFUNC(xf86MatchSbusInstances) - SYMFUNC(xf86GetSbusInfoForEntity) - SYMFUNC(xf86GetEntityForSbusInfo) - SYMFUNC(xf86SbusUseBuiltinMode) - SYMFUNC(xf86MapSbusMem) - SYMFUNC(xf86UnmapSbusMem) - SYMFUNC(xf86SbusHideOsHwCursor) - SYMFUNC(xf86SbusSetOsHwCursorCmap) - SYMFUNC(xf86SbusHandleColormaps) - SYMFUNC(sparcPromInit) - SYMFUNC(sparcPromClose) - SYMFUNC(sparcPromGetProperty) - SYMFUNC(sparcPromGetBool) + /* xf86sbusBus.c */ + SYMFUNC(xf86MatchSbusInstances) + SYMFUNC(xf86GetSbusInfoForEntity) + SYMFUNC(xf86GetEntityForSbusInfo) + SYMFUNC(xf86SbusUseBuiltinMode) + SYMFUNC(xf86MapSbusMem) + SYMFUNC(xf86UnmapSbusMem) + SYMFUNC(xf86SbusHideOsHwCursor) + SYMFUNC(xf86SbusSetOsHwCursorCmap) + SYMFUNC(xf86SbusHandleColormaps) + SYMFUNC(sparcPromInit) + SYMFUNC(sparcPromClose) + SYMFUNC(sparcPromGetProperty) + SYMFUNC(sparcPromGetBool) #endif - /* xf86Init.c */ - SYMFUNC(xf86GetPixFormat) - SYMFUNC(xf86GetBppFromDepth) + /* xf86Init.c */ + SYMFUNC(xf86GetPixFormat) + SYMFUNC(xf86GetBppFromDepth) - /* xf86Mode.c */ - SYMFUNC(xf86GetNearestClock) - SYMFUNC(xf86ModeStatusToString) - SYMFUNC(xf86LookupMode) - SYMFUNC(xf86CheckModeForMonitor) - SYMFUNC(xf86InitialCheckModeForDriver) - SYMFUNC(xf86CheckModeForDriver) - SYMFUNC(xf86ValidateModes) - SYMFUNC(xf86DeleteMode) - SYMFUNC(xf86PruneDriverModes) - SYMFUNC(xf86SetCrtcForModes) - SYMFUNC(xf86PrintModes) - SYMFUNC(xf86ShowClockRanges) + /* xf86Mode.c */ + SYMFUNC(xf86GetNearestClock) + SYMFUNC(xf86ModeStatusToString) + SYMFUNC(xf86LookupMode) + SYMFUNC(xf86CheckModeForMonitor) + SYMFUNC(xf86InitialCheckModeForDriver) + SYMFUNC(xf86CheckModeForDriver) + SYMFUNC(xf86ValidateModes) + SYMFUNC(xf86DeleteMode) + SYMFUNC(xf86PruneDriverModes) + SYMFUNC(xf86SetCrtcForModes) + SYMFUNC(xf86PrintModes) + SYMFUNC(xf86ShowClockRanges) - /* xf86Option.c */ - SYMFUNC(xf86CollectOptions) - SYMFUNC(xf86CollectInputOptions) - /* Merging of XInput stuff */ - SYMFUNC(xf86AddNewOption) - SYMFUNC(xf86SetBoolOption) - SYMFUNC(xf86NewOption) - SYMFUNC(xf86NextOption) - SYMFUNC(xf86OptionListCreate) - SYMFUNC(xf86OptionListMerge) - SYMFUNC(xf86OptionListFree) - SYMFUNC(xf86OptionName) - SYMFUNC(xf86OptionValue) - SYMFUNC(xf86OptionListReport) - SYMFUNC(xf86SetIntOption) - SYMFUNC(xf86SetRealOption) - SYMFUNC(xf86SetStrOption) - SYMFUNC(xf86ReplaceIntOption) - SYMFUNC(xf86ReplaceStrOption) - SYMFUNC(xf86ReplaceBoolOption) - SYMFUNC(xf86FindOption) - SYMFUNC(xf86FindOptionValue) - SYMFUNC(xf86MarkOptionUsed) - SYMFUNC(xf86MarkOptionUsedByName) - SYMFUNC(xf86CheckIfOptionUsed) - SYMFUNC(xf86CheckIfOptionUsedByName) - SYMFUNC(xf86ShowUnusedOptions) - SYMFUNC(xf86ProcessOptions) - SYMFUNC(xf86TokenToOptinfo) - SYMFUNC(xf86TokenToOptName) - SYMFUNC(xf86IsOptionSet) - SYMFUNC(xf86GetOptValString) - SYMFUNC(xf86GetOptValInteger) - SYMFUNC(xf86GetOptValULong) - SYMFUNC(xf86GetOptValReal) - SYMFUNC(xf86GetOptValFreq) - SYMFUNC(xf86GetOptValBool) - SYMFUNC(xf86ReturnOptValBool) - SYMFUNC(xf86NameCmp) - SYMFUNC(xf86InitValuatorAxisStruct) - SYMFUNC(xf86InitValuatorDefaults) - + /* xf86Option.c */ + SYMFUNC(xf86CollectOptions) + SYMFUNC(xf86CollectInputOptions) + /* Merging of XInput stuff */ + SYMFUNC(xf86AddNewOption) + SYMFUNC(xf86NewOption) + SYMFUNC(xf86NextOption) + SYMFUNC(xf86OptionListCreate) + SYMFUNC(xf86OptionListMerge) + SYMFUNC(xf86OptionListFree) + SYMFUNC(xf86OptionName) + SYMFUNC(xf86OptionValue) + SYMFUNC(xf86OptionListReport) + SYMFUNC(xf86SetIntOption) + SYMFUNC(xf86SetRealOption) + SYMFUNC(xf86SetStrOption) + SYMFUNC(xf86SetBoolOption) + SYMFUNC(xf86CheckIntOption) + SYMFUNC(xf86CheckRealOption) + SYMFUNC(xf86CheckStrOption) + SYMFUNC(xf86CheckBoolOption) + SYMFUNC(xf86ReplaceIntOption) + SYMFUNC(xf86ReplaceRealOption) + SYMFUNC(xf86ReplaceStrOption) + SYMFUNC(xf86ReplaceBoolOption) + SYMFUNC(xf86FindOption) + SYMFUNC(xf86FindOptionValue) + SYMFUNC(xf86MarkOptionUsed) + SYMFUNC(xf86MarkOptionUsedByName) + SYMFUNC(xf86CheckIfOptionUsed) + SYMFUNC(xf86CheckIfOptionUsedByName) + SYMFUNC(xf86ShowUnusedOptions) + SYMFUNC(xf86ProcessOptions) + SYMFUNC(xf86TokenToOptinfo) + SYMFUNC(xf86TokenToOptName) + SYMFUNC(xf86IsOptionSet) + SYMFUNC(xf86GetOptValString) + SYMFUNC(xf86GetOptValInteger) + SYMFUNC(xf86GetOptValULong) + SYMFUNC(xf86GetOptValReal) + SYMFUNC(xf86GetOptValFreq) + SYMFUNC(xf86GetOptValBool) + SYMFUNC(xf86ReturnOptValBool) + SYMFUNC(xf86NameCmp) + SYMFUNC(xf86InitValuatorAxisStruct) + SYMFUNC(xf86InitValuatorDefaults) - /* xf86fbman.c */ - SYMFUNC(xf86InitFBManager) - SYMFUNC(xf86InitFBManagerArea) - SYMFUNC(xf86InitFBManagerRegion) - SYMFUNC(xf86RegisterFreeBoxCallback) - SYMFUNC(xf86FreeOffscreenArea) - SYMFUNC(xf86AllocateOffscreenArea) - SYMFUNC(xf86AllocateLinearOffscreenArea) - SYMFUNC(xf86ResizeOffscreenArea) - SYMFUNC(xf86FBManagerRunning) - SYMFUNC(xf86QueryLargestOffscreenArea) - SYMFUNC(xf86PurgeUnlockedOffscreenAreas) - SYMFUNC(xf86RegisterOffscreenManager) - SYMFUNC(xf86AllocateOffscreenLinear) - SYMFUNC(xf86ResizeOffscreenLinear) - SYMFUNC(xf86QueryLargestOffscreenLinear) - SYMFUNC(xf86FreeOffscreenLinear) + /* xf86fbman.c */ + SYMFUNC(xf86InitFBManager) + SYMFUNC(xf86InitFBManagerArea) + SYMFUNC(xf86InitFBManagerRegion) + SYMFUNC(xf86InitFBManagerLinear) + SYMFUNC(xf86RegisterFreeBoxCallback) + SYMFUNC(xf86FreeOffscreenArea) + SYMFUNC(xf86AllocateOffscreenArea) + SYMFUNC(xf86AllocateLinearOffscreenArea) + SYMFUNC(xf86ResizeOffscreenArea) + SYMFUNC(xf86FBManagerRunning) + SYMFUNC(xf86QueryLargestOffscreenArea) + SYMFUNC(xf86PurgeUnlockedOffscreenAreas) + SYMFUNC(xf86RegisterOffscreenManager) + SYMFUNC(xf86AllocateOffscreenLinear) + SYMFUNC(xf86ResizeOffscreenLinear) + SYMFUNC(xf86QueryLargestOffscreenLinear) + SYMFUNC(xf86FreeOffscreenLinear) + /* xf86cmap.c */ + SYMFUNC(xf86HandleColormaps) - /* xf86cmap.c */ - SYMFUNC(xf86HandleColormaps) + /* xf86xv.c */ + SYMFUNC(xf86XVScreenInit) + SYMFUNC(xf86XVRegisterGenericAdaptorDriver) + SYMFUNC(xf86XVListGenericAdaptors) + SYMFUNC(xf86XVRegisterOffscreenImages) + SYMFUNC(xf86XVQueryOffscreenImages) + SYMFUNC(xf86XVAllocateVideoAdaptorRec) + SYMFUNC(xf86XVFreeVideoAdaptorRec) + SYMFUNC(xf86XVFillKeyHelper) + SYMFUNC(xf86XVClipVideoHelper) + SYMFUNC(xf86XVCopyYUV12ToPacked) + SYMFUNC(xf86XVCopyPacked) - /* xf86xv.c */ - SYMFUNC(xf86XVScreenInit) - SYMFUNC(xf86XVRegisterGenericAdaptorDriver) - SYMFUNC(xf86XVListGenericAdaptors) - SYMFUNC(xf86XVRegisterOffscreenImages) - SYMFUNC(xf86XVQueryOffscreenImages) - SYMFUNC(xf86XVAllocateVideoAdaptorRec) - SYMFUNC(xf86XVFreeVideoAdaptorRec) - SYMFUNC(xf86XVFillKeyHelper) - SYMFUNC(xf86XVClipVideoHelper) + /* xf86xvmc.c */ + SYMFUNC(xf86XvMCScreenInit) + SYMFUNC(xf86XvMCCreateAdaptorRec) + SYMFUNC(xf86XvMCDestroyAdaptorRec) - /* xf86xvmc.c */ - SYMFUNC(xf86XvMCScreenInit) - - /* xf86VidMode.c */ - SYMFUNC(VidModeExtensionInit) + /* xf86VidMode.c */ + SYMFUNC(VidModeExtensionInit) #ifdef XF86VIDMODE - SYMFUNC(VidModeGetCurrentModeline) - SYMFUNC(VidModeGetFirstModeline) - SYMFUNC(VidModeGetNextModeline) - SYMFUNC(VidModeDeleteModeline) - SYMFUNC(VidModeZoomViewport) - SYMFUNC(VidModeGetViewPort) - SYMFUNC(VidModeSetViewPort) - SYMFUNC(VidModeSwitchMode) - SYMFUNC(VidModeLockZoom) - SYMFUNC(VidModeGetMonitor) - SYMFUNC(VidModeGetNumOfClocks) - SYMFUNC(VidModeGetClocks) - SYMFUNC(VidModeCheckModeForMonitor) - SYMFUNC(VidModeCheckModeForDriver) - SYMFUNC(VidModeSetCrtcForMode) - SYMFUNC(VidModeAddModeline) - SYMFUNC(VidModeGetDotClock) - SYMFUNC(VidModeGetNumOfModes) - SYMFUNC(VidModeSetGamma) - SYMFUNC(VidModeGetGamma) - SYMFUNC(VidModeCreateMode) - SYMFUNC(VidModeCopyMode) - SYMFUNC(VidModeGetModeValue) - SYMFUNC(VidModeSetModeValue) - SYMFUNC(VidModeGetMonitorValue) - SYMFUNC(VidModeSetGammaRamp) - SYMFUNC(VidModeGetGammaRamp) - SYMFUNC(VidModeGetGammaRampSize) + SYMFUNC(VidModeGetCurrentModeline) + SYMFUNC(VidModeGetFirstModeline) + SYMFUNC(VidModeGetNextModeline) + SYMFUNC(VidModeDeleteModeline) + SYMFUNC(VidModeZoomViewport) + SYMFUNC(VidModeGetViewPort) + SYMFUNC(VidModeSetViewPort) + SYMFUNC(VidModeSwitchMode) + SYMFUNC(VidModeLockZoom) + SYMFUNC(VidModeGetMonitor) + SYMFUNC(VidModeGetNumOfClocks) + SYMFUNC(VidModeGetClocks) + SYMFUNC(VidModeCheckModeForMonitor) + SYMFUNC(VidModeCheckModeForDriver) + SYMFUNC(VidModeSetCrtcForMode) + SYMFUNC(VidModeAddModeline) + SYMFUNC(VidModeGetDotClock) + SYMFUNC(VidModeGetNumOfModes) + SYMFUNC(VidModeSetGamma) + SYMFUNC(VidModeGetGamma) + SYMFUNC(VidModeCreateMode) + SYMFUNC(VidModeCopyMode) + SYMFUNC(VidModeGetModeValue) + SYMFUNC(VidModeSetModeValue) + SYMFUNC(VidModeGetMonitorValue) + SYMFUNC(VidModeSetGammaRamp) + SYMFUNC(VidModeGetGammaRamp) + SYMFUNC(VidModeGetGammaRampSize) #endif - /* xf86MiscExt.c */ + /* xf86Versions.c */ + SYMFUNC(xf86GetBuiltinInterfaceVersion) + SYMFUNC(xf86RegisterBuiltinInterfaceVersion) + + /* xf86MiscExt.c */ #ifdef XF86MISC - SYMFUNC(MiscExtGetMouseSettings) - SYMFUNC(MiscExtGetMouseValue) - SYMFUNC(MiscExtSetMouseValue) - SYMFUNC(MiscExtSetMouseDevice) - SYMFUNC(MiscExtGetKbdSettings) - SYMFUNC(MiscExtGetKbdValue) - SYMFUNC(MiscExtSetKbdValue) - SYMFUNC(MiscExtSetGrabKeysState) - SYMFUNC(MiscExtCreateStruct) - SYMFUNC(MiscExtDestroyStruct) - SYMFUNC(MiscExtApply) - SYMFUNC(MiscExtGetFilePaths) + SYMFUNC(MiscExtGetMouseSettings) + SYMFUNC(MiscExtGetMouseValue) + SYMFUNC(MiscExtSetMouseValue) + SYMFUNC(MiscExtSetMouseDevice) + SYMFUNC(MiscExtGetKbdSettings) + SYMFUNC(MiscExtGetKbdValue) + SYMFUNC(MiscExtSetKbdValue) + SYMFUNC(MiscExtSetGrabKeysState) + SYMFUNC(MiscExtCreateStruct) + SYMFUNC(MiscExtDestroyStruct) + SYMFUNC(MiscExtApply) + SYMFUNC(MiscExtGetFilePaths) + SYMFUNC(MiscExtPassMessage) #endif - /* Misc */ - SYMFUNC(GetTimeInMillis) + /* Misc */ + SYMFUNC(GetTimeInMillis) - /* xf86Xinput.c */ + /* xf86Xinput.c */ #ifdef XINPUT - SYMFUNC(xf86ProcessCommonOptions) - SYMFUNC(xf86IsCorePointer) - SYMFUNC(xf86PostMotionEvent) - SYMFUNC(xf86PostProximityEvent) - SYMFUNC(xf86PostButtonEvent) - SYMFUNC(xf86PostKeyEvent) - SYMFUNC(xf86PostKeyboardEvent) - SYMFUNC(xf86GetMotionEvents) - SYMFUNC(xf86MotionHistoryAllocate) - SYMFUNC(xf86FirstLocalDevice) - SYMFUNC(xf86eqEnqueue) + SYMFUNC(xf86ProcessCommonOptions) + SYMFUNC(xf86IsCorePointer) + SYMFUNC(xf86PostMotionEvent) + SYMFUNC(xf86PostProximityEvent) + SYMFUNC(xf86PostButtonEvent) + SYMFUNC(xf86PostKeyEvent) + SYMFUNC(xf86PostKeyboardEvent) + SYMFUNC(xf86GetMotionEvents) + SYMFUNC(xf86MotionHistoryAllocate) + SYMFUNC(xf86FirstLocalDevice) + SYMFUNC(xf86eqEnqueue) /* The following segment merged from Metrolink tree */ - SYMFUNC(xf86XInputSetScreen) - SYMFUNC(xf86ScaleAxis) - SYMFUNC(xf86XInputSetSendCoreEvents) + SYMFUNC(xf86XInputSetScreen) + SYMFUNC(xf86ScaleAxis) + SYMFUNC(xf86XInputSetSendCoreEvents) /* End merged segment */ #endif - SYMFUNC(DPMSGet) - SYMFUNC(DPMSSet) - SYMFUNC(DPMSSupported) + SYMFUNC(DPMSGet) + SYMFUNC(DPMSSet) + SYMFUNC(DPMSSupported) /* xf86Debug.c */ #ifdef BUILDDEBUG - SYMFUNC(xf86Break1) - SYMFUNC(xf86Break2) - SYMFUNC(xf86Break3) - SYMFUNC(xf86SPTimestamp) - SYMFUNC(xf86STimestamp) + SYMFUNC(xf86Break1) + SYMFUNC(xf86Break2) + SYMFUNC(xf86Break3) + SYMFUNC(xf86SPTimestamp) + SYMFUNC(xf86STimestamp) #endif - -#if 0 /* we want to move the hw stuff in a module */ - SYMFUNC(xf86dactopel) - SYMFUNC(xf86dactocomm) - SYMFUNC(xf86getdaccomm) - SYMFUNC(xf86setdaccomm) - SYMFUNC(xf86setdaccommbit) - SYMFUNC(xf86clrdaccommbit) - SYMFUNC(s3IBMRGB_Probe) - SYMFUNC(s3IBMRGB_Init) - SYMFUNC(s3InIBMRGBIndReg) - SYMFUNC(Ti3025SetClock) - SYMFUNC(Ti3026SetClock) - SYMFUNC(Ti3030SetClock) - SYMFUNC(AltICD2061SetClock) - SYMFUNC(SC11412SetClock) - SYMFUNC(ICS2595SetClock) - SYMFUNC(Att409SetClock) - SYMFUNC(Chrontel8391SetClock) - SYMFUNC(IBMRGBSetClock) - SYMFUNC(ICS5342SetClock) - SYMFUNC(S3TrioSetClock) - SYMFUNC(S3Trio64V2SetClock) - SYMFUNC(S3gendacSetClock) - SYMFUNC(STG1703SetClock) - SYMFUNC(ET6000SetClock) - SYMFUNC(S3AuroraSetClock) - SYMFUNC(commonCalcClock) - SYMFUNC(xf86writepci) - SYMFUNC(dacOutTi3026IndReg) - SYMFUNC(dacInTi3026IndReg) - SYMFUNC(s3OutIBMRGBIndReg) - SYMFUNC(CirrusFindClock) - SYMFUNC(CirrusSetClock) - SYMFUNC(STG1703getIndex) - SYMFUNC(STG1703setIndex) - SYMFUNC(STG1703magic) - SYMFUNC(gendacMNToClock) - SYMFUNC(Et4000AltICD2061SetClock) - SYMFUNC(ET4000stg1703SetClock) - SYMFUNC(ET4000gendacSetClock) -#endif - - SYMFUNC(pciFindFirst) - SYMFUNC(pciFindNext) - SYMFUNC(pciWriteByte) - SYMFUNC(pciWriteWord) - SYMFUNC(pciWriteLong) - SYMFUNC(pciReadByte) - SYMFUNC(pciReadWord) - SYMFUNC(pciReadLong) - SYMFUNC(pciSetBitsLong) - SYMFUNC(pciTag) - SYMFUNC(pciBusAddrToHostAddr) - SYMFUNC(pciHostAddrToBusAddr) - SYMFUNC(xf86MapPciMem) - SYMFUNC(xf86scanpci) - SYMFUNC(xf86ReadPciBIOS) - SYMFUNC(AllocatePixmapPrivateIndex) - SYMFUNC(AllocatePixmapPrivate) + SYMFUNC(pciFindFirst) + SYMFUNC(pciFindNext) + SYMFUNC(pciWriteByte) + SYMFUNC(pciWriteWord) + SYMFUNC(pciWriteLong) + SYMFUNC(pciReadByte) + SYMFUNC(pciReadWord) + SYMFUNC(pciReadLong) + SYMFUNC(pciSetBitsLong) + SYMFUNC(pciTag) + SYMFUNC(pciBusAddrToHostAddr) + SYMFUNC(pciHostAddrToBusAddr) + SYMFUNC(xf86MapPciMem) + SYMFUNC(xf86scanpci) + SYMFUNC(xf86ReadPciBIOS) - /* Loader functions */ - SYMFUNC(LoaderDefaultFunc) - SYMFUNC(LoadSubModule) - SYMFUNC(DuplicateModule) - SYMFUNC(LoaderErrorMsg) - SYMFUNC(LoaderCheckUnresolved) - SYMFUNC(LoadExtension) - SYMFUNC(LoadFont) - SYMFUNC(LoaderReqSymbols) - SYMFUNC(LoaderReqSymLists) - SYMFUNC(LoaderRefSymbols) - SYMFUNC(LoaderRefSymLists) - SYMFUNC(UnloadSubModule) - SYMFUNC(LoaderSymbol) - SYMFUNC(LoaderListDirs) - SYMFUNC(LoaderFreeDirList) - SYMFUNC(LoaderGetOS) + /* Loader functions */ + SYMFUNC(LoaderDefaultFunc) + SYMFUNC(LoadSubModule) + SYMFUNC(DuplicateModule) + SYMFUNC(LoaderErrorMsg) + SYMFUNC(LoaderCheckUnresolved) + SYMFUNC(LoadExtension) + SYMFUNC(LoadFont) + SYMFUNC(LoaderReqSymbols) + SYMFUNC(LoaderReqSymLists) + SYMFUNC(LoaderRefSymbols) + SYMFUNC(LoaderRefSymLists) + SYMFUNC(UnloadSubModule) + SYMFUNC(LoaderSymbol) + SYMFUNC(LoaderListDirs) + SYMFUNC(LoaderFreeDirList) + SYMFUNC(LoaderGetOS) - /* - * these here are our own interfaces to libc functions - */ - SYMFUNC(xf86abort) - SYMFUNC(xf86abs) - SYMFUNC(xf86acos) - SYMFUNC(xf86asin) - SYMFUNC(xf86atan) - SYMFUNC(xf86atan2) - SYMFUNC(xf86atof) - SYMFUNC(xf86atoi) - SYMFUNC(xf86atol) - SYMFUNC(xf86bsearch) - SYMFUNC(xf86ceil) - SYMFUNC(xf86calloc) - SYMFUNC(xf86clearerr) - SYMFUNC(xf86close) - SYMFUNC(xf86cos) - SYMFUNC(xf86exit) - SYMFUNC(xf86exp) - SYMFUNC(xf86fabs) - SYMFUNC(xf86fclose) - SYMFUNC(xf86feof) - SYMFUNC(xf86ferror) - SYMFUNC(xf86fflush) - SYMFUNC(xf86fgetc) - SYMFUNC(xf86fgetpos) - SYMFUNC(xf86fgets) - SYMFUNC(xf86finite) - SYMFUNC(xf86floor) - SYMFUNC(xf86fmod) - SYMFUNC(xf86fopen) - SYMFUNC(xf86fprintf) - SYMFUNC(xf86fputc) - SYMFUNC(xf86fputs) - SYMFUNC(xf86fread) - SYMFUNC(xf86free) - SYMFUNC(xf86freopen) - SYMFUNC(xf86frexp) - SYMFUNC(xf86fscanf) - SYMFUNC(xf86fseek) - SYMFUNC(xf86fsetpos) - SYMFUNC(xf86ftell) - SYMFUNC(xf86fwrite) - SYMFUNC(xf86getc) - SYMFUNC(xf86getenv) - SYMFUNC(xf86getpagesize) - SYMFUNC(xf86hypot) - SYMFUNC(xf86ioctl) - SYMFUNC(xf86isalnum) - SYMFUNC(xf86isalpha) - SYMFUNC(xf86iscntrl) - SYMFUNC(xf86isdigit) - SYMFUNC(xf86isgraph) - SYMFUNC(xf86islower) - SYMFUNC(xf86isprint) - SYMFUNC(xf86ispunct) - SYMFUNC(xf86isspace) - SYMFUNC(xf86isupper) - SYMFUNC(xf86isxdigit) - SYMFUNC(xf86labs) - SYMFUNC(xf86ldexp) - SYMFUNC(xf86log) - SYMFUNC(xf86log10) - SYMFUNC(xf86lseek) - SYMFUNC(xf86malloc) - SYMFUNC(xf86memchr) - SYMFUNC(xf86memcmp) - SYMFUNC(xf86memcpy) - /* - * Some compilers generate calls to memcpy to handle structure copies - * or run-time initializations. - */ - SYMFUNCALIAS("memcpy",xf86memcpy) - SYMFUNC(xf86memset) - /* - * Some compilers generate calls to memset to handle aggregate - * initializations. - */ - SYMFUNCALIAS("memset",xf86memset) - SYMFUNC(xf86memmove) - SYMFUNC(xf86mmap) - SYMFUNC(xf86modf) - SYMFUNC(xf86munmap) - SYMFUNC(xf86open) - SYMFUNC(xf86perror) - SYMFUNC(xf86pow) - SYMFUNC(xf86printf) - SYMFUNC(xf86qsort) - SYMFUNC(xf86read) - SYMFUNC(xf86realloc) - SYMFUNC(xf86remove) - SYMFUNC(xf86rename) - SYMFUNC(xf86rewind) - SYMFUNC(xf86setbuf) - SYMFUNC(xf86setvbuf) - SYMFUNC(xf86sin) - SYMFUNC(xf86snprintf) - SYMFUNC(xf86sprintf) - SYMFUNC(xf86sqrt) - SYMFUNC(xf86sscanf) - SYMFUNC(xf86strcat) - SYMFUNC(xf86strcmp) - SYMFUNC(xf86strcasecmp) - SYMFUNC(xf86strcpy) - SYMFUNC(xf86strcspn) - SYMFUNC(xf86strerror) - SYMFUNC(xf86strlen) - SYMFUNC(xf86strncasecmp) - SYMFUNC(xf86strncat) - SYMFUNC(xf86strncmp) - SYMFUNC(xf86strncpy) - SYMFUNC(xf86strpbrk) - SYMFUNC(xf86strchr) - SYMFUNC(xf86strrchr) - SYMFUNC(xf86strspn) - SYMFUNC(xf86strstr) - SYMFUNC(xf86strtod) - SYMFUNC(xf86strtok) - SYMFUNC(xf86strtol) - SYMFUNC(xf86strtoul) - SYMFUNC(xf86tan) - SYMFUNC(xf86tmpfile) - SYMFUNC(xf86tolower) - SYMFUNC(xf86toupper) - SYMFUNC(xf86ungetc) - SYMFUNC(xf86vfprintf) - SYMFUNC(xf86vsnprintf) - SYMFUNC(xf86vsprintf) - SYMFUNC(xf86write) - -/* non-ANSI C functions */ - SYMFUNC(xf86opendir) - SYMFUNC(xf86closedir) - SYMFUNC(xf86readdir) - SYMFUNC(xf86rewinddir) - SYMFUNC(xf86ffs) - SYMFUNC(xf86strdup) - SYMFUNC(xf86bzero) - SYMFUNC(xf86usleep) - SYMFUNC(xf86execl) + /* + * These are our own interfaces to libc functions. + */ + SYMFUNC(xf86abort) + SYMFUNC(xf86abs) + SYMFUNC(xf86acos) + SYMFUNC(xf86asin) + SYMFUNC(xf86atan) + SYMFUNC(xf86atan2) + SYMFUNC(xf86atof) + SYMFUNC(xf86atoi) + SYMFUNC(xf86atol) + SYMFUNC(xf86bsearch) + SYMFUNC(xf86ceil) + SYMFUNC(xf86calloc) + SYMFUNC(xf86clearerr) + SYMFUNC(xf86close) + SYMFUNC(xf86cos) + SYMFUNC(xf86exit) + SYMFUNC(xf86exp) + SYMFUNC(xf86fabs) + SYMFUNC(xf86fclose) + SYMFUNC(xf86feof) + SYMFUNC(xf86ferror) + SYMFUNC(xf86fflush) + SYMFUNC(xf86fgetc) + SYMFUNC(xf86fgetpos) + SYMFUNC(xf86fgets) + SYMFUNC(xf86finite) + SYMFUNC(xf86floor) + SYMFUNC(xf86fmod) + SYMFUNC(xf86fopen) + SYMFUNC(xf86fprintf) + SYMFUNC(xf86fputc) + SYMFUNC(xf86fputs) + SYMFUNC(xf86fread) + SYMFUNC(xf86free) + SYMFUNC(xf86freopen) + SYMFUNC(xf86frexp) + SYMFUNC(xf86fscanf) + SYMFUNC(xf86fseek) + SYMFUNC(xf86fsetpos) + SYMFUNC(xf86ftell) + SYMFUNC(xf86fwrite) + SYMFUNC(xf86getc) + SYMFUNC(xf86getenv) + SYMFUNC(xf86getpagesize) + SYMFUNC(xf86hypot) + SYMFUNC(xf86ioctl) + SYMFUNC(xf86isalnum) + SYMFUNC(xf86isalpha) + SYMFUNC(xf86iscntrl) + SYMFUNC(xf86isdigit) + SYMFUNC(xf86isgraph) + SYMFUNC(xf86islower) + SYMFUNC(xf86isprint) + SYMFUNC(xf86ispunct) + SYMFUNC(xf86isspace) + SYMFUNC(xf86isupper) + SYMFUNC(xf86isxdigit) + SYMFUNC(xf86labs) + SYMFUNC(xf86ldexp) + SYMFUNC(xf86log) + SYMFUNC(xf86log10) + SYMFUNC(xf86lseek) + SYMFUNC(xf86malloc) + SYMFUNC(xf86memchr) + SYMFUNC(xf86memcmp) + SYMFUNC(xf86memcpy) + /* + * Some compilers generate calls to memcpy to handle structure copies + * or run-time initializations. + */ + SYMFUNCALIAS("memcpy", xf86memcpy) + SYMFUNC(xf86memset) + /* + * Some compilers generate calls to memset to handle aggregate + * initializations. + */ + SYMFUNCALIAS("memset", xf86memset) + SYMFUNC(xf86memmove) + SYMFUNC(xf86mmap) + SYMFUNC(xf86modf) + SYMFUNC(xf86munmap) + SYMFUNC(xf86open) + SYMFUNC(xf86perror) + SYMFUNC(xf86pow) + SYMFUNC(xf86printf) + SYMFUNC(xf86qsort) + SYMFUNC(xf86read) + SYMFUNC(xf86realloc) + SYMFUNC(xf86remove) + SYMFUNC(xf86rename) + SYMFUNC(xf86rewind) + SYMFUNC(xf86setbuf) + SYMFUNC(xf86setvbuf) + SYMFUNC(xf86sin) + SYMFUNC(xf86snprintf) + SYMFUNC(xf86sprintf) + SYMFUNC(xf86sqrt) + SYMFUNC(xf86sscanf) + SYMFUNC(xf86strcat) + SYMFUNC(xf86strcmp) + SYMFUNC(xf86strcasecmp) + SYMFUNC(xf86strcpy) + SYMFUNC(xf86strcspn) + SYMFUNC(xf86strerror) + SYMFUNC(xf86strlcat) + SYMFUNC(xf86strlcpy) + SYMFUNC(xf86strlen) + SYMFUNC(xf86strncasecmp) + SYMFUNC(xf86strncat) + SYMFUNC(xf86strncmp) + SYMFUNC(xf86strncpy) + SYMFUNC(xf86strpbrk) + SYMFUNC(xf86strchr) + SYMFUNC(xf86strrchr) + SYMFUNC(xf86strspn) + SYMFUNC(xf86strstr) + SYMFUNC(xf86strtod) + SYMFUNC(xf86strtok) + SYMFUNC(xf86strtol) + SYMFUNC(xf86strtoul) + SYMFUNC(xf86tan) + SYMFUNC(xf86tmpfile) + SYMFUNC(xf86tolower) + SYMFUNC(xf86toupper) + SYMFUNC(xf86ungetc) + SYMFUNC(xf86vfprintf) + SYMFUNC(xf86vsnprintf) + SYMFUNC(xf86vsprintf) + SYMFUNC(xf86write) - SYMFUNC(xf86getsecs) - SYMFUNC(xf86fpossize) /* for returning sizeof(fpos_t) */ + /* non-ANSI C functions */ + SYMFUNC(xf86opendir) + SYMFUNC(xf86closedir) + SYMFUNC(xf86readdir) + SYMFUNC(xf86rewinddir) + SYMFUNC(xf86ffs) + SYMFUNC(xf86strdup) + SYMFUNC(xf86bzero) + SYMFUNC(xf86usleep) + SYMFUNC(xf86execl) - /* These provide for DRI support. */ - SYMFUNC(xf86stat) - SYMFUNC(xf86fstat) - SYMFUNC(xf86access) - SYMFUNC(xf86geteuid) - SYMFUNC(xf86getegid) - SYMFUNC(xf86getpid) - SYMFUNC(xf86mknod) - SYMFUNC(xf86chmod) - SYMFUNC(xf86chown) - SYMFUNC(xf86sleep) - SYMFUNC(xf86mkdir) - SYMFUNC(xf86shmget) - SYMFUNC(xf86shmat) - SYMFUNC(xf86shmdt) - SYMFUNC(xf86shmctl) + SYMFUNC(xf86getsecs) + SYMFUNC(xf86fpossize) /* for returning sizeof(fpos_t) */ + + /* Some of these were added for DRI support. */ + SYMFUNC(xf86stat) + SYMFUNC(xf86fstat) + SYMFUNC(xf86access) + SYMFUNC(xf86geteuid) + SYMFUNC(xf86getegid) + SYMFUNC(xf86getpid) + SYMFUNC(xf86mknod) + SYMFUNC(xf86chmod) + SYMFUNC(xf86chown) + SYMFUNC(xf86sleep) + SYMFUNC(xf86mkdir) + SYMFUNC(xf86shmget) + SYMFUNC(xf86shmat) + SYMFUNC(xf86shmdt) + SYMFUNC(xf86shmctl) #ifdef HAS_GLIBC_SIGSETJMP - SYMFUNC(xf86setjmp) - SYMFUNC(xf86setjmp0) + SYMFUNC(xf86setjmp) + SYMFUNC(xf86setjmp0) #if defined(__GLIBC__) && (__GLIBC__ >= 2) - SYMFUNCALIAS("xf86setjmp1",__sigsetjmp) + SYMFUNCALIAS("xf86setjmp1", __sigsetjmp) #else - SYMFUNC(xf86setjmp1) /* For libc5 */ + SYMFUNC(xf86setjmp1) /* For libc5 */ #endif #else - SYMFUNCALIAS("xf86setjmp",setjmp) - SYMFUNCALIAS("xf86setjmp0",setjmp) - SYMFUNC(xf86setjmp1) + SYMFUNCALIAS("xf86setjmp", setjmp) + SYMFUNCALIAS("xf86setjmp0", setjmp) + SYMFUNC(xf86setjmp1) #endif - SYMFUNCALIAS("xf86longjmp",longjmp) - SYMFUNC(xf86getjmptype) - SYMFUNC(xf86setjmp1_arg2) - SYMFUNC(xf86setjmperror) + SYMFUNCALIAS("xf86longjmp", longjmp) + SYMFUNC(xf86getjmptype) + SYMFUNC(xf86setjmp1_arg2) + SYMFUNC(xf86setjmperror) #ifdef XF86DRI - /* These may have more general uses, but - for now, they are only used by the DRI. - Loading them only when the DRI is built - may make porting (the non-DRI portions - of the X server) easier. */ - SYMFUNC(xf86InstallSIGIOHandler) - SYMFUNC(xf86RemoveSIGIOHandler) + /* + * These may have more general uses, but for now, they are only used + * by the DRI. Loading them only when the DRI is built may make porting + * (the non-DRI portions of the X server) easier. + */ + SYMFUNC(xf86InstallSIGIOHandler) + SYMFUNC(xf86RemoveSIGIOHandler) # if defined(__alpha__) && defined(linux) - SYMFUNC(_bus_base) + SYMFUNC(_bus_base) # endif #endif - SYMFUNC(xf86BlockSIGIO) - SYMFUNC(xf86UnblockSIGIO) - + SYMFUNC(xf86BlockSIGIO) + SYMFUNC(xf86UnblockSIGIO) + #if defined(__alpha__) - SYMFUNC(__divl) - SYMFUNC(__reml) - SYMFUNC(__divlu) - SYMFUNC(__remlu) - SYMFUNC(__divq) - SYMFUNC(__divqu) - SYMFUNC(__remq) - SYMFUNC(__remqu) + SYMFUNC(__divl) + SYMFUNC(__reml) + SYMFUNC(__divlu) + SYMFUNC(__remlu) + SYMFUNC(__divq) + SYMFUNC(__divqu) + SYMFUNC(__remq) + SYMFUNC(__remqu) # ifdef linux - SYMFUNC(_outw) - SYMFUNC(_outb) - SYMFUNC(_outl) - SYMFUNC(_inb) - SYMFUNC(_inw) - SYMFUNC(_inl) - SYMFUNC(_alpha_outw) - SYMFUNC(_alpha_outb) - SYMFUNC(_alpha_outl) - SYMFUNC(_alpha_inb) - SYMFUNC(_alpha_inw) - SYMFUNC(_alpha_inl) + SYMFUNC(_outw) + SYMFUNC(_outb) + SYMFUNC(_outl) + SYMFUNC(_inb) + SYMFUNC(_inw) + SYMFUNC(_inl) + SYMFUNC(_alpha_outw) + SYMFUNC(_alpha_outb) + SYMFUNC(_alpha_outl) + SYMFUNC(_alpha_inb) + SYMFUNC(_alpha_inw) + SYMFUNC(_alpha_inl) # else - SYMFUNC(outw) - SYMFUNC(outb) - SYMFUNC(outl) - SYMFUNC(inb) - SYMFUNC(inw) - SYMFUNC(inl) + SYMFUNC(outw) + SYMFUNC(outb) + SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) # endif - SYMFUNC(xf86ReadMmio32) - SYMFUNC(xf86ReadMmio16) - SYMFUNC(xf86ReadMmio8) - SYMFUNC(xf86WriteMmio32) - SYMFUNC(xf86WriteMmio16) - SYMFUNC(xf86WriteMmio8) - SYMFUNC(xf86WriteMmioNB32) - SYMFUNC(xf86WriteMmioNB16) - SYMFUNC(xf86WriteMmioNB8) + SYMFUNC(xf86ReadMmio32) + SYMFUNC(xf86ReadMmio16) + SYMFUNC(xf86ReadMmio8) + SYMFUNC(xf86WriteMmio32) + SYMFUNC(xf86WriteMmio16) + SYMFUNC(xf86WriteMmio8) + SYMFUNC(xf86WriteMmioNB32) + SYMFUNC(xf86WriteMmioNB16) + SYMFUNC(xf86WriteMmioNB8) #endif #if defined(sun) && defined(SVR4) - SYMFUNC(inb) - SYMFUNC(inw) - SYMFUNC(inl) - SYMFUNC(outb) - SYMFUNC(outw) - SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) + SYMFUNC(outb) + SYMFUNC(outw) + SYMFUNC(outl) #endif #if defined(__powerpc__) && !defined(__OpenBSD__) - SYMFUNC(inb) - SYMFUNC(inw) - SYMFUNC(inl) - SYMFUNC(outb) - SYMFUNC(outw) - SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) + SYMFUNC(outb) + SYMFUNC(outw) + SYMFUNC(outl) # if defined(NO_INLINE) || defined(Lynx) - SYMFUNC(mem_barrier) - SYMFUNC(ldl_u) - SYMFUNC(eieio) - SYMFUNC(ldl_brx) - SYMFUNC(ldw_brx) - SYMFUNC(stl_brx) - SYMFUNC(stw_brx) - SYMFUNC(ldq_u) - SYMFUNC(ldw_u) - SYMFUNC(stl_u) - SYMFUNC(stq_u) - SYMFUNC(stw_u) - SYMFUNC(write_mem_barrier) + SYMFUNC(mem_barrier) + SYMFUNC(ldl_u) + SYMFUNC(eieio) + SYMFUNC(ldl_brx) + SYMFUNC(ldw_brx) + SYMFUNC(stl_brx) + SYMFUNC(stw_brx) + SYMFUNC(ldq_u) + SYMFUNC(ldw_u) + SYMFUNC(stl_u) + SYMFUNC(stq_u) + SYMFUNC(stw_u) + SYMFUNC(write_mem_barrier) # endif # if defined(Lynx) - SYMFUNC(_restf14) - SYMFUNC(_restf17) - SYMFUNC(_restf18) - SYMFUNC(_restf19) - SYMFUNC(_restf20) - SYMFUNC(_restf22) - SYMFUNC(_restf23) - SYMFUNC(_restf24) - SYMFUNC(_restf25) - SYMFUNC(_restf26) - SYMFUNC(_restf27) - SYMFUNC(_restf28) - SYMFUNC(_restf29) - SYMFUNC(_savef14) - SYMFUNC(_savef17) - SYMFUNC(_savef18) - SYMFUNC(_savef19) - SYMFUNC(_savef20) - SYMFUNC(_savef22) - SYMFUNC(_savef23) - SYMFUNC(_savef24) - SYMFUNC(_savef25) - SYMFUNC(_savef26) - SYMFUNC(_savef27) - SYMFUNC(_savef28) - SYMFUNC(_savef29) + SYMFUNC(_restf14) + SYMFUNC(_restf17) + SYMFUNC(_restf18) + SYMFUNC(_restf19) + SYMFUNC(_restf20) + SYMFUNC(_restf22) + SYMFUNC(_restf23) + SYMFUNC(_restf24) + SYMFUNC(_restf25) + SYMFUNC(_restf26) + SYMFUNC(_restf27) + SYMFUNC(_restf28) + SYMFUNC(_restf29) + SYMFUNC(_savef14) + SYMFUNC(_savef17) + SYMFUNC(_savef18) + SYMFUNC(_savef19) + SYMFUNC(_savef20) + SYMFUNC(_savef22) + SYMFUNC(_savef23) + SYMFUNC(_savef24) + SYMFUNC(_savef25) + SYMFUNC(_savef26) + SYMFUNC(_savef27) + SYMFUNC(_savef28) + SYMFUNC(_savef29) # endif # if PPCIO_DEBUG - SYMFUNC(debug_inb) - SYMFUNC(debug_inw) - SYMFUNC(debug_inl) - SYMFUNC(debug_outb) - SYMFUNC(debug_outw) - SYMFUNC(debug_outl) + SYMFUNC(debug_inb) + SYMFUNC(debug_inw) + SYMFUNC(debug_inl) + SYMFUNC(debug_outb) + SYMFUNC(debug_outw) + SYMFUNC(debug_outl) # endif #endif #if defined(__GNUC__) - SYMFUNC(__div64) - SYMFUNC(__divdf3) - SYMFUNC(__divdi3) - SYMFUNC(__divsf3) - SYMFUNC(__divsi3) - SYMFUNC(__moddi3) - SYMFUNC(__modsi3) - SYMFUNC(__mul64) - SYMFUNC(__muldf3) - SYMFUNC(__muldi3) - SYMFUNC(__mulsf3) - SYMFUNC(__mulsi3) - SYMFUNC(__udivdi3) - SYMFUNC(__udivsi3) - SYMFUNC(__umoddi3) - SYMFUNC(__umodsi3) +#ifndef __UNIXOS2__ + SYMFUNC(__div64) +#endif + SYMFUNC(__divdf3) + SYMFUNC(__divdi3) + SYMFUNC(__divsf3) + SYMFUNC(__divsi3) + SYMFUNC(__moddi3) + SYMFUNC(__modsi3) +#ifndef __UNIXOS2__ + SYMFUNC(__mul64) +#endif + SYMFUNC(__muldf3) + SYMFUNC(__muldi3) + SYMFUNC(__mulsf3) + SYMFUNC(__mulsi3) + SYMFUNC(__udivdi3) + SYMFUNC(__udivsi3) + SYMFUNC(__umoddi3) + SYMFUNC(__umodsi3) #endif #if defined(__ia64__) - SYMFUNC(_outw) - SYMFUNC(_outb) - SYMFUNC(_outl) - SYMFUNC(_inb) - SYMFUNC(_inw) - SYMFUNC(_inl) + SYMFUNC(_outw) + SYMFUNC(_outb) + SYMFUNC(_outl) + SYMFUNC(_inb) + SYMFUNC(_inw) + SYMFUNC(_inl) #endif #if defined(__arm__) - SYMFUNC(outw) - SYMFUNC(outb) - SYMFUNC(outl) - SYMFUNC(inb) - SYMFUNC(inw) - SYMFUNC(inl) + SYMFUNC(outw) + SYMFUNC(outb) + SYMFUNC(outl) + SYMFUNC(inb) + SYMFUNC(inw) + SYMFUNC(inl) #endif #ifdef __FreeBSD__ - SYMFUNC(sysctlbyname) +#if defined(__sparc__) + SYMFUNC(_Qp_qtos) + SYMFUNC(_Qp_qtod) + SYMFUNC(_Qp_qtoux) + SYMFUNC(_Qp_uitoq) + SYMFUNC(_Qp_dtoq) +#endif #endif -/* - * and now some variables - */ + /* Some variables. */ - SYMVAR(xf86stdin) - SYMVAR(xf86stdout) - SYMVAR(xf86stderr) - SYMVAR(xf86errno) - SYMVAR(xf86HUGE_VAL) + SYMVAR(xf86stdin) + SYMVAR(xf86stdout) + SYMVAR(xf86stderr) + SYMVAR(xf86errno) + SYMVAR(xf86HUGE_VAL) - /* General variables (from xf86.h) */ - SYMVAR(xf86ScreenIndex) - SYMVAR(xf86PixmapIndex) - SYMVAR(xf86Screens) - SYMVAR(byte_reversed) - SYMVAR(xf86inSuspend) - /* debugging variables */ + /* General variables (from xf86.h) */ + SYMVAR(xf86ScreenIndex) + SYMVAR(xf86PixmapIndex) + SYMVAR(xf86Screens) + SYMVAR(byte_reversed) + SYMVAR(xf86inSuspend) + /* debugging variables */ #ifdef BUILDDEBUG - SYMVAR(xf86p8bit) - SYMVAR(xf86DummyVar1) - SYMVAR(xf86DummyVar2) - SYMVAR(xf86DummyVar3) + SYMVAR(xf86p8bit) + SYMVAR(xf86DummyVar1) + SYMVAR(xf86DummyVar2) + SYMVAR(xf86DummyVar3) #endif #ifdef async - SYMVAR(xf86CurrentScreen) + SYMVAR(xf86CurrentScreen) #endif - /* predefined resource lists from xf86Bus.h */ - SYMVAR(resVgaExclusive) - SYMVAR(resVgaShared) - SYMVAR(resVgaMemShared) - SYMVAR(resVgaIoShared) - SYMVAR(resVgaUnusedExclusive) - SYMVAR(resVgaUnusedShared) - SYMVAR(resVgaSparseExclusive) - SYMVAR(resVgaSparseShared) - SYMVAR(res8514Exclusive) - SYMVAR(res8514Shared) - SYMVAR(PciAvoid) + /* predefined resource lists from xf86Bus.h */ + SYMVAR(resVgaExclusive) + SYMVAR(resVgaShared) + SYMVAR(resVgaMemShared) + SYMVAR(resVgaIoShared) + SYMVAR(resVgaUnusedExclusive) + SYMVAR(resVgaUnusedShared) + SYMVAR(resVgaSparseExclusive) + SYMVAR(resVgaSparseShared) + SYMVAR(res8514Exclusive) + SYMVAR(res8514Shared) + SYMVAR(PciAvoid) #if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx)) - SYMVAR(ioBase) + SYMVAR(ioBase) #endif - /* Globals from xf86Globals.c and xf86Priv.h */ - SYMVAR(xf86ConfigDRI) + /* Globals from xf86Globals.c and xf86Priv.h */ + SYMVAR(xf86ConfigDRI) - /* Globals from xf86Configure.c */ - SYMVAR(ConfiguredMonitor) + /* Globals from xf86Configure.c */ + SYMVAR(ConfiguredMonitor) - /* Pci.c */ - SYMVAR(pciNumBuses) - - { 0, 0 }, + /* Pci.c */ + SYMVAR(pciNumBuses) + {0, 0} }; |