aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bfd/.Sanitize65
-rw-r--r--bfd/ChangeLog19
-rw-r--r--bfd/Makefile.in13
-rw-r--r--bfd/aoutx.h6
-rw-r--r--bfd/bfd-in2.h28
-rw-r--r--bfd/configure.in2
-rw-r--r--bfd/elfcode.h8
-rw-r--r--bfd/libelf.h16
-rw-r--r--bfd/libnlm.h101
-rw-r--r--bfd/nlm.c40
-rw-r--r--bfd/nlm32-gen.c35
-rw-r--r--bfd/nlm32-target.h265
-rw-r--r--bfd/nlm32.c22
-rw-r--r--bfd/nlm64-gen.c35
-rw-r--r--bfd/nlm64-target.h265
-rw-r--r--bfd/nlm64.c22
-rw-r--r--bfd/nlmcode.h689
-rw-r--r--bfd/targets.c8
18 files changed, 1579 insertions, 60 deletions
diff --git a/bfd/.Sanitize b/bfd/.Sanitize
index 30056fa..3a8aa23 100644
--- a/bfd/.Sanitize
+++ b/bfd/.Sanitize
@@ -28,21 +28,20 @@ fi
Things-to-keep:
COPYING
-PORTING
-doc
ChangeLog
Makefile.in
+PORTING
README.hppaelf
TODO
VERSION
aix386-core.c
+aout-adobe.c
+aout-encap.c
+aout-target.h
aout32.c
aout64.c
aoutf1.h
aoutx.h
-aout-adobe.c
-aout-encap.c
-aout-target.h
archive.c
archures.c
bfd-in.h
@@ -50,15 +49,14 @@ bfd-in2.h
bfd.c
bout.c
cache.c
-ctor.c
-coff-alpha.c
coff-a29k.c
+coff-alpha.c
coff-h8300.c
coff-h8500.c
coff-i386.c
coff-i960.c
-coff-m68k.c
coff-m68k-un.c
+coff-m68k.c
coff-m88k.c
coff-mips.c
coff-msym.c
@@ -71,10 +69,28 @@ coffgen.c
coffswap.h
config
configure.bat
-configure.in
configure.host
+configure.in
core.c
+cpu-a29k.c
+cpu-alpha.c
+cpu-h8300.c
+cpu-h8500.c
+cpu-hppa.c
+cpu-i386.c
+cpu-i960.c
+cpu-m68k.c
+cpu-m88k.c
+cpu-mips.c
+cpu-rs6000.c
+cpu-sh.c
+cpu-sparc.c
+cpu-vax.c
+cpu-we32k.c
+cpu-z8k.c
+ctor.c
demo64.c
+doc
elf.c
elf32-generic.c
elf32-hppa.c
@@ -96,6 +112,7 @@ format.c
gen-aout.c
host-aout.c
hosts
+hp300bsd.c
hp300hpux.c
hppa.c
hppa_stubs.h
@@ -104,37 +121,29 @@ i386bsd.c
i386linux.c
i386lynx.c
ieee.c
+init.c
libaout.h
libbfd-in.h
-libelf.h
-cpu-alpha.c
-cpu-a29k.c
-cpu-i386.c
-cpu-m68k.c
-cpu-mips.c
-cpu-vax.c
-cpu-h8300.c
-cpu-h8500.c
-cpu-hppa.c
-cpu-i960.c
-cpu-m88k.c
-cpu-rs6000.c
-cpu-sh.c
-cpu-we32k.c
-cpu-z8k.c
-hp300bsd.c
-init.c
-cpu-sparc.c
libbfd.c
libbfd.h
libcoff-in.h
libcoff.h
libecoff.h
+libelf.h
libhppa.h
libieee.h
+libnlm.h
liboasys.h
mipsbsd.c
newsos3.c
+nlm.c
+nlm32-gen.c
+nlm32-target.h
+nlm32.c
+nlm64-gen.c
+nlm64-target.h
+nlm64.c
+nlmcode.h
oasys.c
opncls.c
reloc.c
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 16b1577..526daad 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,22 @@
+Mon Jul 19 20:46:18 1993 Fred Fish (fnf@deneb.cygnus.com)
+
+ * configure.in (*-*-netware, i[34]86-*-netware): New configs.
+ * Makefile.in (BFD32_BACKENDS): Add nlm.o, nlm32.o, nlm32-gen.o.
+ * Makefile.in (BFD64_BACKENDS): Add nlm64.o, nlm64-gen.o.
+ * Makefile.in (CFILES): Add nlm{32,64}.c, nlm{32,64}-gen.c.
+ * Makefile.in (nlm.o, nlm{32,64}.o, nlm{32,64}-gen.o: New targets.
+ * bfd-in2.h (INLINE): Defines moved here.
+ * {aoutx.h, elf.c, elfcode.h}: Move INLINE defines to bfd-in2.h.
+ * libelf.h (CAT4): Move define to bfd-in2.h.
+ * bfd-in2.h (CAT4): Merge CAT4 macro with other CAT macros.
+ * bfd-in2.h (union tdata): Add nlm_obj_data.
+ * bfd-in2.h (enum target_flavour): Add bfd_target_nlm_flavour.
+ * targets.c (bfd_nlm{32,64}_{big,little}_vec): Add prototypes.
+ * targets.c (target_vector): Add bfd_nlm{32,64}_{big,little}_vec.
+ * (libnlm.h, nlm.c, nlmcode.h, nlm{32,64}-gen.c,
+ nlm{32,64}-target.h, nlm{32,64}.c, config/i386-nlm.mt): New files
+ for NLM support.
+
Mon Jul 19 15:09:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
* configure.{hosts,in}: add i[34]86-*-lynxos* support
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 909efd3..ce84913 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -85,6 +85,8 @@ BFD32_BACKENDS = \
elf.o \
elf32.o elf32-sparc.o elf32-i386.o elf32-i860.o elf32-m68k.o \
elf32-hppa.o elf32-mips.o elf32-m88k.o elf32-gen.o \
+ nlm.o \
+ nlm32.o nlm32-gen.o \
aout32.o sunos.o newsos3.o mipsbsd.o aout-adobe.o \
i386aout.o i386bsd.o i386linux.o i386lynx.o \
hp300hpux.o bout.o \
@@ -97,6 +99,7 @@ BFD32_BACKENDS = \
BFD64_BACKENDS = \
elf64.o elf64-gen.o \
+ nlm64.o nlm64-gen.o \
aout64.o demo64.o
OPTIONAL_BACKENDS = trad-core.o
@@ -148,6 +151,7 @@ CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c \
elf32.c elf32-sparc.c elf32-i386.c elf32-i860.c elf32-m68k.c \
elf32-hppa.c elf32-m88k.c elf32-mips.c elf32-gen.c \
elf64.c elf64-gen.c \
+ nlm32.c nlm32-gen.c nlm64.c nlm64-gen.c \
coff-alpha.c cpu-alpha.c \
hp300hpux.c i386lynx.c
@@ -494,6 +498,15 @@ elf64.o : elf64.c elfcode.h libelf.h libbfd.h $(BFD_H) \
$(INCDIR)/obstack.h
elf64-gen.o : elf64-gen.c libelf.h libbfd.h \
$(BFD_H) $(INCDIR)/obstack.h
+nlm.o : nlm.c libnlm.h libbfd.h $(BFD_H) $(INCDIR)/obstack.h
+nlm32.o : nlm32.c nlmcode.h libnlm.h libbfd.h $(BFD_H) \
+ $(INCDIR)/obstack.h
+nlm32-gen.o : nlm32-gen.c libnlm.h libbfd.h \
+ $(BFD_H) $(INCDIR)/obstack.h
+nlm64.o : nlm64.c nlmcode.h libnlm.h libbfd.h $(BFD_H) \
+ $(INCDIR)/obstack.h
+nlm64-gen.o : nlm64-gen.c libnlm.h libbfd.h \
+ $(BFD_H) $(INCDIR)/obstack.h
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 9a44f23..0d6a44c 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1429,12 +1429,6 @@ DEFUN(NAME(aout,slurp_symbol_table),(abfd),
table would be very useful for that, and I don't feel like fleshing out two
completely different implementations. [raeburn:930419.0331EDT] */
-#if __GNUC__ >= 2
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-
struct stringtab_entry {
/* Hash value for this string. Only useful so long as we aren't doing
substring matches. */
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 1599d4d..4afc6df 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -53,6 +53,14 @@ here. */
#define BFD64
#endif
+#ifndef INLINE
+#if __GNUC__ >= 2
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+#endif
+
/* 64-bit type definition (if any) from bfd's sysdep.h goes here */
@@ -311,14 +319,28 @@ typedef struct _symbol_info
the standard routine suffix), or it must #define the routines that
are not so named, before calling JUMP_TABLE in the initializer. */
-/* Semi-portable string concatenation in cpp */
+/* Semi-portable string concatenation in cpp.
+ The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
+ The problem is, "32_" is not a valid preprocessing token, and we don't
+ want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the
+ inner CAT macros to be evaluated first, producing still-valid pp-tokens.
+ Then the final concatenation can be done. (Sigh.) */
#ifndef CAT
+#ifdef SABER
+#define CAT(a,b) a##b
+#define CAT3(a,b,c) a##b##c
+#define CAT4(a,b,c,d) a##b##c##d
+#else
#ifdef __STDC__
#define CAT(a,b) a##b
#define CAT3(a,b,c) a##b##c
+#define XCAT2(a,b) CAT(a,b)
+#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
#else
#define CAT(a,b) a/**/b
#define CAT3(a,b,c) a/**/b/**/c
+#define CAT4(a,b,c,d) a/**/b/**/c/**/d
+#endif
#endif
#endif
@@ -330,7 +352,7 @@ CAT(NAME,_slurp_armap),\
CAT(NAME,_slurp_extended_name_table),\
CAT(NAME,_truncate_arname),\
CAT(NAME,_write_armap),\
-CAT(NAME,_close_and_cleanup), \
+CAT(NAME,_close_and_cleanup),\
CAT(NAME,_set_section_contents),\
CAT(NAME,_get_section_contents),\
CAT(NAME,_new_section_hook),\
@@ -1491,6 +1513,7 @@ struct _bfd
struct srec_data_struct *srec_data;
struct tekhex_data_struct *tekhex_data;
struct elf_obj_tdata *elf_obj_data;
+ struct nlm_obj_tdata *nlm_obj_data;
struct bout_data_struct *bout_data;
struct sun_core_struct *sun_core_data;
struct trad_core_struct *trad_core_data;
@@ -1611,6 +1634,7 @@ typedef struct bfd_target
bfd_target_ecoff_flavour,
bfd_target_elf_flavour,
bfd_target_ieee_flavour,
+ bfd_target_nlm_flavour,
bfd_target_oasys_flavour,
bfd_target_tekhex_flavour,
bfd_target_srec_flavour,
diff --git a/bfd/configure.in b/bfd/configure.in
index 184a724..1cbe4da 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -58,6 +58,7 @@ case "${target}" in
i[34]86-*-coff) bfd_target=i386-coff ;;
i[34]86-*-aix*) bfd_target=i386-coff ;;
i[34]86-*-elf) bfd_target=i386-elf ;;
+ i[34]86-*-netware*) bfd_target=i386-nlm ;;
i[34]86-*-linux*) bfd_target=i386-linux ;;
i[34]86-none-*) bfd_target=i386-coff ;;
i960-*-vxworks) bfd_target=i960-bout ;;
@@ -100,6 +101,7 @@ case "${target}" in
*-*-aout) bfd_target=${target_cpu}-aout ;;
*-*-bsd*) bfd_target=${target_cpu}-aout ;;
+ *-*-netware*) bfd_target=${target_cpu}-nlm ;;
*-*-sysv4*) bfd_target=${target_cpu}-elf ;;
*-*-solaris2*) bfd_target=${target_cpu}-elf ;;
*-*-go32) bfd_target=${target_cpu}-aout ;;
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 908e010..8846624 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -107,14 +107,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define ELFCLASS ELFCLASS32
#endif
-#ifndef INLINE
-#if __GNUC__ >= 2
-#define INLINE __inline__
-#else
-#define INLINE
-#endif
-#endif
-
static int shstrtab_length_fixed;
struct elf_sect_data {
diff --git a/bfd/libelf.h b/bfd/libelf.h
index 9936c23..3ef9d89 100644
--- a/bfd/libelf.h
+++ b/bfd/libelf.h
@@ -25,22 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "elf/internal.h"
#include "elf/external.h"
-/* This CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
- The problem is, "32_" is not a valid preprocessing token, and we don't
- want extra underscores (e.g., "elf_32_"). The XCAT2 macro will cause the
- inner CAT macros to be evaluated first, producing still-valid pp-tokens.
- Then the final concatenation can be done. (Sigh.) */
-#ifdef SABER
-#define CAT4(a,b,c,d) a##b##c##d
-#else
-#ifdef __STDC__
-#define XCAT2(a,b) CAT(a,b)
-#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
-#else
-#define CAT4(a,b,c,d) a/**/b/**/c/**/d
-#endif
-#endif
-
/* If size isn't specified as 64 or 32, NAME macro should fail. */
#ifndef NAME
#if ARCH_SIZE==64
diff --git a/bfd/libnlm.h b/bfd/libnlm.h
new file mode 100644
index 0000000..33824b9
--- /dev/null
+++ b/bfd/libnlm.h
@@ -0,0 +1,101 @@
+/* BFD back-end data structures for NLM (NetWare Loadable Modules) files.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+ Written by Cygnus Support.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef _LIBNLM_H_
+#define _LIBNLM_H_ 1
+
+#include "nlm/common.h"
+#include "nlm/internal.h"
+#include "nlm/external.h"
+
+/* If size isn't specified as 64 or 32, NAME macro should fail. */
+#ifndef NAME
+# if ARCH_SIZE==64
+# define NAME(x,y) CAT4(x,64,_,y)
+# endif
+# if ARCH_SIZE==32
+# define NAME(x,y) CAT4(x,32,_,y)
+# endif
+#endif
+
+#define NlmNAME(X) NAME(Nlm,X)
+#define nlmNAME(X) NAME(nlm,X)
+
+typedef struct
+{
+ asymbol symbol;
+} nlm32_symbol_type;
+
+typedef struct
+{
+ asymbol symbol;
+} nlm64_symbol_type;
+
+#define bfd_nlm32_mkobject bfd_nlm_mkobject
+#define bfd_nlm64_mkobject bfd_nlm_mkobject
+#define nlm_mkobject bfd_nlm_mkobject
+extern boolean bfd_nlm_mkobject PARAMS ((bfd *));
+
+extern void bfd_nlm32_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+extern unsigned int bfd_nlm32_get_symtab_upper_bound PARAMS ((bfd *));
+extern unsigned int bfd_nlm64_get_symtab_upper_bound PARAMS ((bfd *));
+extern unsigned int bfd_nlm32_get_symtab PARAMS ((bfd *, asymbol **));
+extern unsigned int bfd_nlm64_get_symtab PARAMS ((bfd *, asymbol **));
+extern asymbol *bfd_nlm32_make_empty_symbol PARAMS ((bfd *));
+extern asymbol *bfd_nlm64_make_empty_symbol PARAMS ((bfd *));
+extern bfd_target *bfd_nlm32_object_p PARAMS ((bfd *));
+extern bfd_target *bfd_nlm64_object_p PARAMS ((bfd *));
+extern boolean bfd_nlm32_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+extern boolean bfd_nlm64_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+
+/* Some private data is stashed away for future use using the tdata pointer
+ in the bfd structure. */
+
+struct nlm_obj_tdata
+{
+ /* Actual data, but ref like ptr */
+ Nlm_Internal_Fixed_Header nlm_fixed_header[1];
+ Nlm_Internal_Variable_Header nlm_variable_header[1];
+ Nlm_Internal_Version_Header nlm_version_header[1];
+ Nlm_Internal_Copyright_Header nlm_copyright_header[1];
+ Nlm_Internal_Extended_Header nlm_extended_header[1];
+ Nlm_Internal_Custom_Header nlm_custom_header[1];
+};
+
+#define nlm_tdata(bfd) ((bfd) -> tdata.nlm_obj_data)
+#define nlm_fixed_header(bfd) (nlm_tdata(bfd) -> nlm_fixed_header)
+#define nlm_variable_header(bfd) (nlm_tdata(bfd) -> nlm_variable_header)
+#define nlm_version_header(bfd) (nlm_tdata(bfd) -> nlm_version_header)
+#define nlm_copyright_header(bfd) (nlm_tdata(bfd) -> nlm_copyright_header)
+#define nlm_extended_header(bfd) (nlm_tdata(bfd) -> nlm_extended_header)
+#define nlm_custom_header(bfd) (nlm_tdata(bfd) -> nlm_custom_header)
+
+/* The NLM code, data, and uninitialized sections have no names defined
+ in the NLM, but bfd wants to give them names, so use the traditional
+ UNIX names. */
+
+#define NLM_CODE_NAME ".text"
+#define NLM_INITIALIZED_DATA_NAME ".data"
+#define NLM_UNINITIALIZED_DATA_NAME ".bss"
+
+#endif /* _LIBNLM_H_ */
diff --git a/bfd/nlm.c b/bfd/nlm.c
new file mode 100644
index 0000000..c941f72
--- /dev/null
+++ b/bfd/nlm.c
@@ -0,0 +1,40 @@
+/* NLM (NetWare Loadable Module) executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#define ARCH_SIZE 0
+#include "libnlm.h"
+
+boolean
+DEFUN (nlm_mkobject, (abfd), bfd * abfd)
+{
+#if 0 /* nlm_object_p does the nlm_tdata allocation */
+ nlm_tdata (abfd) =
+ (struct nlm_obj_tdata *) bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata));
+ if (nlm_tdata (abfd) == NULL)
+ {
+ bfd_error = no_memory;
+ return (false);
+ }
+#endif
+ /* since everything is done at close time, do we need any initialization? */
+ return (true);
+}
diff --git a/bfd/nlm32-gen.c b/bfd/nlm32-gen.c
new file mode 100644
index 0000000..887621e
--- /dev/null
+++ b/bfd/nlm32-gen.c
@@ -0,0 +1,35 @@
+/* Generic support for 32-bit NLM (NetWare Loadable Module)
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libnlm.h"
+
+/* This does not include any relocations, but should be good enough
+ for GDB to read the file. */
+
+#define TARGET_LITTLE_SYM bfd_nlm32_little_generic_vec
+#define TARGET_LITTLE_NAME "nlm32-little"
+#define TARGET_BIG_SYM bfd_nlm32_big_generic_vec
+#define TARGET_BIG_NAME "nlm32-big"
+#define NLM_ARCH bfd_arch_unknown
+#define bfd_nlm32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+
+#include "nlm32-target.h"
diff --git a/bfd/nlm32-target.h b/bfd/nlm32-target.h
new file mode 100644
index 0000000..a830b8d
--- /dev/null
+++ b/bfd/nlm32-target.h
@@ -0,0 +1,265 @@
+/* Target definitions for 32-bit NLM (NetWare Loadable Module)
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* This structure contains everything that BFD knows about a target.
+ It includes things like its byte order, name, what routines to call
+ to do various operations, etc. Every BFD points to a target structure
+ with its "xvec" member.
+
+ There are two such structures here: one for big-endian machines and
+ one for little-endian machines. */
+
+/* We don't have core files. */
+
+#define bfd_nlm32_core_file_p \
+ ((bfd_target *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define bfd_nlm32_core_file_failing_command \
+ _bfd_dummy_core_file_failing_command
+#define bfd_nlm32_core_file_failing_signal \
+ _bfd_dummy_core_file_failing_signal
+#define bfd_nlm32_core_file_matches_executable_p \
+ _bfd_dummy_core_file_matches_executable_p
+
+/* Archives are generic or unimplemented. */
+
+#define bfd_nlm32_slurp_armap \
+ bfd_slurp_coff_armap
+#define bfd_nlm32_slurp_extended_name_table \
+ _bfd_slurp_extended_name_table
+#define bfd_nlm32_truncate_arname \
+ bfd_dont_truncate_arname
+#define bfd_nlm32_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define bfd_nlm32_generic_stat_arch_elt \
+ bfd_generic_stat_arch_elt
+#define bfd_nlm32_write_armap \
+ coff_write_armap
+
+/* Ordinary section reading and writing */
+#define bfd_nlm32_get_section_contents \
+ bfd_generic_get_section_contents
+#define bfd_nlm32_close_and_cleanup \
+ bfd_generic_close_and_cleanup
+
+#define bfd_nlm32_bfd_debug_info_start \
+ bfd_void
+#define bfd_nlm32_bfd_debug_info_end \
+ bfd_void
+#define bfd_nlm32_bfd_debug_info_accumulate \
+ (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
+#define bfd_nlm32_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define bfd_nlm32_bfd_relax_section \
+ bfd_generic_relax_section
+#define bfd_nlm32_bfd_seclet_link \
+ bfd_generic_seclet_link
+#define bfd_nlm32_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
+#define bfd_nlm32_set_section_contents \
+ bfd_generic_set_section_contents
+#define bfd_nlm32_new_section_hook \
+ _bfd_dummy_new_section_hook
+
+#define bfd_nlm32_get_reloc_upper_bound \
+ ((unsigned int (*) PARAMS ((bfd *, sec_ptr))) bfd_0u)
+
+#define bfd_nlm32_canonicalize_reloc \
+ ((unsigned int (*) PARAMS ((bfd *, sec_ptr, arelent **, asymbol **))) bfd_0u)
+
+#define bfd_nlm32_print_symbol \
+ ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_false)
+
+#define bfd_nlm32_get_lineno \
+ ((alent * (*) PARAMS ((bfd *, asymbol *))) bfd_false)
+
+#define bfd_nlm32_find_nearest_line \
+ ((boolean (*) PARAMS ((bfd *, asection *, asymbol **, bfd_vma, \
+ CONST char **, CONST char **, unsigned int *))) \
+ bfd_false)
+
+#define bfd_nlm32_sizeof_headers \
+ ((int (*) PARAMS ((bfd *, boolean))) bfd_0u)
+
+#define bfd_nlm32_write_object_contents \
+ ((boolean (*) PARAMS ((bfd *))) bfd_false)
+
+#ifdef TARGET_BIG_SYM
+bfd_target TARGET_BIG_SYM =
+{
+ /* name: identify kind of target */
+ TARGET_BIG_NAME,
+
+ /* flavour: general indication about file */
+ bfd_target_nlm_flavour,
+
+ /* byteorder_big_p: data is big endian */
+ true,
+
+ /* header_byteorder_big_p: header is also big endian */
+ true,
+
+ /* object_flags: mask of all file flags */
+ (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
+ DYNAMIC | WP_TEXT),
+
+ /* section_flags: mask of all section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
+ SEC_CODE | SEC_DATA),
+
+ /* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ 0,
+
+ /* ar_pad_char: pad character for filenames within an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and/or os and should be independently tunable */
+ '/',
+
+ /* ar_max_namelen: maximum number of characters in an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and should be independently tunable. This value is
+ a WAG (wild a** guess) */
+ 15,
+
+ /* align_power_min: minimum alignment restriction for any section
+ FIXME: this value may be target machine dependent */
+ 3,
+
+ /* Routines to byte-swap various sized integers from the data sections */
+ _do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16,
+
+ /* Routines to byte-swap various sized integers from the file headers */
+ _do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16,
+
+ /* bfd_check_format: check the format of a file being read */
+ { _bfd_dummy_target, /* unknown format */
+ bfd_nlm32_object_p, /* assembler/linker output (object file) */
+ bfd_generic_archive_p, /* an archive */
+ bfd_nlm32_core_file_p /* a core file */
+ },
+
+ /* bfd_set_format: set the format of a file being written */
+ { bfd_false,
+ bfd_nlm_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ bfd_nlm32_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ /* Initialize a jump table with the standard macro. All names start with
+ "nlm" */
+ JUMP_TABLE(bfd_nlm32),
+
+ /* backend_data: */
+ (PTR) NULL,
+};
+#endif
+
+#ifdef TARGET_LITTLE_SYM
+bfd_target TARGET_LITTLE_SYM =
+{
+ /* name: identify kind of target */
+ TARGET_LITTLE_NAME,
+
+ /* flavour: general indication about file */
+ bfd_target_nlm_flavour,
+
+ /* byteorder_big_p: data is big endian */
+ false, /* Nope -- this one's little endian */
+
+ /* header_byteorder_big_p: header is also big endian */
+ false, /* Nope -- this one's little endian */
+
+ /* object_flags: mask of all file flags */
+ (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
+ DYNAMIC | WP_TEXT),
+
+ /* section_flags: mask of all section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
+ SEC_DATA),
+
+ /* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ 0,
+
+ /* ar_pad_char: pad character for filenames within an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and/or os and should be independently tunable */
+ '/',
+
+ /* ar_max_namelen: maximum number of characters in an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and should be independently tunable. This value is
+ a WAG (wild a** guess) */
+ 15,
+
+ /* align_power_min: minimum alignment restriction for any section
+ FIXME: this value may be target machine dependent */
+ 3,
+
+ /* Routines to byte-swap various sized integers from the data sections */
+ _do_getl64, _do_getl_signed_64, _do_putl64,
+ _do_getl32, _do_getl_signed_32, _do_putl32,
+ _do_getl16, _do_getl_signed_16, _do_putl16,
+
+ /* Routines to byte-swap various sized integers from the file headers */
+ _do_getl64, _do_getl_signed_64, _do_putl64,
+ _do_getl32, _do_getl_signed_32, _do_putl32,
+ _do_getl16, _do_getl_signed_16, _do_putl16,
+
+ /* bfd_check_format: check the format of a file being read */
+ { _bfd_dummy_target, /* unknown format */
+ bfd_nlm32_object_p, /* assembler/linker output (object file) */
+ bfd_generic_archive_p, /* an archive */
+ bfd_nlm32_core_file_p /* a core file */
+ },
+
+ /* bfd_set_format: set the format of a file being written */
+ { bfd_false,
+ bfd_nlm_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ bfd_nlm32_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ /* Initialize a jump table with the standard macro. All names start with
+ "nlm" */
+ JUMP_TABLE(bfd_nlm32),
+
+ /* backend_data: */
+ (PTR) NULL,
+};
+#endif
diff --git a/bfd/nlm32.c b/bfd/nlm32.c
new file mode 100644
index 0000000..e2f0b00
--- /dev/null
+++ b/bfd/nlm32.c
@@ -0,0 +1,22 @@
+/* NLM (NetWare Loadable Module) 32-bit executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define ARCH_SIZE 32
+
+#include "nlmcode.h"
diff --git a/bfd/nlm64-gen.c b/bfd/nlm64-gen.c
new file mode 100644
index 0000000..ff5464e
--- /dev/null
+++ b/bfd/nlm64-gen.c
@@ -0,0 +1,35 @@
+/* Generic support for 64-bit NLM (NetWare Loadable Module)
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libnlm.h"
+
+/* This does not include any relocations, but should be good enough
+ for GDB to read the file. */
+
+#define TARGET_LITTLE_SYM bfd_nlm64_little_generic_vec
+#define TARGET_LITTLE_NAME "nlm64-little"
+#define TARGET_BIG_SYM bfd_nlm64_big_generic_vec
+#define TARGET_BIG_NAME "nlm64-big"
+#define NLM_ARCH bfd_arch_unknown
+#define bfd_nlm64_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
+
+#include "nlm64-target.h"
diff --git a/bfd/nlm64-target.h b/bfd/nlm64-target.h
new file mode 100644
index 0000000..b836a0f
--- /dev/null
+++ b/bfd/nlm64-target.h
@@ -0,0 +1,265 @@
+/* Target definitions for 64-bit NLM (NetWare Loadable Module)
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* This structure contains everything that BFD knows about a target.
+ It includes things like its byte order, name, what routines to call
+ to do various operations, etc. Every BFD points to a target structure
+ with its "xvec" member.
+
+ There are two such structures here: one for big-endian machines and
+ one for little-endian machines. */
+
+/* We don't have core files. */
+
+#define bfd_nlm64_core_file_p \
+ ((bfd_target *(*) PARAMS ((bfd *))) bfd_nullvoidptr)
+#define bfd_nlm64_core_file_failing_command \
+ _bfd_dummy_core_file_failing_command
+#define bfd_nlm64_core_file_failing_signal \
+ _bfd_dummy_core_file_failing_signal
+#define bfd_nlm64_core_file_matches_executable_p \
+ _bfd_dummy_core_file_matches_executable_p
+
+/* Archives are generic or unimplemented. */
+
+#define bfd_nlm64_slurp_armap \
+ bfd_slurp_coff_armap
+#define bfd_nlm64_slurp_extended_name_table \
+ _bfd_slurp_extended_name_table
+#define bfd_nlm64_truncate_arname \
+ bfd_dont_truncate_arname
+#define bfd_nlm64_openr_next_archived_file \
+ bfd_generic_openr_next_archived_file
+#define bfd_nlm64_generic_stat_arch_elt \
+ bfd_generic_stat_arch_elt
+#define bfd_nlm64_write_armap \
+ coff_write_armap
+
+/* Ordinary section reading and writing */
+#define bfd_nlm64_get_section_contents \
+ bfd_generic_get_section_contents
+#define bfd_nlm64_close_and_cleanup \
+ bfd_generic_close_and_cleanup
+
+#define bfd_nlm64_bfd_debug_info_start \
+ bfd_void
+#define bfd_nlm64_bfd_debug_info_end \
+ bfd_void
+#define bfd_nlm64_bfd_debug_info_accumulate \
+ (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
+#define bfd_nlm64_bfd_get_relocated_section_contents \
+ bfd_generic_get_relocated_section_contents
+#define bfd_nlm64_bfd_relax_section \
+ bfd_generic_relax_section
+#define bfd_nlm64_bfd_seclet_link \
+ bfd_generic_seclet_link
+#define bfd_nlm64_bfd_make_debug_symbol \
+ ((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
+
+#define bfd_nlm64_set_section_contents \
+ bfd_generic_set_section_contents
+#define bfd_nlm64_new_section_hook \
+ _bfd_dummy_new_section_hook
+
+#define bfd_nlm64_get_reloc_upper_bound \
+ ((unsigned int (*) PARAMS ((bfd *, sec_ptr))) bfd_0u)
+
+#define bfd_nlm64_canonicalize_reloc \
+ ((unsigned int (*) PARAMS ((bfd *, sec_ptr, arelent **, asymbol **))) bfd_0u)
+
+#define bfd_nlm64_print_symbol \
+ ((void (*) PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type))) bfd_false)
+
+#define bfd_nlm64_get_lineno \
+ ((alent * (*) PARAMS ((bfd *, asymbol *))) bfd_false)
+
+#define bfd_nlm64_find_nearest_line \
+ ((boolean (*) PARAMS ((bfd *, asection *, asymbol **, bfd_vma, \
+ CONST char **, CONST char **, unsigned int *))) \
+ bfd_false)
+
+#define bfd_nlm64_sizeof_headers \
+ ((int (*) PARAMS ((bfd *, boolean))) bfd_0u)
+
+#define bfd_nlm64_write_object_contents \
+ ((boolean (*) PARAMS ((bfd *))) bfd_false)
+
+#ifdef TARGET_BIG_SYM
+bfd_target TARGET_BIG_SYM =
+{
+ /* name: identify kind of target */
+ TARGET_BIG_NAME,
+
+ /* flavour: general indication about file */
+ bfd_target_nlm_flavour,
+
+ /* byteorder_big_p: data is big endian */
+ true,
+
+ /* header_byteorder_big_p: header is also big endian */
+ true,
+
+ /* object_flags: mask of all file flags */
+ (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
+ DYNAMIC | WP_TEXT),
+
+ /* section_flags: mask of all section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
+ SEC_CODE | SEC_DATA),
+
+ /* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ 0,
+
+ /* ar_pad_char: pad character for filenames within an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and/or os and should be independently tunable */
+ '/',
+
+ /* ar_max_namelen: maximum number of characters in an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and should be independently tunable. This value is
+ a WAG (wild a** guess) */
+ 15,
+
+ /* align_power_min: minimum alignment restriction for any section
+ FIXME: this value may be target machine dependent */
+ 3,
+
+ /* Routines to byte-swap various sized integers from the data sections */
+ _do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16,
+
+ /* Routines to byte-swap various sized integers from the file headers */
+ _do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16,
+
+ /* bfd_check_format: check the format of a file being read */
+ { _bfd_dummy_target, /* unknown format */
+ bfd_nlm64_object_p, /* assembler/linker output (object file) */
+ bfd_generic_archive_p, /* an archive */
+ bfd_nlm64_core_file_p /* a core file */
+ },
+
+ /* bfd_set_format: set the format of a file being written */
+ { bfd_false,
+ bfd_nlm_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ bfd_nlm64_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ /* Initialize a jump table with the standard macro. All names start with
+ "nlm" */
+ JUMP_TABLE(bfd_nlm64),
+
+ /* backend_data: */
+ (PTR) NULL,
+};
+#endif
+
+#ifdef TARGET_LITTLE_SYM
+bfd_target TARGET_LITTLE_SYM =
+{
+ /* name: identify kind of target */
+ TARGET_LITTLE_NAME,
+
+ /* flavour: general indication about file */
+ bfd_target_nlm_flavour,
+
+ /* byteorder_big_p: data is big endian */
+ false, /* Nope -- this one's little endian */
+
+ /* header_byteorder_big_p: header is also big endian */
+ false, /* Nope -- this one's little endian */
+
+ /* object_flags: mask of all file flags */
+ (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS |
+ DYNAMIC | WP_TEXT),
+
+ /* section_flags: mask of all section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
+ SEC_DATA),
+
+ /* leading_symbol_char: is the first char of a user symbol
+ predictable, and if so what is it */
+ 0,
+
+ /* ar_pad_char: pad character for filenames within an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and/or os and should be independently tunable */
+ '/',
+
+ /* ar_max_namelen: maximum number of characters in an archive header
+ FIXME: this really has nothing to do with NLM, this is a characteristic
+ of the archiver and should be independently tunable. This value is
+ a WAG (wild a** guess) */
+ 15,
+
+ /* align_power_min: minimum alignment restriction for any section
+ FIXME: this value may be target machine dependent */
+ 3,
+
+ /* Routines to byte-swap various sized integers from the data sections */
+ _do_getl64, _do_getl_signed_64, _do_putl64,
+ _do_getl32, _do_getl_signed_32, _do_putl32,
+ _do_getl16, _do_getl_signed_16, _do_putl16,
+
+ /* Routines to byte-swap various sized integers from the file headers */
+ _do_getl64, _do_getl_signed_64, _do_putl64,
+ _do_getl32, _do_getl_signed_32, _do_putl32,
+ _do_getl16, _do_getl_signed_16, _do_putl16,
+
+ /* bfd_check_format: check the format of a file being read */
+ { _bfd_dummy_target, /* unknown format */
+ bfd_nlm64_object_p, /* assembler/linker output (object file) */
+ bfd_generic_archive_p, /* an archive */
+ bfd_nlm64_core_file_p /* a core file */
+ },
+
+ /* bfd_set_format: set the format of a file being written */
+ { bfd_false,
+ bfd_nlm_mkobject,
+ _bfd_generic_mkarchive,
+ bfd_false
+ },
+
+ /* bfd_write_contents: write cached information into a file being written */
+ { bfd_false,
+ bfd_nlm64_write_object_contents,
+ _bfd_write_archive_contents,
+ bfd_false
+ },
+
+ /* Initialize a jump table with the standard macro. All names start with
+ "nlm" */
+ JUMP_TABLE(bfd_nlm64),
+
+ /* backend_data: */
+ (PTR) NULL,
+};
+#endif
diff --git a/bfd/nlm64.c b/bfd/nlm64.c
new file mode 100644
index 0000000..fc5cc02
--- /dev/null
+++ b/bfd/nlm64.c
@@ -0,0 +1,22 @@
+/* NLM (NetWare Loadable Module) 64-bit executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#define ARCH_SIZE 64
+
+#include "nlmcode.h"
diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h
new file mode 100644
index 0000000..127eb94
--- /dev/null
+++ b/bfd/nlmcode.h
@@ -0,0 +1,689 @@
+/* NLM (NetWare Loadable Module) executable support for BFD.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+ Written by Fred Fish @ Cygnus Support, using ELF support as the
+ template.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <string.h> /* For strrchr and friends */
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libnlm.h"
+
+#define Nlm_External_Fixed_Header NAME(Nlm,External_Fixed_Header)
+#define Nlm_External_Version_Header NAME(Nlm,External_Version_Header)
+#define Nlm_External_Copyright_Header NAME(Nlm,External_Copyright_Header)
+#define Nlm_External_Extended_Header NAME(Nlm,External_Extended_Header)
+#define Nlm_External_Custom_Header NAME(Nlm,External_Custom_Header)
+
+#define nlm_symbol_type NAME(nlm,symbol_type)
+
+#define nlm_get_symtab_upper_bound NAME(bfd_nlm,get_symtab_upper_bound)
+#define nlm_get_symtab NAME(bfd_nlm,get_symtab)
+#define nlm_make_empty_symbol NAME(bfd_nlm,make_empty_symbol)
+#define nlm_print_symbol NAME(bfd_nlm,print_symbol)
+#define nlm_get_symbol_info NAME(bfd_nlm,get_symbol_info)
+#define nlm_set_arch_mach NAME(bfd_nlm,set_arch_mach)
+#define nlm_object_p NAME(bfd_nlm,object_p)
+
+#define MSB (~(~(unsigned long)0 >> 1))
+
+/* Forward declarations of static functions */
+
+static boolean add_bfd_section
+ PARAMS ((bfd *, char *, file_ptr, bfd_size_type, flagword));
+
+static void nlm_swap_fixed_header_in
+ PARAMS ((bfd *, Nlm_External_Fixed_Header *, Nlm_Internal_Fixed_Header *));
+
+static boolean nlm_swap_variable_header_in PARAMS ((bfd *));
+
+static boolean nlm_swap_auxiliary_headers_in PARAMS ((bfd *));
+
+static struct sec *section_from_nlm_index PARAMS ((bfd *, int));
+
+static int nlm_section_from_bfd_section PARAMS ((bfd *, struct sec *));
+
+static boolean nlm_slurp_symbol_table PARAMS ((bfd *, asymbol **));
+
+static int nlm_symbol_from_bfd_symbol
+ PARAMS ((bfd *, struct symbol_cache_entry **));
+
+static void nlm_map_symbols PARAMS ((bfd *));
+
+/* Should perhaps use put_offset, put_word, etc. For now, the two versions
+ can be handled by explicitly specifying 32 bits or "the long type". */
+#if ARCH_SIZE == 64
+#define put_word bfd_h_put_64
+#define get_word bfd_h_get_64
+#endif
+#if ARCH_SIZE == 32
+#define put_word bfd_h_put_32
+#define get_word bfd_h_get_32
+#endif
+
+bfd_target *
+DEFUN (nlm_object_p, (abfd), bfd * abfd)
+{
+ Nlm_External_Fixed_Header x_fxdhdr; /* Nlm file header, external form */
+ Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
+ int shindex;
+
+ /* Read in the fixed length portion of the NLM header in external format. */
+
+ if (bfd_read ((PTR) &x_fxdhdr, sizeof (x_fxdhdr), 1, abfd) !=
+ sizeof (x_fxdhdr))
+ {
+ bfd_error = system_call_error;
+ return (NULL);
+ }
+
+ /* Check to see if we have an NLM file by matching the NLM signature. */
+
+ if (strncmp (&x_fxdhdr.signature, NLM_SIGNATURE, NLM_SIGNATURE_SIZE) != 0)
+ {
+ wrong:
+ bfd_error = wrong_format;
+ return (NULL);
+ }
+
+ /* There's no supported way to discover the endianess of an NLM, so test for
+ a sane version number after doing byte swapping appropriate for this
+ XVEC. (Hack alert!) */
+
+ if (get_word (abfd, (bfd_byte *) &x_fxdhdr.version) > 0xFFFF)
+ {
+ goto wrong;
+ }
+
+ /* There's no supported way to check for 32 bit versus 64 bit addresses,
+ so ignore this distinction for now. (FIXME) */
+
+ /* Allocate an instance of the nlm_obj_tdata structure and hook it up to
+ the tdata pointer in the bfd. */
+
+ nlm_tdata (abfd) = (struct nlm_obj_tdata *)
+ bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata));
+ if (nlm_tdata (abfd) == NULL)
+ {
+ bfd_error = no_memory;
+ return (NULL);
+ }
+
+ /* FIXME: Any `wrong' exits below here will leak memory (tdata). */
+
+ /* Swap in the rest of the fixed length header. */
+
+ i_fxdhdrp = nlm_fixed_header (abfd);
+ nlm_swap_fixed_header_in (abfd, &x_fxdhdr, i_fxdhdrp);
+
+ if (!nlm_swap_variable_header_in (abfd)
+ || !nlm_swap_auxiliary_headers_in (abfd)
+ || !add_bfd_section (abfd, NLM_CODE_NAME,
+ i_fxdhdrp -> codeImageOffset,
+ i_fxdhdrp -> codeImageSize,
+ SEC_CODE | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)
+ || !add_bfd_section (abfd, NLM_INITIALIZED_DATA_NAME,
+ i_fxdhdrp -> dataImageOffset,
+ i_fxdhdrp -> dataImageSize,
+ SEC_DATA | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)
+ || !add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME,
+ (file_ptr) 0,
+ i_fxdhdrp -> uninitializedDataSize,
+ SEC_DATA | SEC_ALLOC))
+ {
+ return (NULL);
+ }
+
+ return (abfd -> xvec);
+}
+
+/* Add a section to the bfd. */
+
+static boolean
+DEFUN (add_bfd_section, (abfd, name, offset, size, flags),
+ bfd *abfd AND
+ char *name AND
+ file_ptr offset AND
+ bfd_size_type size AND
+ flagword flags)
+{
+ asection *newsect;
+
+ newsect = bfd_make_section (abfd, name);
+ if (newsect == NULL)
+ {
+ return (false);
+ }
+ newsect -> vma = 0; /* NLM's are relocatable. */
+ newsect -> _raw_size = size;
+ newsect -> filepos = offset;
+ newsect -> flags = flags;
+ newsect -> alignment_power = bfd_log2 (0); /* FIXME */
+ return (true);
+}
+
+
+/* Translate an NLM fixed length file header in external format into an NLM
+ file header in internal format. */
+
+static void
+DEFUN (nlm_swap_fixed_header_in, (abfd, src, dst),
+ bfd * abfd AND
+ Nlm_External_Fixed_Header * src AND
+ Nlm_Internal_Fixed_Header * dst)
+{
+ memcpy (dst -> signature, src -> signature, NLM_SIGNATURE_SIZE);
+ memcpy (dst -> moduleName, src -> moduleName, NLM_MODULE_NAME_SIZE);
+ dst -> version =
+ get_word (abfd, (bfd_byte *) src -> version);
+ dst -> codeImageOffset =
+ get_word (abfd, (bfd_byte *) src -> codeImageOffset);
+ dst -> codeImageSize =
+ get_word (abfd, (bfd_byte *) src -> codeImageSize);
+ dst -> dataImageOffset =
+ get_word (abfd, (bfd_byte *) src -> dataImageOffset);
+ dst -> dataImageSize =
+ get_word (abfd, (bfd_byte *) src -> dataImageSize);
+ dst -> uninitializedDataSize =
+ get_word (abfd, (bfd_byte *) src -> uninitializedDataSize);
+ dst -> customDataOffset =
+ get_word (abfd, (bfd_byte *) src -> customDataOffset);
+ dst -> customDataSize =
+ get_word (abfd, (bfd_byte *) src -> customDataSize);
+ dst -> moduleDependencyOffset =
+ get_word (abfd, (bfd_byte *) src -> moduleDependencyOffset);
+ dst -> numberOfModuleDependencies =
+ get_word (abfd, (bfd_byte *) src -> numberOfModuleDependencies);
+ dst -> relocationFixupOffset =
+ get_word (abfd, (bfd_byte *) src -> relocationFixupOffset);
+ dst -> numberOfRelocationFixups =
+ get_word (abfd, (bfd_byte *) src -> numberOfRelocationFixups);
+ dst -> externalReferencesOffset =
+ get_word (abfd, (bfd_byte *) src -> externalReferencesOffset);
+ dst -> numberOfExternalReferences =
+ get_word (abfd, (bfd_byte *) src -> numberOfExternalReferences);
+ dst -> publicsOffset =
+ get_word (abfd, (bfd_byte *) src -> publicsOffset);
+ dst -> numberOfPublics =
+ get_word (abfd, (bfd_byte *) src -> numberOfPublics);
+ dst -> debugInfoOffset =
+ get_word (abfd, (bfd_byte *) src -> debugInfoOffset);
+ dst -> numberOfDebugRecords =
+ get_word (abfd, (bfd_byte *) src -> numberOfDebugRecords);
+ dst -> codeStartOffset =
+ get_word (abfd, (bfd_byte *) src -> codeStartOffset);
+ dst -> exitProcedureOffset =
+ get_word (abfd, (bfd_byte *) src -> exitProcedureOffset);
+ dst -> checkUnloadProcedureOffset =
+ get_word (abfd, (bfd_byte *) src -> checkUnloadProcedureOffset);
+ dst -> moduleType =
+ get_word (abfd, (bfd_byte *) src -> moduleType);
+ dst -> flags =
+ get_word (abfd, (bfd_byte *) src -> flags);
+}
+
+/* Read and swap in the variable length header. All the fields must
+ exist in the NLM, and must exist in the order they are read here. */
+
+static boolean
+DEFUN (nlm_swap_variable_header_in, (abfd),
+ bfd * abfd)
+{
+ unsigned char temp [TARGET_LONG_SIZE];
+
+ /* Read the description length and text members. */
+
+ if (bfd_read ((PTR) &nlm_variable_header (abfd) -> descriptionLength,
+ sizeof (nlm_variable_header (abfd) -> descriptionLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd) -> descriptionLength))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ if (bfd_read ((PTR) nlm_variable_header (abfd) -> descriptionText,
+ nlm_variable_header (abfd) -> descriptionLength + 1,
+ 1, abfd) !=
+ nlm_variable_header (abfd) -> descriptionLength + 1)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+
+ /* Read and convert the stackSize field. */
+
+ if (bfd_read ((PTR) &temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ nlm_variable_header (abfd) -> stackSize = get_word (abfd, (bfd_byte *) temp);
+
+ /* Read and convert the reserved field. */
+
+ if (bfd_read ((PTR) &temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ nlm_variable_header (abfd) -> reserved = get_word (abfd, (bfd_byte *) temp);
+
+ /* Read the oldThreadName field. This field is a fixed length string. */
+
+ if (bfd_read ((PTR) nlm_variable_header (abfd) -> oldThreadName,
+ sizeof (nlm_variable_header (abfd) -> oldThreadName),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd) -> oldThreadName))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+
+ /* Read the screen name length and text members. */
+
+ if (bfd_read ((PTR) &nlm_variable_header (abfd) -> screenNameLength,
+ sizeof (nlm_variable_header (abfd) -> screenNameLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd) -> screenNameLength))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ if (bfd_read ((PTR) nlm_variable_header (abfd) -> screenName,
+ nlm_variable_header (abfd) -> screenNameLength + 1,
+ 1, abfd) !=
+ nlm_variable_header (abfd) -> screenNameLength + 1)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+
+ /* Read the thread name length and text members. */
+
+ if (bfd_read ((PTR) &nlm_variable_header (abfd) -> threadNameLength,
+ sizeof (nlm_variable_header (abfd) -> threadNameLength),
+ 1, abfd) !=
+ sizeof (nlm_variable_header (abfd) -> threadNameLength))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ if (bfd_read ((PTR) nlm_variable_header (abfd) -> threadName,
+ nlm_variable_header (abfd) -> threadNameLength + 1,
+ 1, abfd) !=
+ nlm_variable_header (abfd) -> threadNameLength + 1)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ return (true);
+}
+
+/* Read and swap in the contents of all the auxiliary headers. Because of
+ the braindead design, we have to do strcmps on strings of indeterminate
+ length to figure out what each auxiliary header is. Even worse, we have
+ no way of knowing how many auxiliary headers there are or where the end
+ of the auxiliary headers are, except by finding something that doesn't
+ look like a known auxiliary header. This means that the first new type
+ of auxiliary header added will break all existing tools that don't
+ recognize it. */
+
+static boolean
+DEFUN (nlm_swap_auxiliary_headers_in, (abfd),
+ bfd * abfd)
+{
+ unsigned char temp [TARGET_LONG_SIZE];
+ unsigned char tempstr [16];
+ long position;
+
+ for (;;)
+ {
+ position = bfd_tell (abfd);
+ if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=
+ sizeof (tempstr))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ if (bfd_seek (abfd, position, SEEK_SET) == -1)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ if (strncmp (tempstr, "VeRsIoN#", 8) == 0)
+ {
+ Nlm_External_Version_Header thdr;
+ if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ memcpy (nlm_version_header (abfd) -> stamp, thdr.stamp,
+ sizeof (thdr.stamp));
+ nlm_version_header (abfd) -> majorVersion =
+ get_word (abfd, (bfd_byte *) thdr.majorVersion);
+ nlm_version_header (abfd) -> minorVersion =
+ get_word (abfd, (bfd_byte *) thdr.minorVersion);
+ nlm_version_header (abfd) -> revision =
+ get_word (abfd, (bfd_byte *) thdr.revision);
+ nlm_version_header (abfd) -> year =
+ get_word (abfd, (bfd_byte *) thdr.year);
+ nlm_version_header (abfd) -> month =
+ get_word (abfd, (bfd_byte *) thdr.month);
+ nlm_version_header (abfd) -> day =
+ get_word (abfd, (bfd_byte *) thdr.day);
+ }
+ else if (strncmp (tempstr, "MeSsAgEs", 8) == 0)
+ {
+ Nlm_External_Extended_Header thdr;
+ if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ memcpy (nlm_extended_header (abfd) -> stamp, thdr.stamp,
+ sizeof (thdr.stamp));
+ nlm_extended_header (abfd) -> languageID =
+ get_word (abfd, (bfd_byte *) thdr.languageID);
+ nlm_extended_header (abfd) -> messageFileOffset =
+ get_word (abfd, (bfd_byte *) thdr.messageFileOffset);
+ nlm_extended_header (abfd) -> messageFileLength =
+ get_word (abfd, (bfd_byte *) thdr.messageFileLength);
+ nlm_extended_header (abfd) -> messageCount =
+ get_word (abfd, (bfd_byte *) thdr.messageCount);
+ nlm_extended_header (abfd) -> helpFileOffset =
+ get_word (abfd, (bfd_byte *) thdr.helpFileOffset);
+ nlm_extended_header (abfd) -> helpFileLength =
+ get_word (abfd, (bfd_byte *) thdr.helpFileLength);
+ nlm_extended_header (abfd) -> RPCDataOffset =
+ get_word (abfd, (bfd_byte *) thdr.RPCDataOffset);
+ nlm_extended_header (abfd) -> RPCDataLength =
+ get_word (abfd, (bfd_byte *) thdr.RPCDataLength);
+ nlm_extended_header (abfd) -> sharedCodeOffset =
+ get_word (abfd, (bfd_byte *) thdr.sharedCodeOffset);
+ nlm_extended_header (abfd) -> sharedCodeLength =
+ get_word (abfd, (bfd_byte *) thdr.sharedCodeLength);
+ nlm_extended_header (abfd) -> sharedDataOffset =
+ get_word (abfd, (bfd_byte *) thdr.sharedDataOffset);
+ nlm_extended_header (abfd) -> sharedDataLength =
+ get_word (abfd, (bfd_byte *) thdr.sharedDataLength);
+ nlm_extended_header (abfd) -> sharedRelocationFixupOffset =
+ get_word (abfd, (bfd_byte *) thdr.sharedRelocationFixupOffset);
+ nlm_extended_header (abfd) -> sharedRelocationFixupCount =
+ get_word (abfd, (bfd_byte *) thdr.sharedRelocationFixupCount);
+ nlm_extended_header (abfd) -> sharedExternalReferenceOffset =
+ get_word (abfd, (bfd_byte *) thdr.sharedExternalReferenceOffset);
+ nlm_extended_header (abfd) -> sharedExternalReferenceCount =
+ get_word (abfd, (bfd_byte *) thdr.sharedExternalReferenceCount);
+ nlm_extended_header (abfd) -> sharedPublicsOffset =
+ get_word (abfd, (bfd_byte *) thdr.sharedPublicsOffset);
+ nlm_extended_header (abfd) -> sharedPublicsCount =
+ get_word (abfd, (bfd_byte *) thdr.sharedPublicsCount);
+ nlm_extended_header (abfd) -> SharedInitializationOffset =
+ get_word (abfd, (bfd_byte *) thdr.sharedInitializationOffset);
+ nlm_extended_header (abfd) -> SharedExitProcedureOffset =
+ get_word (abfd, (bfd_byte *) thdr.SharedExitProcedureOffset);
+ nlm_extended_header (abfd) -> productID =
+ get_word (abfd, (bfd_byte *) thdr.productID);
+ nlm_extended_header (abfd) -> reserved0 =
+ get_word (abfd, (bfd_byte *) thdr.reserved0);
+ nlm_extended_header (abfd) -> reserved1 =
+ get_word (abfd, (bfd_byte *) thdr.reserved1);
+ nlm_extended_header (abfd) -> reserved2 =
+ get_word (abfd, (bfd_byte *) thdr.reserved2);
+ nlm_extended_header (abfd) -> reserved3 =
+ get_word (abfd, (bfd_byte *) thdr.reserved3);
+ nlm_extended_header (abfd) -> reserved4 =
+ get_word (abfd, (bfd_byte *) thdr.reserved4);
+ nlm_extended_header (abfd) -> reserved5 =
+ get_word (abfd, (bfd_byte *) thdr.reserved5);
+ }
+ else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
+ {
+ Nlm_External_Custom_Header thdr;
+ if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ memcpy (nlm_custom_header (abfd) -> stamp, thdr.stamp,
+ sizeof (thdr.stamp));
+ nlm_custom_header (abfd) -> dataLength =
+ get_word (abfd, (bfd_byte *) thdr.dataLength);
+ nlm_custom_header (abfd) -> debugRecOffset =
+ get_word (abfd, (bfd_byte *) thdr.debugRecOffset);
+ nlm_custom_header (abfd) -> debugRecLength =
+ get_word (abfd, (bfd_byte *) thdr.debugRecLength);
+ }
+ else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0)
+ {
+ Nlm_External_Copyright_Header thdr;
+ if (bfd_read ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ memcpy (nlm_copyright_header (abfd) -> stamp, thdr.stamp,
+ sizeof (thdr.stamp));
+ nlm_copyright_header (abfd) -> copyrightMessageLength =
+ get_word (abfd, (bfd_byte *) thdr.copyrightMessageLength);
+ /* The copyright message is a variable length string. */
+ if (bfd_read ((PTR) nlm_copyright_header (abfd) -> copyrightMessage,
+ nlm_copyright_header (abfd) -> copyrightMessageLength + 1,
+ 1, abfd) !=
+ nlm_copyright_header (abfd) -> copyrightMessageLength + 1)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+}
+
+/* We read the NLM's public symbols and use it to generate a bfd symbol
+ table (hey, it's better than nothing) on a one-for-one basis. Thus
+ use the number of public symbols as the number of bfd symbols we will
+ have once we actually get around to reading them in.
+
+ Return the number of bytes required to hold the symtab vector, based on
+ the count plus 1, since we will NULL terminate the vector allocated based
+ on this size. */
+
+unsigned int
+DEFUN (nlm_get_symtab_upper_bound, (abfd), bfd * abfd)
+{
+ Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
+ unsigned int symcount;
+ unsigned int symtab_size = 0;
+
+ i_fxdhdrp = nlm_fixed_header (abfd);
+ symcount = i_fxdhdrp -> numberOfPublics;
+ symtab_size = (symcount + 1) * (sizeof (asymbol));
+ return (symtab_size);
+}
+
+/* Note that bfd_get_symcount is guaranteed to be zero if slurping the
+ symbol table fails. */
+
+unsigned int
+DEFUN (nlm_get_symtab, (abfd, alocation),
+ bfd *abfd AND
+ asymbol **alocation)
+{
+ nlm_slurp_symbol_table (abfd, alocation);
+ return (bfd_get_symcount (abfd));
+}
+
+asymbol *
+DEFUN (nlm_make_empty_symbol, (abfd), /* FIXME! */
+ bfd * abfd)
+{
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ new -> the_bfd = abfd;
+ return new;
+}
+
+void
+DEFUN (nlm_get_symbol_info, (ignore_abfd, symbol, ret),
+ bfd * ignore_abfd AND
+ asymbol * symbol AND
+ symbol_info * ret)
+{
+ bfd_symbol_info (symbol, ret);
+}
+
+boolean
+DEFUN (nlm_set_arch_mach, (abfd, arch, machine),
+ bfd * abfd AND
+ enum bfd_architecture arch AND
+ unsigned long machine)
+{
+ return false;
+}
+
+/* Slurp in nlm symbol table.
+
+ In the external (in-file) form, NLM export records are variable length,
+ with the following form:
+
+ 1 byte length of the symbol name (N)
+ N bytes the symbol name
+ 4 bytes the symbol offset from start of it's section
+
+ Note that we currently ignore the internal debug records. There is
+ a lot of duplication between the export records and the internal debug
+ records. We may in the future, want to merge the information from the
+ debug records with the information from the export records to produce
+ a more complete symbol table, treating additional information from the
+ debug records as static symbols. (FIXME)
+
+ If SYMPTRS is non-NULL, the bfd symbols are copied to where it points.
+
+ When we return, the bfd symcount is either zero or contains the correct
+ number of symbols.
+*/
+
+static boolean
+DEFUN (nlm_slurp_symbol_table, (abfd, symptrs),
+ bfd *abfd AND
+ asymbol **symptrs) /* Buffer for generated bfd symbols */
+{
+ Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form */
+ int symcount; /* Number of external NLM symbols */
+ int idx;
+ nlm_symbol_type *sym; /* Pointer to current bfd symbol */
+ nlm_symbol_type *symbase; /* Buffer for generated bfd symbols */
+ char symlength; /* Symbol length read into here */
+ long symoffset; /* Symbol offset read into here */
+
+ if (bfd_get_outsymbols (abfd) != NULL)
+ {
+ return (true);
+ }
+
+ /* Read each raw NLM symbol, using the information to create a canonical bfd
+ symbol table entry.
+
+ Note that we allocate the initial bfd canonical symbol buffer based on a
+ one-to-one mapping of the NLM symbols to canonical symbols. We actually
+ use all the NLM symbols, so there will be no space left over at the end.
+ When we have all the symbols, we build the caller's pointer vector. */
+
+ abfd -> symcount = 0;
+ i_fxdhdrp = nlm_fixed_header (abfd);
+ symcount = i_fxdhdrp -> numberOfPublics;
+ if (symcount == 0)
+ {
+ return (true);
+ }
+ if (bfd_seek (abfd, i_fxdhdrp -> publicsOffset, SEEK_SET) == -1)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ symbase = (nlm_symbol_type *)
+ bfd_zalloc (abfd, symcount * sizeof (nlm_symbol_type));
+ sym = symbase;
+
+ /* We use the bfd's symcount directly as the control count, so that early
+ termination of the loop leaves the symcount correct for the symbols that
+ were read. */
+
+ while (abfd -> symcount < symcount)
+ {
+ if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ != sizeof (symlength))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ sym -> symbol.the_bfd = abfd;
+ sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
+ if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
+ != symlength)
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ if (bfd_read ((PTR) &symoffset, sizeof (symoffset), 1, abfd)
+ != sizeof (symoffset))
+ {
+ bfd_error = system_call_error;
+ return (false);
+ }
+ sym -> symbol.flags = BSF_GLOBAL | BSF_EXPORT;
+ sym -> symbol.value = get_word (abfd, (bfd_byte *) &symoffset);
+ if (sym -> symbol.value & MSB)
+ {
+ sym -> symbol.value &= ~MSB;
+ sym -> symbol.flags |= BSF_FUNCTION;
+ sym -> symbol.section =
+ bfd_get_section_by_name (abfd, NLM_CODE_NAME);
+ }
+ else
+ {
+ sym -> symbol.section =
+ bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
+ }
+ abfd -> symcount++;
+ sym++;
+ }
+
+ /* Fill in the user's symbol pointer vector if needed. */
+
+ if (symptrs != NULL)
+ {
+ sym = symbase;
+ symcount = abfd -> symcount;
+ while (symcount-- > 0)
+ {
+ *symptrs++ = &sym -> symbol;
+ sym++;
+ }
+ *symptrs = NULL; /* Final NULL pointer */
+ }
+
+ return (true);
+}
+
diff --git a/bfd/targets.c b/bfd/targets.c
index cb97a0f..f777882 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -368,6 +368,10 @@ extern bfd_target bfd_elf32_big_generic_vec;
extern bfd_target bfd_elf32_little_generic_vec;
extern bfd_target bfd_elf64_big_generic_vec;
extern bfd_target bfd_elf64_little_generic_vec;
+extern bfd_target bfd_nlm32_big_generic_vec;
+extern bfd_target bfd_nlm32_little_generic_vec;
+extern bfd_target bfd_nlm64_big_generic_vec;
+extern bfd_target bfd_nlm64_little_generic_vec;
extern bfd_target ieee_vec;
extern bfd_target oasys_vec;
extern bfd_target m88kbcs_vec;
@@ -445,9 +449,13 @@ bfd_target *target_vector[] = {
&bfd_elf32_bigmips_vec,
&bfd_elf32_little_generic_vec,
&bfd_elf32_big_generic_vec,
+ &bfd_nlm32_little_generic_vec,
+ &bfd_nlm32_big_generic_vec,
#ifdef BFD64
&bfd_elf64_little_generic_vec,
&bfd_elf64_big_generic_vec,
+ &bfd_nlm64_little_generic_vec,
+ &bfd_nlm64_big_generic_vec,
#endif
&a_out_adobe_vec,
&b_out_vec_little_host,