rpms/xorg-x11-server/devel xorg-x11-server-1.1.0-loader-diet.patch, NONE, 1.1 xorg-x11-server.spec, 1.87, 1.88

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Jun 19 21:22:29 UTC 2006


Author: ajackson

Update of /cvs/dist/rpms/xorg-x11-server/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv30280

Modified Files:
	xorg-x11-server.spec 
Added Files:
	xorg-x11-server-1.1.0-loader-diet.patch 
Log Message:
Backport loader debloating.


xorg-x11-server-1.1.0-loader-diet.patch:
 configure.ac                    |    6 
 hw/xfree86/Makefile.am          |    2 
 hw/xfree86/common/xf86Globals.c |    7 
 hw/xfree86/loader/Makefile.am   |   29 -
 hw/xfree86/loader/dlloader.c    |  107 ++---
 hw/xfree86/loader/dlloader.h    |    8 
 hw/xfree86/loader/loader.c      |  808 ----------------------------------------
 hw/xfree86/loader/loader.h      |  196 ---------
 hw/xfree86/loader/loaderProcs.h |    7 
 hw/xfree86/loader/loadext.c     |    5 
 hw/xfree86/loader/loadfont.c    |    2 
 hw/xfree86/loader/loadmod.c     |   84 +---
 hw/xfree86/loader/os.c          |    4 
 include/xorg-config.h.in        |    6 
 include/xorg-server.h.in        |    6 
 15 files changed, 96 insertions(+), 1181 deletions(-)

--- NEW FILE xorg-x11-server-1.1.0-loader-diet.patch ---
--- xorg-server-1.1.0/include/xorg-server.h.in.loader-diet	2005-12-02 01:02:44.000000000 -0500
+++ xorg-server-1.1.0/include/xorg-server.h.in	2006-06-19 16:48:07.000000000 -0400
@@ -28,12 +28,6 @@
 /* Use OsVendorInit */
 #undef DDXOSINIT
 
-/* Prefer dlloader modules to elfloader */
-#undef DLOPEN_HACK
-
-/* Building with libdl */
-#undef DLOPEN_SUPPORT
-
 /* Build DPMS extension */
 #undef DPMSExtension
 
--- xorg-server-1.1.0/include/xorg-config.h.in.loader-diet	2006-03-15 16:25:38.000000000 -0500
+++ xorg-server-1.1.0/include/xorg-config.h.in	2006-06-19 16:48:07.000000000 -0400
@@ -30,12 +30,6 @@
 /* URL to go to for support. */
 #undef __VENDORDWEBSUPPORT__
 
-/* Prefer dlloader modules to elfloader */
-#undef DLOPEN_HACK
-
-/* Use libdl-based loader. */
-#undef DLOPEN_SUPPORT
-
 /* Built-in output drivers. */
 #undef DRIVERS
 
--- xorg-server-1.1.0/hw/xfree86/common/xf86Globals.c.loader-diet	2006-05-09 14:04:29.000000000 -0400
+++ xorg-server-1.1.0/hw/xfree86/common/xf86Globals.c	2006-06-19 16:48:07.000000000 -0400
@@ -247,10 +247,3 @@
 _X_EXPORT Bool xf86inSuspend = FALSE;
 Bool xorgHWAccess = FALSE;
 PciBusId xf86IsolateDevice;
-
-#ifdef DLOPEN_HACK
-/*
- * This stuff is a hack to allow dlopen() modules to work.  It is intended
- * only to be used when using dlopen() modules for debugging purposes.
- */
-#endif
--- xorg-server-1.1.0/hw/xfree86/loader/loadmod.c.loader-diet	2006-03-25 14:52:04.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/loadmod.c	2006-06-19 16:48:07.000000000 -0400
@@ -1,7 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.73 2003/11/03 05:11:51 tsi Exp $ */
-
 /*
- *
  * Copyright 1995-1998 by Metro Link, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -73,7 +70,7 @@
 #include <dirent.h>
 #include <limits.h>
 
-extern int check_unresolved_sema;
+#define TestFree(a) if (a) { xfree (a); a = NULL; }
 
 typedef struct _pattern {
     const char *pattern;
@@ -93,7 +90,7 @@
 				  const XF86ModReqInfo *, int *, int *,
 				  int flags);
 
-ModuleVersions LoaderVersionInfo = {
+const ModuleVersions LoaderVersionInfo = {
     XORG_VERSION_CURRENT,
     ABI_ANSIC_VERSION,
     ABI_VIDEODRV_VERSION,
@@ -102,17 +99,6 @@
     ABI_FONT_VERSION
 };
 
-#if 0
-void
-LoaderFixups(void)
-{
-    /* Need to call LRS here because the frame buffers get loaded last,
-     * and the drivers depend on them. */
-
-    LoaderResolveSymbols();
-}
-#endif
-
 static void
 FreeStringList(char **paths)
 {
@@ -225,15 +211,15 @@
 /*
  * Standard set of module name patterns to check, in order of preference
  * These are regular expressions (suitable for use with POSIX regex(3)).
+ *
+ * This list assumes that you're an ELFish platform and therefore your
+ * shared libraries are named something.so.  If we're ever nuts enough
+ * to port this DDX to, say, Darwin, we'll need to fix this.
  */
 static PatternRec stdPatterns[] = {
     {"^lib(.*)\\.so$",},
-    {"^lib(.*)\\.a$",},
     {"(.*)_drv\\.so$",},
-    {"(.*)_drv\\.o$",},
     {"(.*)\\.so$",},
-    {"(.*)\\.a$",},
-    {"(.*)\\.o$",},
     {NULL,}
 };
 
@@ -413,11 +399,6 @@
     int dirlen;
     const char **subdirs = NULL;
     const char **s;
-#ifdef DLOPEN_HACK
-    const char suffix[3][3] = { "so", "a", "o" };
-#else
-    const char suffix[3][3] = { "a", "o", "so" };
-#endif
 
 #ifndef __EMX__
     dirpath = (char *)dir;
@@ -437,7 +418,6 @@
 	    continue;
 	strcpy(buf, dirpath);
 	strcat(buf, *s);
-	/*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf); */
         if ((stat(buf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
 	    int i;
 	
@@ -445,28 +425,23 @@
                 buf[dirlen++] = '/';
             }
 	    
-	    for (i = 0; i < 3 && !name; i++) {
-                snprintf(tmpBuf, PATH_MAX, "%slib%s.%s", buf, module,
-                         suffix[i]);
-                if (stat(tmpBuf, &stat_buf) == 0) {
-                    name = tmpBuf;
-                    break;
-                }
-                snprintf(tmpBuf, PATH_MAX, "%s%s_drv.%s", buf, module,
-                         suffix[i]);
-                if (stat(tmpBuf, &stat_buf) == 0) {
-                    name = tmpBuf;
-                    break;
-                }
-                snprintf(tmpBuf, PATH_MAX, "%s%s.%s", buf, module,
-                         suffix[i]);
-                if (stat(tmpBuf, &stat_buf) == 0) {
-                    name = tmpBuf;
-                    break;
-                }
-	    }
-	    if (name)
-		break;
+            snprintf(tmpBuf, PATH_MAX, "%slib%s.so", buf, module);
+            if (stat(tmpBuf, &stat_buf) == 0) {
+                name = tmpBuf;
+                break;
+            }
+
+            snprintf(tmpBuf, PATH_MAX, "%s%s_drv.so", buf, module);
+            if (stat(tmpBuf, &stat_buf) == 0) {
+                name = tmpBuf;
+                break;
+            }
+
+            snprintf(tmpBuf, PATH_MAX, "%s%s.so", buf, module);
+            if (stat(tmpBuf, &stat_buf) == 0) {
+                name = tmpBuf;
+                break;
+            }
         }
     }
     FreeSubdirs(subdirs);
@@ -740,19 +715,11 @@
 	    /* 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);
+			    "is newer 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;
 }
 
@@ -879,7 +846,6 @@
     int noncanonical = 0;
     char *m = NULL;
 
-    /*xf86Msg(X_INFO,"OS2DIAG: LoadModule: %s\n",module); */
     xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module);
 
     patterns = InitPatterns(patternlist);
@@ -1318,7 +1284,7 @@
 	msg = "module-specific error";
 	break;
     default:
-	msg = "uknown error";
+	msg = "unknown error";
     }
     if (name)
 	xf86Msg(type, "%s: Failed to load module \"%s\" (%s, %d)\n",
--- xorg-server-1.1.0/hw/xfree86/loader/os.c.loader-diet	2006-03-25 14:52:04.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/os.c	2006-06-19 16:48:07.000000000 -0400
@@ -1,5 +1,3 @@
-/* $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.
  *
@@ -38,6 +36,7 @@
  * loader and by OS-specific modules.
  */
 
+#ifndef OSNAME
 #if defined(__linux__)
 #define OSNAME "linux"
 #elif defined(__FreeBSD__)
@@ -67,6 +66,7 @@
 #else
 #define OSNAME "unknown"
 #endif
+#endif
 
 /* Return the OS name, and run-time OS version */
 
--- xorg-server-1.1.0/hw/xfree86/loader/Makefile.am.loader-diet	2005-12-02 01:02:41.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/Makefile.am	2006-06-19 16:48:07.000000000 -0400
@@ -1,10 +1,6 @@
 noinst_LIBRARIES = libloader.a
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../vbe \
-           -I$(srcdir)/../ddc -I$(srcdir)/../int10 -I$(srcdir)/../i2c \
-           -I$(srcdir)/../fbdevhw -I$(srcdir)/../scanpci -I$(srcdir)/../xaa \
-           -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac -I$(srcdir)/../shadowfb \
-           -I$(srcdir)/../dixmods/extmod -I$(srcdir)/../../../miext/cw \
-           -I$(srcdir)/../../../miext/damage
+
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser
 
 #AM_LDFLAGS = -r
 AM_CFLAGS = -DIN_LOADER $(XORG_CFLAGS) @SERVER_DEFINES@ @LOADER_DEFINES@
@@ -13,22 +9,10 @@
 SPARC_SOURCES = SparcMulDiv.S
 endif
 
-sdk_HEADERS = \
-	elf.h
-
 EXTRA_DIST = \
-	aout.h \
-	aoutloader.h \
-	ar.h \
-	coff.h \
-	coffloader.h \
 	dlloader.h \
-	elf.h \
-	elfloader.h \
-	hash.h \
 	loader.h \
 	loaderProcs.h \
-	sym.h \
 	SparcMulDiv.S
 
 libloader_a_SOURCES = \
@@ -37,15 +21,6 @@
 	loadext.c \
         loadmod.c \
 	loadfont.c \
-        aoutloader.c \
         dlloader.c \
-        elfloader.c \
-        coffloader.c \
 	os.c \
-	dixsym.c \
-	extsym.c \
-	fontsym.c \
-	misym.c \
-	xf86sym.c \
-	hash.c \
 	$(SPARC_SOURCES)
--- xorg-server-1.1.0/hw/xfree86/loader/loader.h.loader-diet	2006-03-11 19:11:34.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/loader.h	2006-06-19 16:48:07.000000000 -0400
@@ -1,7 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.h,v 1.28 2003/11/06 18:38:14 tsi Exp $ */
-
 /*
- *
  * Copyright 1995-1998 by Metro Link, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -56,163 +53,19 @@
 #ifndef _LOADER_H
 #define _LOADER_H
 
-#include "sym.h"
-
 #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
-#define LD_COFFOBJECT	2
-#define LD_XCOFFOBJECT	3
-#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
 
 /* LoadModule proc flags; LD_FLAG_GLOBAL adds symbols to global
  * namespace, default is to keep symbols local to module. */
 #define LD_FLAG_GLOBAL 1
 
-/*
- * COFF Section nmumbers
- */
-#define N_TEXT       1
-#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 _coff_COMMON *COFFCommonPtr;
-typedef struct AOUT_RELOC *AOUTRelocPtr;
-typedef struct AOUT_COMMON *AOUTCommonPtr;
-
-typedef struct _LoaderReloc {
-    int modtype;
-    struct _LoaderReloc *next;
-    COFFRelocPtr coff_reloc;
-    ELFRelocPtr elf_reloc;
-    AOUTRelocPtr aout_reloc;
-} LoaderRelocRec, *LoaderRelocPtr;
-
-typedef struct _loader_item *itemPtr;
-typedef struct _loader_item {
-    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;
-#endif
-} 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 */
-} 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 */
-} LDRModuleRec, *LDRModulePtr;
-
-extern char DebuggerPresent;
-extern LDRModulePtr ModList;
-extern LDRCommonPtr ldrCommons;
-extern int nCommons;
-
-/*
- * The loader uses loader specific alloc/calloc/free functions that
- * are mapped to either to the regular Xserver functions, or in a couple
- * of special cases, mapped to the C library functions.
- */
-#if !defined(PowerMAX_OS) && !(defined(linux) && (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__))) && 0
-#define xf86loadermalloc(size) xalloc(size)
-#define xf86loaderrealloc(ptr,size) xrealloc(ptr,size)
-#define xf86loadercalloc(num,size) xcalloc(num,size)
-#define xf86loaderfree(ptr) xfree(ptr)
-#define xf86loaderstrdup(ptr) xstrdup(ptr)
-#else
-/*
- * On Some OSes, xalloc() et al uses mmap to allocate space for large
- * allocation. This has the effect of placing the text section of some
- * modules very far away from the rest which are placed on the heap.
- * Certain relocations are limited in the size of the offsets that can be
- * handled, and this seperation causes these relocation to overflow. This
- * is fixed by just using the C library allocation functions for the loader
- * to ensure that all text sections are located on the heap. OSes that have
- * this problem are:
- *	PowerMAX_OS/PPC
- * 	Linux/Alpha
- * 	Linux/PPC
- *	Linux/IA-64
- */
-#define xf86loadermalloc(size) malloc(size)
-#define xf86loaderrealloc(ptr,size) realloc(ptr,size)
-#define xf86loadercalloc(num,size) calloc(num,size)
-#define xf86loaderfree(ptr) free(ptr)
-#define xf86loaderstrdup(ptr) strdup(ptr)
-#endif
-
 typedef struct _loader *loaderPtr;
 
-/*
- * _loader_funcs hold the entry points for a module format.
- */
-
-typedef void *(*LoadModuleProcPtr) (loaderPtr modrec, int fd, LOOKUP **, int flags);
-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 */
-} loader_funcs;
-
 /* Each module loaded has a loaderRec */
 typedef struct _loader {
     int handle;			/* Unique id used to remove symbols from
@@ -221,7 +74,6 @@
     char *name;
     char *cname;
     void *private;		/* format specific data */
-    loader_funcs *funcs;	/* funcs for operating on this module */
     loaderPtr next;
 } loaderRec;
 
@@ -234,64 +86,22 @@
     int extensionVersion;
     int fontVersion;
 } ModuleVersions;
-extern ModuleVersions LoaderVersionInfo;
+extern const ModuleVersions LoaderVersionInfo;
 
 extern unsigned long LoaderOptions;
 
 /* Internal Functions */
-
-void LoaderAddSymbols(int, int, LOOKUP *);
-void LoaderDefaultFunc(void);
 void LoaderDuplicateSymbol(const char *, const int);
-
-#if 0
-void LoaderFixups(void);
-#endif
-void LoaderResolve(void);
-int LoaderResolveSymbols(void);
 int _LoaderHandleUnresolved(char *, char *);
-void LoaderHashAdd(itemPtr);
-itemPtr LoaderHashDelete(const char *);
-itemPtr LoaderHashFind(const char *);
-void LoaderHashTraverse(void *, int (*)(void *, itemPtr));
-void LoaderPrintAddress(const char *);
-void LoaderPrintItem(itemPtr);
-void LoaderPrintSymbol(unsigned long);
-void LoaderDumpSymbols(void);
 char *_LoaderModuleToName(int);
-int _LoaderAddressToSection(const unsigned long, const char **,
-			    const char **);
 int LoaderOpen(const char *, const char *, int, int *, int *, int *, int);
 int LoaderHandleOpen(int);
 
-/*
- * File interface functions
- */
-void *_LoaderFileToMem(int fd, unsigned long offset, int size, char *label);
-void _LoaderFreeFileMem(void *addr, int size);
-int _LoaderFileRead(int fd, unsigned int offset, void *addr, int size);
-
-/*
- * Relocation list manipulation routines
- */
-LoaderRelocPtr _LoaderGetRelocations(void *);
-
-/*
- * object to name lookup routines
- */
+/* object to name lookup routines */
 char *_LoaderHandleToName(int handle);
 char *_LoaderHandleToCanonicalName(int handle);
 
-/*
- * Entry points for the different loader types
- */
-#include "aoutloader.h"
-#include "coffloader.h"
-#include "elfloader.h"
+/* Loader backends. */
 #include "dlloader.h"
-/* LD_ARCHIVE */
-void *ARCHIVELoadModule(loaderPtr, int, LOOKUP **, int flags);
-
-extern void _loader_debug_state(void);
 
 #endif /* _LOADER_H */
--- xorg-server-1.1.0/hw/xfree86/loader/loader.c.loader-diet	2006-03-28 02:21:50.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/loader.c	2006-06-19 16:48:07.000000000 -0400
@@ -1,5 +1,3 @@
-/* $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.
  *
@@ -69,12 +67,8 @@
 #include <malloc.h>
 #endif
 #include <stdarg.h>
-#include "ar.h"
-#include "elf.h"
-#include "coff.h"
 
 #include "os.h"
-#include "sym.h"
 #include "loader.h"
 #include "loaderProcs.h"
 #include "xf86.h"
@@ -82,31 +76,11 @@
 
 #include "compiler.h"
 
-extern LOOKUP miLookupTab[];
-extern LOOKUP xfree86LookupTab[];
-extern LOOKUP dixLookupTab[];
-extern LOOKUP fontLookupTab[];
-extern LOOKUP extLookupTab[];
-
-/*
-#define DEBUG
-#define DEBUGAR
-#define DEBUGLIST
-#define DEBUGMEM
-*/
-
-int check_unresolved_sema = 0;
-
 #if defined(Lynx) && defined(sun)
 /* Cross build machine doesn;t have strerror() */
 #define strerror(err) "strerror unsupported"
 #endif
 
-#ifdef __UNIXOS2__
-void *os2ldcalloc(size_t, size_t);
-#endif
-
-#ifdef HANDLE_IN_HASH_ENTRY
 /*
  * handles are used to identify files that are loaded. Even archives
  * are counted as a single file.
@@ -116,7 +90,6 @@
 #define HANDLE_USED 1
 static char freeHandles[MAX_HANDLE];
 static int refCount[MAX_HANDLE];
-#endif
 
 #if defined(__sparc__) && defined(__GNUC__) && !defined(__FreeBSD__)
 # define SYMFUNCDOT(func) { "." #func, (funcptr)&__sparc_dot_ ## func },
@@ -136,26 +109,6 @@
 DEFFUNCDOT(umul)
 DEFFUNCDOT(div)
 DEFFUNCDOT(udiv)
-#ifdef linux
-static LOOKUP SparcV89LookupTab[] = {
-    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}
-};
 
 #ifdef linux
 #if defined(__GNUC__) && defined(__GLIBC__)
@@ -223,22 +176,6 @@
  */
 static int moduleseq = 0;
 
-/*
- * GDB Interface
- * =============
- *
- * Linked list of loaded modules - gdb will traverse this to determine
- * whether it needs to add the symbols for the loaded module.
- */
-LDRModulePtr ModList = 0;
-
-/* Flag which gdb sets to let us know we're being debugged */
-char DebuggerPresent = 0;
-
-/* List of common symbols */
-LDRCommonPtr ldrCommons;
-int nCommons;
-
 typedef struct {
     int num;
     const char **list;
@@ -256,120 +193,18 @@
 static int fatalReqSym = 0;
 
 /* Prototypes for static functions. */
-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)
-{
-}
-
-/*
- * 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 */
-#ifdef DLOPEN_SUPPORT
-    {DLLoadModule,
-     DLResolveSymbols,
-     DLCheckForUnresolved,
-     ARCHIVEAddressToSection,
-     DLUnloadModule, {0, 0, 0, 0, 0}},
-#else
-    {AOUTLoadModule,
-     AOUTResolveSymbols,
-     AOUTCheckForUnresolved,
-     AOUTAddressToSection,
-     AOUTUnloadModule, {0, 0, 0, 0, 0}},
-#endif
-    /* LD_ELFDLOBJECT */
-#ifdef DLOPEN_SUPPORT
-    {DLLoadModule,
-     DLResolveSymbols,
-     DLCheckForUnresolved,
-     ARCHIVEAddressToSection,
-     DLUnloadModule, {0, 0, 0, 0, 0}},
-#else
-    {ELFLoadModule,
-     ELFResolveSymbols,
-     ELFCheckForUnresolved,
-     ELFAddressToSection,
-     ELFUnloadModule, {0, 0, 0, 0, 0}},
-#endif
-};
-
-int numloaders = sizeof(funcs) / sizeof(loader_funcs);
 
 void
 LoaderInit(void)
 {
     const char *osname = NULL;
 
-#ifdef DLOPEN_SUPPORT
     char *ld_bind_now = getenv("LD_BIND_NOW");
     if (ld_bind_now && *ld_bind_now) {
         xf86Msg(X_ERROR, "LD_BIND_NOW is set, dlloader will NOT work!\n");
     }
-#endif
-
-    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);
-    else
-#endif
-	LoaderAddSymbols(-1, -1, SparcLookupTab);
-#endif
 
     xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n");
     xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
@@ -392,16 +227,6 @@
     if (osname)
 	xf86MsgVerb(X_INFO, 2, "Loader running on %s\n", osname);
 
-#if defined(linux) && \
-    (defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \
-     || ( 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);
-#endif
 #if defined(__UNIXWARE__) && !defined(__GNUC__)
     /* For UnixWare we need to load the C Runtime libraries which are
      * normally auto-linked by the compiler. Otherwise we are bound to
@@ -424,250 +249,12 @@
 #endif
 }
 
-/*
- * Determine what type of object is being loaded.
- * This function is responsible for restoring the offset.
- * The fd and offset are used here so that when Archive processing
- * is enabled, individual elements of an archive can be evaluated
- * so the correct loader_funcs can be determined.
- */
-static int
-_GetModuleType(int fd, long offset)
-{
-    unsigned char buf[256];	/* long enough for the largest magic type */
-
-    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]);
-#endif
-
-    lseek(fd, offset, SEEK_SET);
-
-    if (strncmp((char *)buf, ARMAG, SARMAG) == 0) {
-	return LD_ARCHIVE;
-    }
-#if defined(AIAMAG)
-    /* LynxOS PPC style archives */
-    if (strncmp((char *)buf, AIAMAG, SAIAMAG) == 0) {
-	return LD_ARCHIVE;
-    }
-#endif
-
-    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) {
-	/* I386MAGIC */
-	return LD_COFFOBJECT;
-    }
-    if (buf[0] == 0x01 && buf[1] == 0xdf) {
-	/* XCOFFMAGIC */
-	return LD_COFFOBJECT;
-    }
-    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] == 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] == 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 */
-
-/*
- * _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)
-{
-#ifdef UseMMAP
-    unsigned long ret;
-
-# ifdef MmapPageAlign
-    unsigned long pagesize;
-    unsigned long new_size;
-    unsigned long new_off;
-    unsigned long new_off_bias;
-# endif
-# define MMAP_PROT	(PROT_READ|PROT_WRITE|PROT_EXEC)
-
-# ifdef DEBUGMEM
-    ErrorF("_LoaderFileToMem(%d,%u(%u),%d,%s)", fd, offset, offsetbias, size,
-	   label);
-# endif
-# ifdef MmapPageAlign
-    pagesize = getpagesize();
-    new_size = (size + pagesize - 1) / pagesize;
-    new_size *= pagesize;
-    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 __amd64__
-			      | MAP_32BIT
-#  endif
-			      , 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 __amd64__
-			      | MAP_32BIT
-#  endif
-			      , 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);
-# endif
-
-    if (size == 0) {
-# ifdef DEBUGMEM
-	ErrorF("=NULL\n", ptr);
-# endif
-	return NULL;
-    }
-# ifndef __UNIXOS2__
-    if ((ptr = xf86loadercalloc(size, 1)) == NULL)
-	FatalError("_LoaderFileToMem() malloc failed\n");
-# else
-    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);
-    }
-# endif
-
-    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 (defined(linux) || defined(__NetBSD__) || defined(__OpenBSD__) \
-    || defined(__FreeBSD__)) && 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);
-    }
-# endif
-
-# ifdef DEBUGMEM
-    ErrorF("=%lx\n", ptr);
-# endif
-
-    return (void *)ptr;
-#endif
-}
-
-/*
- * _LoaderFreeFileMem() free the memory in which a file was loaded.
- */
-void
-_LoaderFreeFileMem(void *addr, int size)
-{
-#if defined (UseMMAP) && defined (MmapPageAlign)
-    unsigned long pagesize = getpagesize();
-    memType i_addr = (memType) addr;
-    unsigned long new_size;
-#endif
-#ifdef DEBUGMEM
-    ErrorF("_LoaderFreeFileMem(%x,%d)\n", addr, size);
-#endif
-#ifdef UseMMAP
-# if defined (MmapPageAlign)
-    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);
-# else
-    munmap((void *)addr, size);
-# endif
-#else
-    if (size == 0)
-	return;
-
-    xf86loaderfree(addr);
-#endif
-
-    return;
-}
-
-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 (read(fd, buf, size) != size)
-	FatalError("_LoaderFileRead() read() failed: %s\n", strerror(errno));
-
-    return size;
-}
-
 static loaderPtr listHead = (loaderPtr) 0;
 
 static loaderPtr
 _LoaderListPush()
 {
-    loaderPtr item = xf86loadercalloc(1, sizeof(struct _loader));
+    loaderPtr item = calloc(1, sizeof(struct _loader));
 
     item->next = listHead;
     listHead = item;
@@ -789,28 +376,6 @@
 }
 
 /*
- * _LoaderAddressToSection() will return the name of the file & section
- * that contains the given address.
- */
-int
-_LoaderAddressToSection(const unsigned long address, const char **module,
-			const char **section)
-{
-    loaderPtr item = listHead;
-
-    while (item) {
-	if ((*section =
-	     item->funcs->AddressToSection(item->private, address)) != NULL) {
-	    *module = _LoaderModuleToName(item->module);
-	    return 1;
-	}
-	item = item->next;
-    }
-
-    return 0;
-}
-
-/*
  * Add a list of symbols to the referenced list.
  */
 
@@ -969,283 +534,15 @@
     return (fatalsym);
 }
 
-/*
- * Handle an archive.
- */
-void *
-ARCHIVELoadModule(loaderPtr modrec, int arfd, LOOKUP ** ppLookup, int flags)
-{
-    loaderPtr tmp = NULL;
-    void *ret = NULL;
-    unsigned char magic[SARMAG];
-    struct ar_hdr hdr;
-
-#if defined(__powerpc__) && defined(Lynx)
-    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;
-    LOOKUP *lookup_ret, *p;
-    LOOKUP *myLookup = NULL;	/* Does realloc behave if ptr == 0? */
-    int modtype;
-    int i;
-    int numsyms = 0;
-
-    /* lookup_ret = xf86loadermalloc(sizeof (LOOKUP *)); */
-
-    arnamesize = strlen(modrec->name);
-
-#if !(defined(__powerpc__) && defined(Lynx))
-    read(arfd, magic, SARMAG);
-
-    if (strncmp((const char *)magic, ARMAG, SARMAG) != 0) {
-	ErrorF("ARCHIVELoadModule: wrong magic!!\n");
-	return NULL;
-    }
-#else
-    read(arfd, &fhdr, FL_HSZ);
-
-    if (strncmp(fhdr.fl_magic, AIAMAG, SAIAMAG) != 0) {
-	ErrorF("ARCHIVELoadModule: wrong magic!!\n");
-	return NULL;
-    }
-#endif /* __powerpc__ && Lynx */
-
-#ifdef DEBUGAR
-    ErrorF("Looking for archive members starting at offset %o\n", offset);
-#endif
-
-    while (read(arfd, &hdr, sizeof(struct ar_hdr))) {
-
-	longname = NULL;
-	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 */
-#endif
-	offset = lseek(arfd, 0, SEEK_CUR);
-
-	/* Check for a Symbol Table */
-	if ((hdr.ar_name[0] == '/' && hdr.ar_name[1] == ' ') ||
-#if defined(__powerpc__) && defined(Lynx)
-	    namlen == 0 ||
-#endif
-	    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);
-#endif
-	    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 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);
-#endif
-	    nametablelen = size;
-	    nametable = (char *)xf86loadermalloc(nametablelen);
-	    read(arfd, nametable, size);
-	    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 */
-	    continue;
-	}
-
-	if (hdr.ar_name[0] == '/') {
-	    /*  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);
-		offsetbias = 0;
-		return NULL;
-	    }
-	    if (nameoffset > nametablelen) {
-		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, '/');
-	    if (slash)
-		*slash = '\0';
-	    longname = xf86loadermalloc(arnamesize + strlen(membername) + 2);
-	    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) {
-		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);
-	    if (i != modnamesize) {
-		ErrorF("Bad archive member %s\n", hdr.ar_name);
-		xf86loaderfree(longname);
-		offsetbias = 0;
-		return NULL;
-	    }
-	    longname[i] = '\0';
-	    offset += i;
-	    size -= i;
-	} else {
-	    /* Regular archive member */
-#ifdef DEBUGAR
-	    ErrorF("Member '%16.16s', size %d, offset %x\n",
-#if !(defined(__powerpc__) && defined(Lynx))
-		   hdr.ar_name,
-#else
-		   name,
-#endif
-		   size, offset);
-#endif
-
-	    slash = strchr(hdr.ar_name, '/');
-	    if (slash == NULL) {
-		/* BSD format without trailing slash */
-		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 ((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->handle = modrec->handle;
-	tmp->module = moduleseq++;
-	tmp->cname = xf86loadermalloc(strlen(modrec->cname) + 1);
-	strcpy(tmp->cname, modrec->cname);
-	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);
-
-	} else {
-	    tmp->name = longname;
-	}
-	offsetbias = offset;
-
-	if ((tmp->private = funcs[modtype].LoadModule(tmp, arfd, &lookup_ret, LD_FLAG_GLOBAL))
-	    == 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 */
-
-	if (tmp->private == (void *)-1L) {
-	    xf86Msg(X_INFO, "Skipping \"%s\":  "
-		    "object file contains no symbols\n",
-		    tmp->name);
-	    continue;
-	} 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++) ;
-	if (i) {
-	    myLookup = xf86loaderrealloc(myLookup, (numsyms + i + 1)
-					 * sizeof(LOOKUP));
-	    if (!myLookup)
-		continue;	/* Oh well! */
-
-	    memcpy(&(myLookup[numsyms]), lookup_ret, i * sizeof(LOOKUP));
-	    numsyms += i;
-	    myLookup[numsyms].symName = 0;
-	}
-	xf86loaderfree(lookup_ret);
-    }
-    /* xf86loaderfree(lookup_ret); */
-    offsetbias = 0;
-
-    *ppLookup = myLookup;
-    if (nametable)
-	xf86loaderfree(nametable);
-
-    return ret;
-}
-
-/*
- * Relocation list manipulation routines
- */
-
-/*
- * _LoaderGetRelocations() Return the list of outstanding relocations
- */
-LoaderRelocPtr
-_LoaderGetRelocations(void *mod)
-{
-    loader_funcs *formatrec = (loader_funcs *) mod;
-
-    return &(formatrec->pRelocs);
-}
-
-
-/*
- * Public Interface to the loader.
- */
+/* Public Interface to the loader. */
 
 int
 LoaderOpen(const char *module, const char *cname, int handle,
 	   int *errmaj, int *errmin, int *wasLoaded, int flags)
 {
     loaderPtr tmp;
-    int new_handle, modtype;
+    int new_handle;
     int fd;
-    LOOKUP *pLookup;
 
 #if defined(DEBUG)
     ErrorF("LoaderOpen(%s)\n", module);
@@ -1311,26 +608,15 @@
 	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;
-	return -1;
-    }
-
     tmp = _LoaderListPush();
-    tmp->name = xf86loadermalloc(strlen(module) + 1);
+    tmp->name = malloc(strlen(module) + 1);
     strcpy(tmp->name, module);
-    tmp->cname = xf86loadermalloc(strlen(cname) + 1);
+    tmp->cname = malloc(strlen(cname) + 1);
     strcpy(tmp->cname, cname);
     tmp->handle = new_handle;
     tmp->module = moduleseq++;
-    tmp->funcs = &funcs[modtype];
 
-    if ((tmp->private = funcs[modtype].LoadModule(tmp, fd, &pLookup, flags)) == NULL) {
+    if ((tmp->private = DLLoadModule(tmp, fd, flags)) == NULL) {
 	xf86Msg(X_ERROR, "Failed to load %s\n", module);
 	_LoaderListPop(new_handle);
 	freeHandles[new_handle] = HANDLE_FREE;
@@ -1341,11 +627,6 @@
 	return -1;
     }
 
-    if (tmp->private != (void *)-1L) {
-	LoaderAddSymbols(new_handle, tmp->module, pLookup);
-	xf86loaderfree(pLookup);
-    }
-
     close(fd);
 
     return new_handle;
@@ -1367,54 +648,13 @@
 _X_EXPORT void *
 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;
-    else
-#ifdef DLOPEN_SUPPORT
-	return (DLFindSymbol(sym));
-#else
-	return NULL;
-#endif
-}
-
-int
-LoaderResolveSymbols(void)
-{
-    int i;
-
-    for (i = 0; i < numloaders; i++)
-	funcs[i].ResolveSymbols(&funcs[i]);
-    return 0;
+    return (DLFindSymbol(sym));
 }
 
 _X_EXPORT int
 LoaderCheckUnresolved(int delay_flag)
 {
-    int i, ret = 0;
-    LoaderResolveOptions delayFlag = (LoaderResolveOptions)delay_flag;
-
-    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 (!check_unresolved_sema || delayFlag == LD_RESOLV_FORCE)
-	for (i = 0; i < numloaders; i++)
-	    if (funcs[i].CheckForUnresolved(&funcs[i]))
-		ret = 1;
+    int ret = 0;
 
     if (fatalReqSym)
 	FatalError("Some required symbols were unresolved\n");
@@ -1422,24 +662,6 @@
     return ret;
 }
 
-void xf86LoaderTrap(void);
-
-void
-xf86LoaderTrap(void)
-{
-}
-
-_X_EXPORT void
-LoaderDefaultFunc(void)
-{
-    ErrorF("\n\n\tThis should not happen!\n"
-	   "\tAn unresolved function was called!\n");
-
-    xf86LoaderTrap();
-
-    FatalError("\n");
-}
-
 int
 LoaderUnload(int handle)
 {
@@ -1463,10 +685,10 @@
 	    /* 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);
+	DLUnloadModule(tmp->private);
+	free(tmp->name);
+	free(tmp->cname);
+	free(tmp);
     }
 
     freeHandles[handle] = HANDLE_FREE;
@@ -1483,12 +705,6 @@
     FatalError("Module load failure\n");
 }
 
-/* GDB Sync function */
-void
-_loader_debug_state()
-{
-}
-
 unsigned long LoaderOptions = 0;
 
 void
--- xorg-server-1.1.0/hw/xfree86/loader/dlloader.h.loader-diet	2006-03-11 19:11:34.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/dlloader.h	2006-06-19 16:48:07.000000000 -0400
@@ -19,19 +19,15 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dlloader.h,v 1.2 1998/07/25 16:56:14 dawes Exp $ */
-
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
 
 #ifndef _DLLOADER_H
 #define _DLLOADER_H
-extern void *DLLoadModule(loaderPtr, int, LOOKUP **, int flags);
-extern void DLResolveSymbols(void *);
-extern int DLCheckForUnresolved(void *);
+
+extern void *DLLoadModule(loaderPtr, int, int flags);
 extern void DLUnloadModule(void *);
 extern void *DLFindSymbol(const char *name);
-extern void *DLFindSymbolLocal(pointer module, const char *name);
 
 #endif
--- xorg-server-1.1.0/hw/xfree86/loader/loadext.c.loader-diet	2006-03-25 14:52:04.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/loadext.c	2006-06-19 16:48:07.000000000 -0400
@@ -1,4 +1,3 @@
-/* $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.
  *
@@ -37,6 +36,10 @@
 #include "misc.h"
 #include "xf86.h"
 
+/*
+ * This should be static, but miinitext wants it.  FIXME: make extension
+ * initialization not completely terrible.
+ */
 ExtensionModule *ExtensionModuleList = NULL;
 static int numExtensionModules = 0;
 
--- xorg-server-1.1.0/hw/xfree86/loader/loadfont.c.loader-diet	2006-03-25 14:52:04.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/loadfont.c	2006-06-19 16:48:07.000000000 -0400
@@ -1,4 +1,3 @@
-/* $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.
  *
@@ -37,6 +36,7 @@
 #include "misc.h"
 #include "xf86.h"
 
+/* XXX this should be static, but xorgcfg needs it, nngh */
 FontModule *FontModuleList = NULL;
 static int numFontModules = 0;
 
--- xorg-server-1.1.0/hw/xfree86/loader/dlloader.c.loader-diet	2006-03-11 19:11:34.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/dlloader.c	2006-06-19 16:48:07.000000000 -0400
@@ -1,7 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dlloader.c,v 1.13 2003/10/15 16:29:02 dawes Exp $ */
-
 /*
- *
  * Copyright (c) 1997 The XFree86 Project, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software
@@ -23,7 +20,18 @@
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.  */
+ * SOFTWARE.
+ */
+
+/*
+ * Once upon a time, X had multiple loader backends, three of which were
+ * essentially libdl reimplementations.  This was nonsense so we chucked
+ * it, but we still retain the factorization between loader API and
+ * platform implementation.  This file is the libdl implementation, and
+ * currently the only backend.  If you find yourself porting to a platform
+ * without working libdl - hpux, win32, some forsaken a.out host, etc. -
+ * make a new backend rather than hacking up this file.
+ */
 
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
@@ -36,82 +44,67 @@
 #include <X11/Xos.h>
 #include "os.h"
 
-#include "sym.h"
 #include "loader.h"
 #include "dlloader.h"
 
-#ifdef DL_LAZY
+#if defined(DL_LAZY)
 #define DLOPEN_LAZY DL_LAZY
-#else
-#ifdef RTLD_LAZY
+#elif defined(RTLD_LAZY)
 #define DLOPEN_LAZY RTLD_LAZY
-#else
-#ifdef __FreeBSD__
+#elif defined(__FreeBSD__)
 #define DLOPEN_LAZY 1
 #else
 #define DLOPEN_LAZY 0
 #endif
-#endif
-#endif
-#ifdef LD_GLOBAL
+
+#if defined(LD_GLOBAL)
 #define DLOPEN_GLOBAL LD_GLOBAL
-#else
-#ifdef RTLD_GLOBAL
+#elif defined(RTLD_GLOBAL)
 #define DLOPEN_GLOBAL RTLD_GLOBAL
 #else
 #define DLOPEN_GLOBAL 0
 #endif
-#endif
 
 #if defined(CSRG_BASED) && !defined(__ELF__)
-#define NEED_UNDERSCORE_FOR_DLLSYM
+#define DLSYM_PREFIX "_"
+#else
+#define DLSYM_PREFIX ""
 #endif
 
-/*
- * This structure contains all of the information about a module
- * that has been loaded.
- */
 typedef struct {
     int handle;
     void *dlhandle;
     int flags;
 } DLModuleRec, *DLModulePtr;
 
-/* 
- * a list of loaded modules XXX can be improved
- */
+/* Hooray, yet another open coded linked list! FIXME */
 typedef struct DLModuleList {
     DLModulePtr module;
     struct DLModuleList *next;
 } DLModuleList;
 
-DLModuleList *dlModuleList = NULL;
+static DLModuleList *dlModuleList = NULL;
 
-void *
+static void *
 DLFindSymbolLocal(pointer module, const char *name)
 {
     DLModulePtr dlfile = module;
     void *p;
     char *n;
 
-#ifdef NEED_UNDERSCORE_FOR_DLLSYM
-    static const char symPrefix[] = "_";
-#else
-    static const char symPrefix[] = "";
-#endif
+    static const char symPrefix[] = DLSYM_PREFIX;
 
-    n = xf86loadermalloc(strlen(symPrefix) + strlen(name) + 1);
-    sprintf(n, "%s%s", symPrefix, name);
+    n = malloc(strlen(symPrefix) + strlen(name) + 1);
+    if (strlen(symPrefix))
+	sprintf(n, "%s%s", symPrefix, name);
+    else
+	sprintf(n, "%s", name);
     p = dlsym(dlfile->dlhandle, n);
-    xf86loaderfree(n);
+    free(n);
 
     return p;
 }
 
-
-/*
- * Search a symbol in the module list
- */
 void *
 DLFindSymbol(const char *name)
 {
@@ -127,75 +120,59 @@
     return NULL;
 }
 
-/*
- * public interface
- */
 void *
-DLLoadModule(loaderPtr modrec, int fd, LOOKUP ** ppLookup, int flags)
+DLLoadModule(loaderPtr modrec, int fd, int flags)
 {
     DLModulePtr dlfile;
     DLModuleList *l;
     int dlopen_flags;
 
-    if ((dlfile = xf86loadercalloc(1, sizeof(DLModuleRec))) == NULL) {
-	ErrorF("Unable  to allocate DLModuleRec\n");
+    if ((dlfile = calloc(1, sizeof(DLModuleRec))) == NULL) {
+	ErrorF("Unable to allocate DLModuleRec\n");
 	return NULL;
     }
     dlfile->handle = modrec->handle;
     if (flags & LD_FLAG_GLOBAL)
-      dlopen_flags = DLOPEN_LAZY | DLOPEN_GLOBAL;
+	dlopen_flags = DLOPEN_LAZY | DLOPEN_GLOBAL;
     else
-      dlopen_flags = DLOPEN_LAZY;
+	dlopen_flags = DLOPEN_LAZY;
     dlfile->dlhandle = dlopen(modrec->name, dlopen_flags);
     if (dlfile->dlhandle == NULL) {
 	ErrorF("dlopen: %s\n", dlerror());
-	xf86loaderfree(dlfile);
+	free(dlfile);
 	return NULL;
     }
 
-    l = xf86loadermalloc(sizeof(DLModuleList));
+    l = malloc(sizeof(DLModuleList));
     l->module = dlfile;
     l->next = dlModuleList;
     dlModuleList = l;
-    *ppLookup = NULL;
 
     return (void *)dlfile;
 }
 
 void
-DLResolveSymbols(void *mod)
-{
-    return;
-}
-
-int
-DLCheckForUnresolved(void *mod)
-{
-    return 0;
-}
-
-void
 DLUnloadModule(void *modptr)
 {
     DLModulePtr dlfile = (DLModulePtr) modptr;
     DLModuleList *l, *p;
 
-    /*  remove it from dlModuleList */
+    /* remove it from dlModuleList. */
     if (dlModuleList->module == modptr) {
 	l = dlModuleList;
 	dlModuleList = l->next;
-	xf86loaderfree(l);
+	free(l);
     } else {
 	p = dlModuleList;
 	for (l = dlModuleList->next; l != NULL; l = l->next) {
 	    if (l->module == modptr) {
 		p->next = l->next;
-		xf86loaderfree(l);
+		free(l);
 		break;
 	    }
 	    p = l;
 	}
     }
     dlclose(dlfile->dlhandle);
-    xf86loaderfree(modptr);
+    free(modptr);
 }
--- xorg-server-1.1.0/hw/xfree86/loader/loaderProcs.h.loader-diet	2006-03-11 19:11:34.000000000 -0500
+++ xorg-server-1.1.0/hw/xfree86/loader/loaderProcs.h	2006-06-19 16:48:07.000000000 -0400
@@ -1,7 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loaderProcs.h,v 1.21 2003/10/15 16:29:04 dawes Exp $ */
-
 /*
- *
  * Copyright 1995-1998 by Metro Link, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -78,9 +75,7 @@
     const XF86ModuleVersionInfo *VersionInfo;
 } ModuleDesc, *ModuleDescPtr;
 
-/*
- * Extenal API for the loader 
- */
+/* External API for the loader */
 
 void LoaderInit(void);
 
--- xorg-server-1.1.0/hw/xfree86/Makefile.am.loader-diet	2006-05-09 14:04:29.000000000 -0400
+++ xorg-server-1.1.0/hw/xfree86/Makefile.am	2006-06-19 16:48:07.000000000 -0400
@@ -36,11 +36,11 @@
 XORG_LIBS = \
             @XORG_CORE_LIBS@ \
             common/libinit.a \
-            loader/libloader.a \
             libosandcommon.la \
             parser/libxf86config.a \
             dummylib/libdummy.a \
 	    dixmods/libdixmods.la \
+            loader/libloader.a \
             @XORG_LIBS@
 
 Xorg_LDADD = $(XORG_LIBS) \
--- xorg-server-1.1.0/configure.ac.loader-diet	2006-05-22 13:18:49.000000000 -0400
+++ xorg-server-1.1.0/configure.ac	2006-06-19 16:48:34.000000000 -0400
@@ -1041,7 +1041,7 @@
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
 	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
 	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
-	XORG_LIBS="$MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $LBX_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
+	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $LBX_LIB $XPSTUBS_LIB $OS_LIB"
 
 	AC_CHECK_LIB([dl], [dlopen], XORG_LIBS="$XORG_LIBS -ldl")
 
@@ -1250,10 +1250,6 @@
 	AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
 	AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
 	AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
-	# XXX HACK!  if anyone cares about elfloader in 7.0 you need to
-	# XXX do something smarter here.
-	AC_DEFINE(DLOPEN_HACK, 1, [Prefer dlloader modules to elfloader])
-	AC_DEFINE(DLOPEN_SUPPORT, 1, [Use libdl-based loader])
 	AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
 	AC_DEFINE(DRIVERS, {}, [Built-in output drivers (none)])
 	AC_DEFINE(IDRIVERS, {}, [Built-in input drivers (none)])


Index: xorg-x11-server.spec
===================================================================
RCS file: /cvs/dist/rpms/xorg-x11-server/devel/xorg-x11-server.spec,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- xorg-x11-server.spec	19 Jun 2006 20:09:35 -0000	1.87
+++ xorg-x11-server.spec	19 Jun 2006 21:22:27 -0000	1.88
@@ -38,6 +38,7 @@
 Patch2000:  xorg-x11-server-1.1.0-cw-crash-fix.patch
 Patch2001:  xorg-x11-server-1.1.0-pci-scan-fixes.patch
 Patch2002:  xorg-x11-server-1.1.0-hush-crash-message.patch
+Patch2003:  xorg-x11-server-1.1.0-loader-diet.patch
 
 # autoconfiguration feature patches
 #Patch3000:  xorg-x11-server-1.1.0-input-autoconfig-2.patch
@@ -298,6 +299,7 @@
 %patch2000 -p1 -b .cw-crash
 %patch2001 -p1 -b .pci-scan
 %patch2002 -p1 -b .crash-message
+%patch2003 -p1 -b .loader-diet
 
 %patch3001 -p1 -b .edid1
 %patch3002 -p1 -b .cvt
@@ -602,8 +604,8 @@
 * Mon Jun 19 2006 Adam Jackson <ajackson at redhat.com> 1.1.0-17
 - Disable filling in monitor gamma info from EDID momentarily, since drivers
   will use that field to set the card's gamma ramp.
-- Backport some stuff from git: cw crash fix, faster pci scanning, and a
-  log message cleanup.
+- Backport some stuff from git: cw crash fix, faster pci scanning, some
+  log message cleanup, and a massive debloating of the loader.
 
 * Fri Jun 16 2006 Mike A. Harris <mharris at redhat.com> 1.1.0-16
 - Enable spec support for s390, s390x, alpha, sparc, and sparc64 architectures.




More information about the fedora-cvs-commits mailing list