From a51c9b66271f0551fb83b90a7db6c464eac2318b Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 17 Sep 2002 01:49:00 +0000 Subject: Initiate deorbit burn for the i386-only a.out related support. Moves are under way to move the remnants of the a.out toolchain to ports. As the comment in src/Makefile said, this stuff is deprecated and one should not expect this to remain beyond 4.0-REL. It has already lasted WAY beyond that. Notable exceptions: gcc - I have not touched the a.out generation stuff there. ldd/ldconfig - still have some code to interface with a.out rtld. old as/ld/etc - I have not removed these yet, pending their move to ports. some includes - necessary for ldd/ldconfig for now. Tested on: i386 (extensively), alpha --- lib/libc/amd64/SYS.h | 6 +--- lib/libc/gen/dlfcn.c | 79 +----------------------------------------- lib/libc/gen/getobjformat.c | 84 +++------------------------------------------ lib/libc/gmon/gmon.c | 2 +- lib/libc/i386/SYS.h | 6 +--- 5 files changed, 8 insertions(+), 169 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 5a636f8..1483f9d 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -58,8 +58,4 @@ /* gas messes up offset -- although we don't currently need it, do for BCS */ #define LCALL(x,y) .byte 0x9a ; .long y; .word x -#ifdef __ELF__ -#define KERNCALL int $0x80 /* Faster */ -#else -#define KERNCALL LCALL(7,0) /* The old way */ -#endif +#define KERNCALL int $0x80 diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index 4a3500d..ff1d900 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -28,12 +28,8 @@ __FBSDID("$FreeBSD$"); /* - * Linkage to services provided by the dynamic linker. These are - * implemented differently in ELF and a.out, because the dynamic - * linkers have different interfaces. + * Linkage to services provided by the dynamic linker. */ -#ifdef __ELF__ - #include #include @@ -107,76 +103,3 @@ dlsym(void * __restrict handle, const char * __restrict name) _rtld_error(sorry); return NULL; } - -#else /* a.out format */ - -#include -#include /* XXX - Required by link.h */ -#include -#include -#include - -/* - * For a.out, entry to the dynamic linker is via these trampolines. - * They enter the dynamic linker through the ld_entry struct that was - * passed back from the dynamic linker at startup time. - */ - -/* GCC is needed because we use its __builtin_return_address construct. */ - -#ifndef __GNUC__ -#error "GCC is needed to compile this file" -#endif - -/* - * These variables are set by code in crt0.o. For compatibility with - * old executables, they must be common, not extern. - */ -struct ld_entry *__ldso_entry; /* Entry points to dynamic linker */ -int __ldso_version; /* Dynamic linker version number */ - -int -dladdr(const void *addr, Dl_info *dlip) -{ - if (__ldso_entry == NULL || __ldso_version < LDSO_VERSION_HAS_DLADDR) - return 0; - return (__ldso_entry->dladdr)(addr, dlip); -} - -int -dlclose(void *handle) -{ - if (__ldso_entry == NULL) - return -1; - return (__ldso_entry->dlclose)(handle); -} - -const char * -dlerror(void) -{ - if (__ldso_entry == NULL) - return "Service unavailable"; - return (__ldso_entry->dlerror)(); -} - -void * -dlopen(const char *name, int mode) -{ - if (__ldso_entry == NULL) - return NULL; - return (__ldso_entry->dlopen)(name, mode); -} - -void * -dlsym(void * __restrict handle, const char * __restrict name) -{ - if (__ldso_entry == NULL) - return NULL; - if (__ldso_version >= LDSO_VERSION_HAS_DLSYM3) { - void *retaddr = __builtin_return_address(0); /* __GNUC__ only */ - return (__ldso_entry->dlsym3)(handle, name, retaddr); - } else - return (__ldso_entry->dlsym)(handle, name); -} - -#endif /* __ELF__ */ diff --git a/lib/libc/gen/getobjformat.c b/lib/libc/gen/getobjformat.c index de5c9c1..7428f36 100644 --- a/lib/libc/gen/getobjformat.c +++ b/lib/libc/gen/getobjformat.c @@ -33,88 +33,12 @@ __FBSDID("$FreeBSD$"); #include #include -#define PATH_OBJFORMAT "/etc/objformat" - -static int copyformat(char *, const char *, size_t); - -static const char *known_formats[] = { OBJFORMAT_NAMES, NULL }; - -static int -copyformat(char *buf, const char *fmt, size_t bufsize) -{ - size_t len; - - len = strlen(fmt); - if (len > bufsize - 1) - return -1; - strcpy(buf, fmt); - return len; -} - int getobjformat(char *buf, size_t bufsize, int *argcp, char **argv) { - const char *fmt; - char **src, **dst; - const char *env; - FILE *fp; - fmt = NULL; - - if (argv != NULL) { - /* - * Scan for arguments setting known formats, e.g., "-elf". - * If "argcp" is non-NULL, delete these arguments from the - * list and update the argument count in "*argcp". - */ - for (dst = src = argv; *src != NULL; src++) { - if ((*src)[0] == '-') { - const char **p; - - for (p = known_formats; *p != NULL; p++) - if (strcmp(*src + 1, *p) == 0) - break; - if (*p != NULL) { - fmt = *p; - if (argcp == NULL) /* Don't delete */ - *dst++ = *src; - } else - *dst++ = *src; - } else - *dst++ = *src; - } - *dst = NULL; - if (argcp != NULL) - *argcp -= src - dst; - if (fmt != NULL) - return copyformat(buf, fmt, bufsize); - } - - /* Check the OBJFORMAT environment variable. */ - if ((env = getenv("OBJFORMAT")) != NULL) - return copyformat(buf, env, bufsize); - - /* Take a look at "/etc/objformat". */ - if ((fp = fopen(PATH_OBJFORMAT, "r")) != NULL) { - char line[1024]; - int found; - int len; - - found = len = 0; - while (fgets(line, sizeof line, fp) != NULL) { - if (strncmp(line, "OBJFORMAT=", 10) == 0) { - char *p = &line[10]; - - p[strcspn(p, " \t\n")] = '\0'; - len = copyformat(buf, p, bufsize); - found = 1; - } - } - fclose(fp); - if (found) - return len; - } - - /* As a last resort, use the compiled in default. */ - return copyformat(buf, OBJFORMAT_DEFAULT, bufsize); + if (bufsize < 4) + return -1; + strcpy(buf, "elf"); + return 3; } diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 34dc936..9530220 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" -#if defined(__ELF__) && (defined(__i386__) || defined(__sparc64__)) +#if defined(__i386__) || defined(__sparc64__) extern char *minbrk asm (".minbrk"); #else extern char *minbrk asm ("minbrk"); diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h index 5a636f8..1483f9d 100644 --- a/lib/libc/i386/SYS.h +++ b/lib/libc/i386/SYS.h @@ -58,8 +58,4 @@ /* gas messes up offset -- although we don't currently need it, do for BCS */ #define LCALL(x,y) .byte 0x9a ; .long y; .word x -#ifdef __ELF__ -#define KERNCALL int $0x80 /* Faster */ -#else -#define KERNCALL LCALL(7,0) /* The old way */ -#endif +#define KERNCALL int $0x80 -- cgit v1.1