From c24ed7019341148dab6d639b026aaf701e8fac0c Mon Sep 17 00:00:00 2001 From: Marc G. Fournier Date: Tue, 10 Mar 1998 05:24:33 +0000 Subject: Get the ultrix4 ports back in sync... --- src/backend/port/dynloader/ultrix4.c | 75 ++++++++++++++++++++ src/backend/port/dynloader/ultrix4.h | 123 +++++++++++++++++++++++++++++++++ src/backend/port/ultrix4/Makefile | 34 --------- src/backend/port/ultrix4/dl.h | 123 --------------------------------- src/backend/port/ultrix4/dynloader.c | 75 -------------------- src/backend/port/ultrix4/port-protos.h | 43 ------------ 6 files changed, 198 insertions(+), 275 deletions(-) create mode 100644 src/backend/port/dynloader/ultrix4.c create mode 100644 src/backend/port/dynloader/ultrix4.h delete mode 100644 src/backend/port/ultrix4/Makefile delete mode 100644 src/backend/port/ultrix4/dl.h delete mode 100644 src/backend/port/ultrix4/dynloader.c delete mode 100644 src/backend/port/ultrix4/port-protos.h (limited to 'src') diff --git a/src/backend/port/dynloader/ultrix4.c b/src/backend/port/dynloader/ultrix4.c new file mode 100644 index 00000000000..7d1d493c2bc --- /dev/null +++ b/src/backend/port/dynloader/ultrix4.c @@ -0,0 +1,75 @@ +/*------------------------------------------------------------------------- + * + * dynloader.c-- + * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x. + * (Note that pg_dlsym and pg_dlclose are actually macros defined in + * "port-protos.h".) + * + * Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/port/dynloader/ultrix4.c,v 1.1 1998/03/10 05:23:40 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +#include +#include +#include "dl.h" +#include +#include "c.h" +#include "fmgr.h" +#include "port-protos.h" +#include "utils/elog.h" + +extern char pg_pathname[]; + +void * +pg_dlopen(char *filename) +{ + static int dl_initialized = 0; + void *handle; + + /* + * initializes the dynamic loader with the executable's pathname. + * (only needs to do this the first time pg_dlopen is called.) + */ + if (!dl_initialized) + { + if (!dl_init(pg_pathname)) + { + return NULL; + } + + /* + * if there are undefined symbols, we want dl to search from the + * following libraries also. + */ + dl_setLibraries("/usr/lib/libm_G0.a:/usr/lib/libc_G0.a"); + dl_initialized = 1; + } + + /* + * open the file. We do the symbol resolution right away so that we + * will know if there are undefined symbols. (This is in fact the same + * semantics as "ld -A". ie. you cannot have undefined symbols. + */ + if ((handle = dl_open(filename, DL_NOW)) == NULL) + { + int count; + char **list = dl_undefinedSymbols(&count); + + /* list the undefined symbols, if any */ + if (count) + { + elog(NOTICE, "dl: Undefined:"); + while (*list) + { + elog(NOTICE, " %s", *list); + list++; + } + } + } + + return (void *) handle; +} diff --git a/src/backend/port/dynloader/ultrix4.h b/src/backend/port/dynloader/ultrix4.h new file mode 100644 index 00000000000..47bb5e33392 --- /dev/null +++ b/src/backend/port/dynloader/ultrix4.h @@ -0,0 +1,123 @@ +/*------------------------------------------------------------------------- + * + * dl.h-- + * + * + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: ultrix4.h,v 1.1 1998/03/10 05:23:46 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ +/* + * Ultrix 4.x Dynamic Loader Library Version 1.0 + * + * dl.h-- + * header file for the Dynamic Loader Library + * + * + * Copyright (c) 1993 Andrew K. Yu, University of California at Berkeley + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for educational, research, and non-profit purposes and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation. Permission + * to incorporate this software into commercial products can be obtained + * from the author. The University of California and the author make + * no representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied warranty. + * + */ +#ifndef _DL_HEADER_ +#define _DL_HEADER_ + +#include /* needed to declare FILE for ldfcn.h */ +#include +#include +#include +#include +#include + + +typedef long CoreAddr; + + +typedef struct ScnInfo +{ + CoreAddr addr; /* starting address of the section */ + SCNHDR hdr; /* section header */ + RELOC *relocEntries; /* relocation entries */ +} ScnInfo; + +typedef enum +{ + DL_NEEDRELOC, /* still need relocation */ + DL_RELOCATED, /* no relocation necessary */ + DL_INPROG /* relocation in progress */ +} dlRStatus; + +typedef struct JmpTbl +{ + char *block; /* the jump table memory block */ + struct JmpTbl *next; /* next block */ +} JmpTbl; + +typedef struct dlFile +{ + char *filename; /* file name of the object file */ + + int textSize; /* used by mprotect */ + CoreAddr textAddress; /* start addr of text section */ + long textVaddr; /* vaddr of text section in obj file */ + CoreAddr rdataAddress; /* start addr of rdata section */ + long rdataVaddr; /* vaddr of text section in obj file */ + CoreAddr dataAddress; /* start addr of data section */ + long dataVaddr; /* vaddr of text section in obj file */ + CoreAddr bssAddress; /* start addr of bss section */ + long bssVaddr; /* vaddr of text section in obj file */ + + int nsect; /* number of sections */ + ScnInfo *sect; /* details of each section (array) */ + + int issExtMax; /* size of string space */ + char *extss; /* extern sym string space (in core) */ + int iextMax; /* maximum number of Symbols */ + pEXTR extsyms; /* extern syms */ + + dlRStatus relocStatus; /* what relocation needed? */ + int needReloc; + + JmpTbl *jmptable; /* the jump table for R_JMPADDR */ + + struct dlFile *next; /* next member of the archive */ +} dlFile; + +typedef struct dlSymbol +{ + char *name; /* name of the symbol */ + long addr; /* address of the symbol */ + dlFile *objFile; /* from which file */ +} dlSymbol; + +/* + * prototypes for the dl* interface + */ +extern void *dl_open( /* char *filename, int mode */ ); +extern void *dl_sym( /* void *handle, char *name */ ); +extern void dl_close( /* void *handle */ ); +extern char *dl_error( /* void */ ); + +#define DL_LAZY 0 /* lazy resolution */ +#define DL_NOW 1 /* immediate resolution */ + +/* + * Miscellaneous utility routines: + */ +extern char **dl_undefinedSymbols( /* int *count */ ); +extern void dl_printAllSymbols( /* void *handle */ ); +extern void dl_setLibraries( /* char *libs */ ); + +#endif /* _DL_HEADER_ */ diff --git a/src/backend/port/ultrix4/Makefile b/src/backend/port/ultrix4/Makefile deleted file mode 100644 index db84c05a3e7..00000000000 --- a/src/backend/port/ultrix4/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#------------------------------------------------------------------------- -# -# Makefile-- -# Makefile for port/ultrix -# -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/Makefile,v 1.3 1997/12/20 00:26:38 scrappy Exp $ -# -#------------------------------------------------------------------------- - -SRCDIR = ../../.. -include ../../../Makefile.global - -INCLUDE_OPT = -I../.. - -CFLAGS+=$(INCLUDE_OPT) - -OBJS = dynloader.o port.o strdup.o - -all: SUBSYS.o - -SUBSYS.o: $(OBJS) - $(LD) -r -o SUBSYS.o $(OBJS) - -depend dep: - $(CC) -MM $(INCLUDE_OPT) *.c >depend - -clean: - rm -f SUBSYS.o $(OBJS) - -ifeq (depend,$(wildcard depend)) -include depend -endif - diff --git a/src/backend/port/ultrix4/dl.h b/src/backend/port/ultrix4/dl.h deleted file mode 100644 index 9014e151a5c..00000000000 --- a/src/backend/port/ultrix4/dl.h +++ /dev/null @@ -1,123 +0,0 @@ -/*------------------------------------------------------------------------- - * - * dl.h-- - * - * - * - * Copyright (c) 1994, Regents of the University of California - * - * $Id: dl.h,v 1.5 1997/09/08 02:27:33 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -/* - * Ultrix 4.x Dynamic Loader Library Version 1.0 - * - * dl.h-- - * header file for the Dynamic Loader Library - * - * - * Copyright (c) 1993 Andrew K. Yu, University of California at Berkeley - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for educational, research, and non-profit purposes and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation. Permission - * to incorporate this software into commercial products can be obtained - * from the author. The University of California and the author make - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ -#ifndef _DL_HEADER_ -#define _DL_HEADER_ - -#include /* needed to declare FILE for ldfcn.h */ -#include -#include -#include -#include -#include - - -typedef long CoreAddr; - - -typedef struct ScnInfo -{ - CoreAddr addr; /* starting address of the section */ - SCNHDR hdr; /* section header */ - RELOC *relocEntries; /* relocation entries */ -} ScnInfo; - -typedef enum -{ - DL_NEEDRELOC, /* still need relocation */ - DL_RELOCATED, /* no relocation necessary */ - DL_INPROG /* relocation in progress */ -} dlRStatus; - -typedef struct JmpTbl -{ - char *block; /* the jump table memory block */ - struct JmpTbl *next; /* next block */ -} JmpTbl; - -typedef struct dlFile -{ - char *filename; /* file name of the object file */ - - int textSize; /* used by mprotect */ - CoreAddr textAddress; /* start addr of text section */ - long textVaddr; /* vaddr of text section in obj file */ - CoreAddr rdataAddress; /* start addr of rdata section */ - long rdataVaddr; /* vaddr of text section in obj file */ - CoreAddr dataAddress; /* start addr of data section */ - long dataVaddr; /* vaddr of text section in obj file */ - CoreAddr bssAddress; /* start addr of bss section */ - long bssVaddr; /* vaddr of text section in obj file */ - - int nsect; /* number of sections */ - ScnInfo *sect; /* details of each section (array) */ - - int issExtMax; /* size of string space */ - char *extss; /* extern sym string space (in core) */ - int iextMax; /* maximum number of Symbols */ - pEXTR extsyms; /* extern syms */ - - dlRStatus relocStatus; /* what relocation needed? */ - int needReloc; - - JmpTbl *jmptable; /* the jump table for R_JMPADDR */ - - struct dlFile *next; /* next member of the archive */ -} dlFile; - -typedef struct dlSymbol -{ - char *name; /* name of the symbol */ - long addr; /* address of the symbol */ - dlFile *objFile; /* from which file */ -} dlSymbol; - -/* - * prototypes for the dl* interface - */ -extern void *dl_open( /* char *filename, int mode */ ); -extern void *dl_sym( /* void *handle, char *name */ ); -extern void dl_close( /* void *handle */ ); -extern char *dl_error( /* void */ ); - -#define DL_LAZY 0 /* lazy resolution */ -#define DL_NOW 1 /* immediate resolution */ - -/* - * Miscellaneous utility routines: - */ -extern char **dl_undefinedSymbols( /* int *count */ ); -extern void dl_printAllSymbols( /* void *handle */ ); -extern void dl_setLibraries( /* char *libs */ ); - -#endif /* _DL_HEADER_ */ diff --git a/src/backend/port/ultrix4/dynloader.c b/src/backend/port/ultrix4/dynloader.c deleted file mode 100644 index 55271c5e0e6..00000000000 --- a/src/backend/port/ultrix4/dynloader.c +++ /dev/null @@ -1,75 +0,0 @@ -/*------------------------------------------------------------------------- - * - * dynloader.c-- - * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x. - * (Note that pg_dlsym and pg_dlclose are actually macros defined in - * "port-protos.h".) - * - * Copyright (c) 1994, Regents of the University of California - * - * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.6 1998/02/26 04:34:39 momjian Exp $ - * - *------------------------------------------------------------------------- - */ -#include -#include -#include "dl.h" -#include -#include "c.h" -#include "fmgr.h" -#include "port-protos.h" -#include "utils/elog.h" - -extern char pg_pathname[]; - -void * -pg_dlopen(char *filename) -{ - static int dl_initialized = 0; - void *handle; - - /* - * initializes the dynamic loader with the executable's pathname. - * (only needs to do this the first time pg_dlopen is called.) - */ - if (!dl_initialized) - { - if (!dl_init(pg_pathname)) - { - return NULL; - } - - /* - * if there are undefined symbols, we want dl to search from the - * following libraries also. - */ - dl_setLibraries("/usr/lib/libm_G0.a:/usr/lib/libc_G0.a"); - dl_initialized = 1; - } - - /* - * open the file. We do the symbol resolution right away so that we - * will know if there are undefined symbols. (This is in fact the same - * semantics as "ld -A". ie. you cannot have undefined symbols. - */ - if ((handle = dl_open(filename, DL_NOW)) == NULL) - { - int count; - char **list = dl_undefinedSymbols(&count); - - /* list the undefined symbols, if any */ - if (count) - { - elog(NOTICE, "dl: Undefined:"); - while (*list) - { - elog(NOTICE, " %s", *list); - list++; - } - } - } - - return (void *) handle; -} diff --git a/src/backend/port/ultrix4/port-protos.h b/src/backend/port/ultrix4/port-protos.h deleted file mode 100644 index fc3b40c7629..00000000000 --- a/src/backend/port/ultrix4/port-protos.h +++ /dev/null @@ -1,43 +0,0 @@ -/*------------------------------------------------------------------------- - * - * port-protos.h-- - * prototypes for Ultrix-specific routines - * - * - * Copyright (c) 1994, Regents of the University of California - * - * $Id: port-protos.h,v 1.8 1997/12/19 22:46:47 scrappy Exp $ - * - *------------------------------------------------------------------------- - */ -#ifndef PORT_PORTOS_H -#define PORT_PORTOS_H - -/* - * Externals in libc that need prototypes (or at least declarations) - */ - -extern char *ecvt(double, int, int *, int *); -extern char *fcvt(double, int, int *, int *); - -/* dynloader.c */ -/* - * New dynamic loader. - * - * This dynamic loader uses Andrew Yu's libdl-1.0 package for Ultrix 4.x. - * (Note that pg_dlsym and pg_dlclose are actually macros defined in - * "port-protos.h".) - */ - -#define pg_dlsym(h, f) ((func_ptr)dl_sym(h, f)) -#define pg_dlclose(h) dl_close(h) -#define pg_dlerror() dl_error() -extern int dl_init(char *); - -/* port.c */ - -extern int syscall(); - -extern void init_address_fixup(void); - -#endif /* PORT_PORTOS_H */ -- cgit v1.2.3