From 53725cc25f4507d33b567cc91fac5728ad47109d Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 7 Sep 2003 11:25:04 +0000 Subject: [PATCH] * Disabled non-libelf stab files. * Added a stab-unix.c file which is a placeholder for future nm|objdump implementations. git-svn-id: svn://svn.zoy.org/elk/trunk@119 55e467fa-43c5-0310-a8a2-de718669efc6 --- src/Makefile.am | 9 +++++- src/stab-elf.c | 6 ++++ src/stab-unix.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ src/stab.c | 10 ++++--- 4 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 src/stab-unix.c diff --git a/src/Makefile.am b/src/Makefile.am index 1c65ce8..bc44ed0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,8 @@ libelk_la_SOURCES = \ read.c \ special.c \ stab.c \ + $(stab_elf_c) \ + $(stab_unix_c) \ stkmem.c \ string.c \ symbol.c \ @@ -41,6 +43,12 @@ libelk_la_SOURCES = \ vector.c \ $(NULL) +if HAVE_LIBELF +stab_elf_c = stab-elf.c +else +stab_unix_c = stab-unix.c +endif + EXTRA_DIST = \ dump-ecoff.c \ dump-elf.c \ @@ -52,7 +60,6 @@ EXTRA_DIST = \ stab-coff.c \ stab-convex.c \ stab-ecoff.c \ - stab-elf.c \ stab-hp9k300.c \ stab-hp9k800.c \ stab-macho.c \ diff --git a/src/stab-elf.c b/src/stab-elf.c index 17b0b0d..e2cc448 100644 --- a/src/stab-elf.c +++ b/src/stab-elf.c @@ -28,11 +28,16 @@ * THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. */ +#include "config.h" + #include #include #include #include #include +#include + +#include "kernel.h" SYMTAB * Snarf_Symbols (lf) @@ -144,3 +149,4 @@ Open_File_And_Snarf_Symbols (name) (void)close (f); return tab; } + diff --git a/src/stab-unix.c b/src/stab-unix.c new file mode 100644 index 0000000..0368218 --- /dev/null +++ b/src/stab-unix.c @@ -0,0 +1,75 @@ +/* stab-unix.c + * + * $Id$ + * + * Copyright 1990, 1991, 1992, 1993, 1994, 1995, Oliver Laumann, Berlin + * Copyright 2002, 2003 Sam Hocevar , Paris + * + * This software was derived from Elk 1.2, which was Copyright 1987, 1988, + * 1989, Nixdorf Computer AG and TELES GmbH, Berlin (Elk 1.2 has been written + * by Oliver Laumann for TELES Telematic Services, Berlin, in a joint project + * between TELES and Nixdorf Microprocessor Engineering, Berlin). + * + * Oliver Laumann, TELES GmbH, Nixdorf Computer AG and Sam Hocevar, as co- + * owners or individual owners of copyright in this software, grant to any + * person or company a worldwide, royalty free, license to + * + * i) copy this software, + * ii) prepare derivative works based on this software, + * iii) distribute copies of this software or derivative works, + * iv) perform this software, or + * v) display this software, + * + * provided that this notice is not removed and that neither Oliver Laumann + * nor Teles nor Nixdorf are deemed to have made any representations as to + * the suitability of this software for any purpose nor are held responsible + * for any defects of this software. + * + * THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +#include "config.h" + +#include +#include +#include +#include + +#include "kernel.h" + +SYMTAB *Snarf_Symbols (FILE *f) { + SYMTAB *tab; + register SYM *sp, **nextp; + + tab = (SYMTAB *)Safe_Malloc (sizeof (SYMTAB)); + tab->first = 0; + tab->strings = 0; + + return tab; +} + +SYMTAB *Open_File_And_Snarf_Symbols (char *name) { + int fd; + FILE *fp; + SYMTAB *tab; + + fprintf (stderr, "trying to find symbols in %s\n", name); + +#ifdef O_BINARY + fd = open (name, O_RDONLY|O_BINARY); +#else + fd = open (name, O_RDONLY); +#endif + if (fd == -1) { + Saved_Errno = errno; + Primitive_Error ("can't open file: ~E"); + } + if ((fp = fdopen (fd, "rb")) == NULL) { + close (fd); + Primitive_Error ("can't fdopen file"); + } + tab = Snarf_Symbols (fp); + (void)fclose (fp); + return tab; +} + diff --git a/src/stab.c b/src/stab.c index 50edc76..df08f19 100644 --- a/src/stab.c +++ b/src/stab.c @@ -39,7 +39,7 @@ void Free_Symbols (SYMTAB *); #if defined(CAN_LOAD_LIB) || defined (INIT_OBJECTS) -#if defined(MACH_O) +/*#if defined(MACH_O) # include "stab-macho.c" #elif defined(HAVE_LIBELF) # include "stab-elf.c" @@ -53,9 +53,11 @@ void Free_Symbols (SYMTAB *); # include "stab-hp9k300.c" #elif defined(hp9000s800) || defined(__hp9000s800) || defined(__hp9000s800__) # include "stab-hp9k800.c" -#else +#elif defined(HAVE_A_OUT_H) # include "stab-bsd.c" -#endif +#else +# include "stab-unix.c" +#endif*/ static SYMPREFIX Ignore_Prefixes[] = { /* Currently none */ @@ -171,4 +173,4 @@ void Free_Symbols (SYMTAB *tab) { free (tab->strings); free ((char *)tab); } -#endif /* CAN_LOAD_OBJ || INIT_OBJECTS */ +#endif /* CAN_LOAD_LIB || INIT_OBJECTS */