aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-04-16 15:11:22 +0930
committerAlan Modra <amodra@gmail.com>2018-04-16 15:11:22 +0930
commitb4b594e304d44458e25e106ddb4824a37aaf556c (patch)
tree56141c32290d4aa4c12ccf1bb1aae631cca7ad39 /bfd
parentfceadf09517d8b37a0fa77852e26a789fc160d94 (diff)
downloadbinutils-b4b594e304d44458e25e106ddb4824a37aaf556c.zip
binutils-b4b594e304d44458e25e106ddb4824a37aaf556c.tar.gz
binutils-b4b594e304d44458e25e106ddb4824a37aaf556c.tar.bz2
Remove netware support
include/ * nlm/ChangeLog-9315: Delete. * nlm/alpha-ext.h: Delete. * nlm/common.h: Delete. * nlm/external.h: Delete. * nlm/i386-ext.h: Delete. * nlm/internal.h: Delete. * nlm/ppc-ext.h: Delete. * nlm/sparc32-ext.h: Delete. bfd/ * Makefile.am: Remove netware support. * bfd-in.h: Likewise. * bfd.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * doc/bfdint.texi: Likewise. * ecoff.c: Likewise. * targets.c: Likewise. * libnlm.h: Delete. * nlm-target.h: Delete. * nlm.c: Delete. * nlm32-alpha.c: Delete. * nlm32-i386.c: Delete. * nlm32-ppc.c: Delete. * nlm32-sparc.c: Delete. * nlm32.c: Delete. * nlm64.c: Delete. * nlmcode.h: Delete. * nlmswap.h: Delete. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * .gitignore: Remove netware support. * Makefile.am: Likewise. * configure.ac: Likewise. * doc/Makefile.am: Likewise. * doc/binutils.texi: Likewise. * testsuite/binutils-all/nm.exp: Likewise. * nlmconv.c: Delete. * nlmconv.h: Delete. * nlmheader.y: Delete. * Makefile.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gas/ * Makefile.am: Remove netware support. * config/tc-i386.c: Likewise. * configure.tgt: Likewise. * config/te-netware.h: Delete. * Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gprof/ * corefile.c: Remove netware support. ld/ * Makefile.am: Remove netware support. * configure.tgt: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise. * emulparams/i386nw.sh: Delete. * emulparams/ppcnw.sh: Delete. * scripttempl/nw.sc: Delete. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog26
-rw-r--r--bfd/Makefile.am18
-rw-r--r--bfd/Makefile.in25
-rw-r--r--bfd/bfd-in.h2
-rw-r--r--bfd/bfd-in2.h4
-rw-r--r--bfd/bfd.c1
-rw-r--r--bfd/config.bfd21
-rwxr-xr-xbfd/configure4
-rw-r--r--bfd/configure.ac4
-rw-r--r--bfd/doc/bfdint.texi24
-rw-r--r--bfd/ecoff.c16
-rw-r--r--bfd/libnlm.h222
-rw-r--r--bfd/nlm-target.h265
-rw-r--r--bfd/nlm.c55
-rw-r--r--bfd/nlm32-alpha.c859
-rw-r--r--bfd/nlm32-i386.c429
-rw-r--r--bfd/nlm32-ppc.c986
-rw-r--r--bfd/nlm32-sparc.c378
-rw-r--r--bfd/nlm32.c22
-rw-r--r--bfd/nlm64.c22
-rw-r--r--bfd/nlmcode.h1982
-rw-r--r--bfd/nlmswap.h153
-rw-r--r--bfd/po/SRC-POTFILES.in11
-rw-r--r--bfd/targets.c10
24 files changed, 31 insertions, 5508 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fe34344..9e26d90 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,31 @@
2018-04-16 Alan Modra <amodra@gmail.com>
+ * Makefile.am: Remove netware support.
+ * bfd-in.h: Likewise.
+ * bfd.c: Likewise.
+ * config.bfd: Likewise.
+ * configure.ac: Likewise.
+ * doc/bfdint.texi: Likewise.
+ * ecoff.c: Likewise.
+ * targets.c: Likewise.
+ * libnlm.h: Delete.
+ * nlm-target.h: Delete.
+ * nlm.c: Delete.
+ * nlm32-alpha.c: Delete.
+ * nlm32-i386.c: Delete.
+ * nlm32-ppc.c: Delete.
+ * nlm32-sparc.c: Delete.
+ * nlm32.c: Delete.
+ * nlm64.c: Delete.
+ * nlmcode.h: Delete.
+ * nlmswap.h: Delete.
+ * Makefile.in: Regenerate.
+ * bfd-in2.h: Regenerate.
+ * configure: Regenerate.
+ * po/SRC-POTFILES.in: Regenerate.
+
+2018-04-16 Alan Modra <amodra@gmail.com>
+
* archures.c: Remove tahoe support.
* config.bfd: Likewise.
* configure.ac: Likewise.
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index a03e2b2..0ed96c9 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -411,11 +411,6 @@ BFD32_BACKENDS = \
mach-o-arm.lo \
mipsbsd.lo \
newsos3.lo \
- nlm.lo \
- nlm32-i386.lo \
- nlm32-ppc.lo \
- nlm32-sparc.lo \
- nlm32.lo \
ns32knetbsd.lo \
oasys.lo \
pc532-mach.lo \
@@ -602,11 +597,6 @@ BFD32_BACKENDS_CFILES = \
mach-o-arm.c \
mipsbsd.c \
newsos3.c \
- nlm.c \
- nlm32-i386.c \
- nlm32-ppc.c \
- nlm32-sparc.c \
- nlm32.c \
ns32knetbsd.c \
oasys.c \
pc532-mach.c \
@@ -690,8 +680,6 @@ BFD64_BACKENDS = \
mach-o-aarch64.lo \
mach-o-x86-64.lo \
mmo.lo \
- nlm32-alpha.lo \
- nlm64.lo \
pe-x86_64.lo \
pei-ia64.lo \
pei-x86_64.lo \
@@ -731,8 +719,6 @@ BFD64_BACKENDS_CFILES = \
mach-o-aarch64.c \
mach-o-x86-64.c \
mmo.c \
- nlm32-alpha.c \
- nlm64.c \
pe-x86_64.c \
pei-ia64.c \
pei-x86_64.c \
@@ -804,8 +790,8 @@ SOURCE_HFILES = \
elf64-hppa.h elfcode.h elfcore.h \
freebsd.h genlink.h go32stub.h \
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
- libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \
- netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \
+ liboasys.h libpei.h libxcoff.h mach-o.h \
+ netbsd.h ns32k.h \
pef.h pef-traceback.h peicode.h som.h version.h \
vms.h xsym.h
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index d63aef9..91614ce 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -745,11 +745,6 @@ BFD32_BACKENDS = \
mach-o-arm.lo \
mipsbsd.lo \
newsos3.lo \
- nlm.lo \
- nlm32-i386.lo \
- nlm32-ppc.lo \
- nlm32-sparc.lo \
- nlm32.lo \
ns32knetbsd.lo \
oasys.lo \
pc532-mach.lo \
@@ -936,11 +931,6 @@ BFD32_BACKENDS_CFILES = \
mach-o-arm.c \
mipsbsd.c \
newsos3.c \
- nlm.c \
- nlm32-i386.c \
- nlm32-ppc.c \
- nlm32-sparc.c \
- nlm32.c \
ns32knetbsd.c \
oasys.c \
pc532-mach.c \
@@ -1025,8 +1015,6 @@ BFD64_BACKENDS = \
mach-o-aarch64.lo \
mach-o-x86-64.lo \
mmo.lo \
- nlm32-alpha.lo \
- nlm64.lo \
pe-x86_64.lo \
pei-ia64.lo \
pei-x86_64.lo \
@@ -1066,8 +1054,6 @@ BFD64_BACKENDS_CFILES = \
mach-o-aarch64.c \
mach-o-x86-64.c \
mmo.c \
- nlm32-alpha.c \
- nlm64.c \
pe-x86_64.c \
pei-ia64.c \
pei-x86_64.c \
@@ -1139,8 +1125,8 @@ SOURCE_HFILES = \
elf64-hppa.h elfcode.h elfcore.h \
freebsd.h genlink.h go32stub.h \
libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
- libnlm.h liboasys.h libpei.h libxcoff.h mach-o.h \
- netbsd.h nlm-target.h nlmcode.h nlmswap.h ns32k.h \
+ liboasys.h libpei.h libxcoff.h mach-o.h \
+ netbsd.h ns32k.h \
pef.h pef-traceback.h peicode.h som.h version.h \
vms.h xsym.h
@@ -1594,13 +1580,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmo.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netbsd-core.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newsos3.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm32-alpha.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm32-i386.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm32-ppc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm32-sparc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm32.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nlm64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ns32knetbsd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oasys.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opncls.Plo@am__quote@
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index a06cd74..cc59ed6 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -608,8 +608,6 @@ extern bfd_boolean _bfd_handle_already_linked
/* Externally visible ECOFF routines. */
-extern bfd_vma bfd_ecoff_get_gp_value
- (bfd * abfd);
extern bfd_boolean bfd_ecoff_set_gp_value
(bfd *abfd, bfd_vma gp_value);
extern bfd_boolean bfd_ecoff_set_regmasks
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 6a3d3d5..d04f028 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -615,8 +615,6 @@ extern bfd_boolean _bfd_handle_already_linked
/* Externally visible ECOFF routines. */
-extern bfd_vma bfd_ecoff_get_gp_value
- (bfd * abfd);
extern bfd_boolean bfd_ecoff_set_gp_value
(bfd *abfd, bfd_vma gp_value);
extern bfd_boolean bfd_ecoff_set_regmasks
@@ -7015,7 +7013,6 @@ struct bfd
struct ihex_data_struct *ihex_data;
struct tekhex_data_struct *tekhex_data;
struct elf_obj_tdata *elf_obj_data;
- struct nlm_obj_tdata *nlm_obj_data;
struct mmo_data_struct *mmo_data;
struct sun_core_struct *sun_core_data;
struct sco5_core_struct *sco5_core_data;
@@ -7325,7 +7322,6 @@ enum bfd_flavour
bfd_target_xcoff_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/bfd.c b/bfd/bfd.c
index 31bcc34..31df6cd 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -317,7 +317,6 @@ CODE_FRAGMENT
. struct ihex_data_struct *ihex_data;
. struct tekhex_data_struct *tekhex_data;
. struct elf_obj_tdata *elf_obj_data;
-. struct nlm_obj_tdata *nlm_obj_data;
. struct mmo_data_struct *mmo_data;
. struct sun_core_struct *sun_core_data;
. struct sco5_core_struct *sco5_core_data;
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 77ce4eb..4f6fb94 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -57,7 +57,6 @@ case $targ in
mips*-*-irix5* | mips*-*-irix6*)
# Not obsolete
;;
- *-*-netware* | \
arm-epoc-pe* | \
arm*-*-aout | \
arm*-*-coff | \
@@ -75,7 +74,6 @@ case $targ in
i[3-7]86-*-freebsd[12] | \
i[3-7]86-*-netbsdaout* | i[3-7]86-*-netbsd* | \
i[3-7]86-*-openbsd[0-2].* | i[3-7]86-*-openbsd3.[0-3] | \
- i[3-7]86-*-netware* | \
i[3-7]86-*-linux*aout* | \
i[3-7]86-*-mach* | i[3-7]86-*-osf1mk* | \
i[3-7]86-*-os9k | \
@@ -106,7 +104,6 @@ case $targ in
sparc-*-linux*aout* | \
sparc-*-netbsdaout* | \
sparc-*-openbsd[0-2].* | sparc-*-openbsd3.[0-1] | \
- sparc-*-netware* | \
sparc64-*-aout* | \
sparc*-*-coff* | \
vax-*-bsd* | vax-*-ultrix* | \
@@ -130,6 +127,7 @@ esac
case $targ in
*-adobe-* | \
*-go32-rtems* | \
+ *-*-netware* | \
*-*-rtemsaout* | \
*-*-rtemscoff* | \
a29k-* | \
@@ -294,11 +292,6 @@ case "${targ}" in
targ_selvecs=alpha_ecoff_le_vec
want64=true
;;
- alpha*-*-netware*)
- targ_defvec=alpha_ecoff_le_vec
- targ_selvecs=alpha_nlm32_vec
- want64=true
- ;;
alpha*-*-linux*ecoff*)
targ_defvec=alpha_ecoff_le_vec
targ_selvecs=alpha_elf64_vec
@@ -732,10 +725,6 @@ case "${targ}" in
targ_defvec=i386_elf32_vec
targ_selvecs="iamcu_elf32_vec i386_aout_nbsd_vec"
;;
- i[3-7]86-*-netware*)
- targ_defvec=i386_elf32_vec
- targ_selvecs="iamcu_elf32_vec i386_nlm32_vec i386_coff_vec i386_aout_vec"
- ;;
i[3-7]86-*-linux*aout*)
targ_defvec=i386_aout_linux_vec
targ_selvecs="i386_elf32_vec iamcu_elf32_vec"
@@ -1384,10 +1373,6 @@ case "${targ}" in
targ_selvecs="rs6000_xcoff_vec"
targ_cflags=-DSMALL_ARCHIVE
;;
- powerpc-*-netware*)
- targ_defvec=powerpc_elf32_vec
- targ_selvecs="powerpc_nlm32_vec rs6000_xcoff_vec"
- ;;
powerpc-*-nto*)
targ_defvec=powerpc_elf32_vec
targ_selvecs="rs6000_xcoff_vec powerpc_elf32_le_vec powerpc_boot_vec"
@@ -1665,10 +1650,6 @@ case "${targ}" in
targ_defvec=sparc_elf32_vxworks_vec
targ_selvecs="sparc_elf32_vec sparc_aout_sunos_be_vec"
;;
- sparc-*-netware*)
- targ_defvec=sparc_elf32_vec
- targ_selvecs="sparc_nlm32_vec sparc_aout_sunos_be_vec"
- ;;
#ifdef BFD64
sparc64-*-aout*)
targ_defvec=sparc_aout_sunos_be_vec
diff --git a/bfd/configure b/bfd/configure
index 5a06c7a..81befe3 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -14337,7 +14337,6 @@ do
alpha_ecoff_le_vec) tb="$tb coff-alpha.lo ecoff.lo $ecoff"; target_size=64 ;;
alpha_elf64_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
alpha_elf64_fbsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
- alpha_nlm32_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"; target_size=64 ;;
alpha_vms_vec) tb="$tb vms-alpha.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
alpha_vms_lib_txt_vec) tb="$tb vms-lib.lo vms-misc.lo" ;;
am33_elf32_linux_vec) tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
@@ -14424,7 +14423,6 @@ do
i386_elf32_vxworks_vec) tb="$tb elf32-i386.lo elfxx-x86.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
i386_mach_o_vec) tb="$tb mach-o-i386.lo" ;;
i386_msdos_vec) tb="$tb i386msdos.lo" ;;
- i386_nlm32_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
i386_pe_vec) tb="$tb pe-i386.lo peigen.lo $coff" ;;
i386_pei_vec) tb="$tb pei-i386.lo peigen.lo $coff" ;;
iamcu_elf32_vec) tb="$tb elf32-i386.lo elfxx-x86.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
@@ -14539,7 +14537,6 @@ do
powerpc_elf64_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
powerpc_elf64_le_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
powerpc_elf64_fbsd_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
- powerpc_nlm32_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo $coff" ;;
powerpc_pe_le_vec) tb="$tb pe-ppc.lo peigen.lo $coff" ;;
powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo $coff" ;;
@@ -14601,7 +14598,6 @@ do
sparc_elf64_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
sparc_elf64_fbsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
sparc_elf64_sol2_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
- sparc_nlm32_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
spu_elf32_vec) tb="$tb elf32-spu.lo elf32.lo $elf" ;;
sym_vec) tb="$tb xsym.lo" ;;
tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
diff --git a/bfd/configure.ac b/bfd/configure.ac
index afaa635..e8250ad 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -414,7 +414,6 @@ do
alpha_ecoff_le_vec) tb="$tb coff-alpha.lo ecoff.lo $ecoff"; target_size=64 ;;
alpha_elf64_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
alpha_elf64_fbsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
- alpha_nlm32_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"; target_size=64 ;;
alpha_vms_vec) tb="$tb vms-alpha.lo vms-misc.lo vms-lib.lo"; target_size=64 ;;
alpha_vms_lib_txt_vec) tb="$tb vms-lib.lo vms-misc.lo" ;;
am33_elf32_linux_vec) tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
@@ -501,7 +500,6 @@ do
i386_elf32_vxworks_vec) tb="$tb elf32-i386.lo elfxx-x86.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
i386_mach_o_vec) tb="$tb mach-o-i386.lo" ;;
i386_msdos_vec) tb="$tb i386msdos.lo" ;;
- i386_nlm32_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
i386_pe_vec) tb="$tb pe-i386.lo peigen.lo $coff" ;;
i386_pei_vec) tb="$tb pei-i386.lo peigen.lo $coff" ;;
iamcu_elf32_vec) tb="$tb elf32-i386.lo elfxx-x86.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
@@ -616,7 +614,6 @@ do
powerpc_elf64_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
powerpc_elf64_le_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
powerpc_elf64_fbsd_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
- powerpc_nlm32_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo $coff" ;;
powerpc_pe_le_vec) tb="$tb pe-ppc.lo peigen.lo $coff" ;;
powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo $coff" ;;
@@ -678,7 +675,6 @@ do
sparc_elf64_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
sparc_elf64_fbsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
sparc_elf64_sol2_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
- sparc_nlm32_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
spu_elf32_vec) tb="$tb elf32-spu.lo elf32.lo $elf" ;;
sym_vec) tb="$tb xsym.lo" ;;
tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
diff --git a/bfd/doc/bfdint.texi b/bfd/doc/bfdint.texi
index fa838c4..954a47a 100644
--- a/bfd/doc/bfdint.texi
+++ b/bfd/doc/bfdint.texi
@@ -338,8 +338,6 @@ ECOFF.
ELF.
@item bfd_target_ieee_flavour
IEEE-695.
-@item bfd_target_nlm_flavour
-NLM.
@item bfd_target_oasys_flavour
OASYS.
@item bfd_target_tekhex_flavour
@@ -1116,23 +1114,6 @@ various macros, and includes @file{aout-target.h}.
Like @file{freebsd.h}, except that there are several files which include
it.
-@item nlm-target.h
-@cindex @file{nlm-target.h}
-Defines the target vector for a standard NLM target.
-
-@item nlmcode.h
-@cindex @file{nlmcode.h}
-Like @file{elfcode.h}, but for NLM targets. This is only included by
-@file{nlm32.c} and @file{nlm64.c}, both of which define the macro
-@samp{ARCH_SIZE} to an appropriate value. There are no 64 bit NLM
-targets anyhow, so this is sort of useless.
-
-@item nlmswap.h
-@cindex @file{nlmswap.h}
-Like @file{coffswap.h}, but for NLM targets. This is included by each
-NLM target, but I think it winds up compiling to the exact same code for
-every target, and as such is fairly useless.
-
@item peicode.h
@cindex @file{peicode.h}
Provides swapping routines and other hooks for PE targets.
@@ -1826,11 +1807,6 @@ information. Normally produced by a linker.
Load Memory Address. This is the address at which a section will be
loaded. Compare with VMA, below.
-@item NLM
-NetWare Loadable Module. Used to describe the format of an object which
-be loaded into NetWare, which is some kind of PC based network server
-program.
-
@item object file
A binary file including machine instructions, symbols, and relocation
information. Normally produced by an assembler.
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index c947e60..b01f572 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -2218,22 +2218,6 @@ _bfd_ecoff_set_section_contents (bfd *abfd,
return TRUE;
}
-/* Get the GP value for an ECOFF file. This is a hook used by
- nlmconv. */
-
-bfd_vma
-bfd_ecoff_get_gp_value (bfd *abfd)
-{
- if (bfd_get_flavour (abfd) != bfd_target_ecoff_flavour
- || bfd_get_format (abfd) != bfd_object)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return 0;
- }
-
- return ecoff_data (abfd)->gp;
-}
-
/* Set the GP value for an ECOFF file. This is a hook used by the
assembler. */
diff --git a/bfd/libnlm.h b/bfd/libnlm.h
deleted file mode 100644
index 042c3a4..0000000
--- a/bfd/libnlm.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/* BFD back-end data structures for NLM (NetWare Loadable Modules) files.
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#ifndef _LIBNLM_H_
-#define _LIBNLM_H_ 1
-
-#ifdef ARCH_SIZE
-# define NLM_ARCH_SIZE ARCH_SIZE
-#endif
-#include "nlm/common.h"
-#include "nlm/internal.h"
-#include "nlm/external.h"
-
-/* A reloc for an imported NLM symbol. Normal relocs are associated
- with sections, and include a symbol. These relocs are associated
- with (undefined) symbols, and include a section. */
-
-struct nlm_relent
-{
- /* Section of reloc. */
- asection *section;
- /* Reloc info (sym_ptr_ptr field set only when canonicalized). */
- arelent reloc;
-};
-
-/* Information we keep for an NLM symbol. */
-
-typedef struct
-{
- /* BFD symbol. */
- asymbol symbol;
- /* Number of reloc entries for imported symbol. */
- bfd_size_type rcnt;
- /* Array of reloc information for imported symbol. */
- struct nlm_relent *relocs;
-} nlmNAME(symbol_type);
-
-extern bfd_boolean nlm_mkobject (bfd *);
-extern bfd_boolean nlm_set_arch_mach (bfd *, enum bfd_architecture, unsigned long);
-extern void nlmNAME (get_symbol_info) (bfd *, asymbol *, symbol_info *);
-extern long nlmNAME (get_symtab_upper_bound)(bfd *);
-extern long nlmNAME (canonicalize_symtab) (bfd *, asymbol **);
-extern asymbol * nlmNAME (make_empty_symbol) (bfd *);
-extern void nlmNAME (print_symbol) (bfd *, void *, asymbol *, bfd_print_symbol_type);
-extern long nlmNAME (get_reloc_upper_bound) (bfd *, asection *);
-extern long nlmNAME (canonicalize_reloc) (bfd *, asection *, arelent **, asymbol **);
-extern const bfd_target * nlmNAME (object_p) (bfd *);
-extern bfd_boolean nlmNAME (set_arch_mach) (bfd *, enum bfd_architecture, unsigned long);
-extern bfd_boolean nlmNAME (set_section_contents) (bfd *, asection *, const void *, file_ptr, bfd_size_type);
-extern bfd_boolean nlmNAME (write_object_contents) (bfd *);
-
-/* 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_hdr[1];
- Nlm_Internal_Variable_Header nlm_variable_hdr[1];
- Nlm_Internal_Version_Header nlm_version_hdr[1];
- Nlm_Internal_Copyright_Header nlm_copyright_hdr[1];
- Nlm_Internal_Extended_Header nlm_extended_hdr[1];
- Nlm_Internal_Custom_Header nlm_custom_hdr[1];
- Nlm_Internal_Cygnus_Ext_Header nlm_cygnus_ext_hdr[1];
- /* BFD NLM symbols. */
- nlmNAME (symbol_type) * nlm_symbols;
- /* Lowest text and data VMA values. */
- bfd_vma nlm_text_low;
- bfd_vma nlm_data_low;
- /* Caches for data read from object file. */
- arelent * nlm_reloc_fixups;
- asection ** nlm_reloc_fixup_secs;
- /* Backend specific information. This should probably be a pointer,
- but that would require yet another entry point to initialize the
- structure. */
- union
- {
- struct /* Alpha backend information. */
- {
- bfd_vma gp; /* GP value. */
- bfd_vma lita_address; /* .lita section address. */
- bfd_size_type lita_size; /* .lita section size. */
- }
- alpha_backend_data;
- }
- backend_data;
-};
-
-#define nlm_tdata(bfd) ((bfd) -> tdata.nlm_obj_data)
-#define nlm_fixed_header(bfd) (nlm_tdata (bfd) -> nlm_fixed_hdr)
-#define nlm_variable_header(bfd) (nlm_tdata (bfd) -> nlm_variable_hdr)
-#define nlm_version_header(bfd) (nlm_tdata (bfd) -> nlm_version_hdr)
-#define nlm_copyright_header(bfd) (nlm_tdata (bfd) -> nlm_copyright_hdr)
-#define nlm_extended_header(bfd) (nlm_tdata (bfd) -> nlm_extended_hdr)
-#define nlm_custom_header(bfd) (nlm_tdata (bfd) -> nlm_custom_hdr)
-#define nlm_cygnus_ext_header(bfd) (nlm_tdata (bfd) -> nlm_cygnus_ext_hdr)
-#define nlm_get_symbols(bfd) (nlm_tdata (bfd) -> nlm_symbols)
-#define nlm_set_symbols(bfd, p) (nlm_tdata (bfd) -> nlm_symbols = (p))
-#define nlm_set_text_low(bfd, i) (nlm_tdata (bfd) -> nlm_text_low = (i))
-#define nlm_get_text_low(bfd) (nlm_tdata (bfd) -> nlm_text_low)
-#define nlm_set_data_low(bfd, i) (nlm_tdata (bfd) -> nlm_data_low = (i))
-#define nlm_get_data_low(bfd) (nlm_tdata (bfd) -> nlm_data_low)
-#define nlm_relocation_fixups(bfd) (nlm_tdata (bfd) -> nlm_reloc_fixups)
-#define nlm_relocation_fixup_secs(bfd) (nlm_tdata (bfd) -> nlm_reloc_fixup_secs)
-#define nlm_alpha_backend_data(bfd) (&nlm_tdata (bfd) -> backend_data.alpha_backend_data)
-
-/* This is used when writing out the external relocs. */
-
-struct reloc_and_sec
-{
- arelent *rel;
- asection *sec;
-};
-
-/* We store some function pointer in the backend structure. This lets
- different NLM targets share most of the same code, while providing
- slightly different code where necessary. */
-
-struct nlm_backend_data
-{
- /* Signature for this backend. */
- char signature[NLM_SIGNATURE_SIZE];
- /* Size of the fixed header. */
- bfd_size_type fixed_header_size;
- /* Size of optional prefix for this backend. Some backend may
- require this to be a function, but so far a constant is OK. This
- is for a prefix which precedes the standard NLM fixed header. */
- bfd_size_type optional_prefix_size;
- /* Architecture. */
- enum bfd_architecture arch;
- /* Machine. */
- unsigned int mach;
- /* Some NLM formats do not use the uninitialized data section, so
- all uninitialized data must be put into the regular data section
- instead. */
- bfd_boolean no_uninitialized_data;
- /* Some NLM formats have a prefix on the file. If this function is
- not NULL, it will be called by nlm_object_p. It should return
- TRUE if this file could match this format, and it should leave
- the BFD such that a bfd_bread will pick up the fixed header. */
- bfd_boolean (*nlm_backend_object_p) (bfd *);
- /* Write out the prefix. This function may be NULL. This must
- write out the same number of bytes as is in the field
- optional_prefix_size. */
- bfd_boolean (*nlm_write_prefix) (bfd *);
- /* Read a relocation fixup from abfd. The reloc information is
- machine specific. The second argument is the symbol if this is
- an import, or NULL if this is a reloc fixup. This function
- should set the third argument to the section which the reloc
- belongs in, and the fourth argument to the reloc itself; it does
- not need to fill in the sym_ptr_ptr field for a reloc against an
- import symbol. */
- bfd_boolean (*nlm_read_reloc) (bfd *, nlmNAME (symbol_type) *, asection **, arelent *);
- /* To make objcopy to an i386 NLM work, the i386 backend needs a
- chance to work over the relocs. This is a bit icky. */
- bfd_boolean (*nlm_mangle_relocs) (bfd *, asection *, const void *, bfd_vma, bfd_size_type);
- /* Read an import record from abfd. It would be nice if this
- were in a machine-dependent format, but it doesn't seem to be. */
- bfd_boolean (*nlm_read_import) (bfd *, nlmNAME (symbol_type) *);
- /* Write an import record to abfd. */
- bfd_boolean (*nlm_write_import) (bfd *, asection *, arelent *);
- /* Set the section for a public symbol. This may be NULL, in which
- case a default method will be used. */
- bfd_boolean (*nlm_set_public_section) (bfd *, nlmNAME (symbol_type) *);
- /* Get the offset to write out for a public symbol. This may be
- NULL, in which case a default method will be used. */
- bfd_vma (*nlm_get_public_offset) (bfd *, asymbol *);
- /* Swap the fixed header in and out */
- void (*nlm_swap_fhdr_in) (bfd *, void *, Nlm_Internal_Fixed_Header *);
- void (*nlm_swap_fhdr_out) (bfd *, struct nlm_internal_fixed_header *, void *);
- /* Write out an external reference. */
- bfd_boolean (*nlm_write_external) (bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *);
- bfd_boolean (*nlm_write_export) (bfd *, asymbol *, bfd_vma);
-};
-
-#define nlm_backend(bfd) ((struct nlm_backend_data *)((bfd) -> xvec -> backend_data))
-#define nlm_signature(bfd) (nlm_backend (bfd) -> signature)
-#define nlm_fixed_header_size(bfd) (nlm_backend (bfd) -> fixed_header_size)
-#define nlm_optional_prefix_size(bfd) (nlm_backend (bfd) -> optional_prefix_size)
-#define nlm_architecture(bfd) (nlm_backend (bfd) -> arch)
-#define nlm_machine(bfd) (nlm_backend (bfd) -> mach)
-#define nlm_no_uninitialized_data(bfd) (nlm_backend (bfd) -> no_uninitialized_data)
-#define nlm_backend_object_p_func(bfd) (nlm_backend (bfd) -> nlm_backend_object_p)
-#define nlm_write_prefix_func(bfd) (nlm_backend (bfd) -> nlm_write_prefix)
-#define nlm_read_reloc_func(bfd) (nlm_backend (bfd) -> nlm_read_reloc)
-#define nlm_mangle_relocs_func(bfd) (nlm_backend (bfd) -> nlm_mangle_relocs)
-#define nlm_read_import_func(bfd) (nlm_backend (bfd) -> nlm_read_import)
-#define nlm_write_import_func(bfd) (nlm_backend (bfd) -> nlm_write_import)
-#define nlm_set_public_section_func(bfd) (nlm_backend (bfd) -> nlm_set_public_section)
-#define nlm_get_public_offset_func(bfd) (nlm_backend (bfd) -> nlm_get_public_offset)
-#define nlm_swap_fixed_header_in_func(bfd) (nlm_backend (bfd) -> nlm_swap_fhdr_in)
-#define nlm_swap_fixed_header_out_func(bfd)(nlm_backend (bfd) -> nlm_swap_fhdr_out)
-#define nlm_write_external_func(bfd) (nlm_backend (bfd) -> nlm_write_external)
-#define nlm_write_export_func(bfd) (nlm_backend (bfd) -> nlm_write_export)
-
-/* 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-target.h b/bfd/nlm-target.h
deleted file mode 100644
index a299843..0000000
--- a/bfd/nlm-target.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Target definitions for 32/64-bit NLM (NetWare Loadable Module)
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#define nlm_core_file_p _bfd_dummy_target
-
-#define nlm_get_symtab_upper_bound nlmNAME (get_symtab_upper_bound)
-#define nlm_canonicalize_symtab nlmNAME (canonicalize_symtab)
-#define nlm_make_empty_symbol nlmNAME (make_empty_symbol)
-#define nlm_print_symbol nlmNAME (print_symbol)
-#define nlm_get_symbol_info nlmNAME (get_symbol_info)
-#define nlm_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string
-#define nlm_bfd_is_local_label_name bfd_generic_is_local_label_name
-#define nlm_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
-#define nlm_get_lineno _bfd_nosymbols_get_lineno
-#define nlm_find_nearest_line _bfd_nosymbols_find_nearest_line
-#define nlm_find_line _bfd_nosymbols_find_line
-#define nlm_find_inliner_info _bfd_nosymbols_find_inliner_info
-#define nlm_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
-#define nlm_read_minisymbols _bfd_generic_read_minisymbols
-#define nlm_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-
-#define nlm_get_reloc_upper_bound nlmNAME (get_reloc_upper_bound)
-#define nlm_canonicalize_reloc nlmNAME (canonicalize_reloc)
-#define nlm_set_reloc _bfd_generic_set_reloc
-#define nlm_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
-#define nlm_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
-#define nlm_set_section_contents nlmNAME (set_section_contents)
-
-#define nlm_sizeof_headers _bfd_nolink_sizeof_headers
-#define nlm_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
-#define nlm_bfd_relax_section bfd_generic_relax_section
-#define nlm_bfd_gc_sections bfd_generic_gc_sections
-#define nlm_bfd_lookup_section_flags bfd_generic_lookup_section_flags
-#define nlm_bfd_merge_sections bfd_generic_merge_sections
-#define nlm_bfd_is_group_section bfd_generic_is_group_section
-#define nlm_bfd_discard_group bfd_generic_discard_group
-#define nlm_section_already_linked _bfd_generic_section_already_linked
-#define nlm_bfd_define_common_symbol bfd_generic_define_common_symbol
-#define nlm_bfd_define_start_stop bfd_generic_define_start_stop
-#define nlm_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define nlm_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define nlm_bfd_link_just_syms _bfd_generic_link_just_syms
-#define nlm_bfd_copy_link_hash_symbol_type \
- _bfd_generic_copy_link_hash_symbol_type
-#define nlm_bfd_final_link _bfd_generic_final_link
-#define nlm_bfd_link_split_section _bfd_generic_link_split_section
-#define nlm_bfd_link_check_relocs _bfd_generic_link_check_relocs
-
-/* 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. */
-
-/* Forward declaration for use when initialising alternative_target field. */
-#ifdef TARGET_LITTLE_SYM
-extern const bfd_target TARGET_LITTLE_SYM;
-#endif
-
-#ifdef TARGET_BIG_SYM
-const bfd_target TARGET_BIG_SYM =
-{
- /* Name: identify kind of target. */
- TARGET_BIG_NAME,
-
- /* Flavour: general indication about file. */
- bfd_target_nlm_flavour,
-
- /* Byteorder: data is big endian. */
- BFD_ENDIAN_BIG,
-
- /* Header_byteorder: header is also big endian. */
- BFD_ENDIAN_BIG,
-
- /* Object_flags: mask of all file flags. */
- (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
- | 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,
- 0, /* match priority. */
-
- /* Routines to byte-swap various sized integers from the data sections. */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
-
- /* Routines to byte-swap various sized integers from the file headers. */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16,
-
- /* bfd_check_format: check the format of a file being read. */
- { _bfd_dummy_target, /* Unknown format. */
- nlmNAME (object_p), /* Assembler/linker output (object file). */
- bfd_generic_archive_p, /* An archive. */
- nlm_core_file_p /* A core file. */
- },
-
- /* bfd_set_format: set the format of a file being written. */
- { _bfd_bool_bfd_false_error,
- nlm_mkobject,
- _bfd_generic_mkarchive,
- _bfd_bool_bfd_false_error
- },
-
- /* bfd_write_contents: write cached information into a file being written. */
- { _bfd_bool_bfd_false_error,
- nlmNAME (write_object_contents),
- _bfd_write_archive_contents,
- _bfd_bool_bfd_false_error
- },
-
- /* Initialize a jump table with the standard macro.
- All names start with "nlm". */
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (nlm),
- BFD_JUMP_TABLE_RELOCS (nlm),
- BFD_JUMP_TABLE_WRITE (nlm),
- BFD_JUMP_TABLE_LINK (nlm),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- /* Alternative endian target. */
-#ifdef TARGET_LITTLE_SYM
- & TARGET_LITTLE_SYM,
-#else
- NULL,
-#endif
-
- /* Backend_data. */
- (void *) TARGET_BACKEND_DATA
-};
-#endif
-
-#ifdef TARGET_LITTLE_SYM
-const bfd_target TARGET_LITTLE_SYM =
-{
- /* Name: identify kind of target. */
- TARGET_LITTLE_NAME,
-
- /* Flavour: general indication about file. */
- bfd_target_nlm_flavour,
-
- /* Byteorder: data is little endian. */
- BFD_ENDIAN_LITTLE,
-
- /* Header_byteorder: header is also little endian. */
- BFD_ENDIAN_LITTLE,
-
- /* Object_flags: mask of all file flags. */
- (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS
- | 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,
- 0, /* match priority. */
-
- /* Routines to byte-swap various sized integers from the data sections. */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16,
-
- /* Routines to byte-swap various sized integers from the file headers. */
- bfd_getl64, bfd_getl_signed_64, bfd_putl64,
- bfd_getl32, bfd_getl_signed_32, bfd_putl32,
- bfd_getl16, bfd_getl_signed_16, bfd_putl16,
-
- /* bfd_check_format: check the format of a file being read. */
- { _bfd_dummy_target, /* Unknown format. */
- nlmNAME(object_p), /* Assembler/linker output (object file). */
- bfd_generic_archive_p, /* An archive. */
- nlm_core_file_p /* A core file. */
- },
-
- /* bfd_set_format: set the format of a file being written. */
- { _bfd_bool_bfd_false_error,
- nlm_mkobject,
- _bfd_generic_mkarchive,
- _bfd_bool_bfd_false_error
- },
-
- /* bfd_write_contents: write cached information into a file being written. */
- { _bfd_bool_bfd_false_error,
- nlmNAME(write_object_contents),
- _bfd_write_archive_contents,
- _bfd_bool_bfd_false_error
- },
-
- /* Initialize a jump table with the standard macro.
- All names start with "nlm". */
- BFD_JUMP_TABLE_GENERIC (_bfd_generic),
- BFD_JUMP_TABLE_COPY (_bfd_generic),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
- BFD_JUMP_TABLE_SYMBOLS (nlm),
- BFD_JUMP_TABLE_RELOCS (nlm),
- BFD_JUMP_TABLE_WRITE (nlm),
- BFD_JUMP_TABLE_LINK (nlm),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- /* Alternative endian target. */
-#ifdef TARGET_BIG_SYM
- & TARGET_BIG_SYM,
-#else
- NULL,
-#endif
-
- /* Backend_data. */
- (void *) TARGET_BACKEND_DATA
-};
-#endif
diff --git a/bfd/nlm.c b/bfd/nlm.c
deleted file mode 100644
index 828a474..0000000
--- a/bfd/nlm.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* NLM (NetWare Loadable Module) executable support for BFD.
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
-#include "libnlm.h"
-
-/* Make an NLM object. We just need to allocate the backend
- information. */
-
-bfd_boolean
-nlm_mkobject (bfd * abfd)
-{
- bfd_size_type amt = sizeof (struct nlm_obj_tdata);
-
- nlm_tdata (abfd) = bfd_zalloc (abfd, amt);
- if (nlm_tdata (abfd) == NULL)
- return FALSE;
-
- if (nlm_architecture (abfd) != bfd_arch_unknown)
- bfd_default_set_arch_mach (abfd, nlm_architecture (abfd),
- nlm_machine (abfd));
-
- /* Since everything is done at close time, do we need any initialization ? */
- return TRUE;
-}
-
-/* Set the architecture and machine for an NLM object. */
-
-bfd_boolean
-nlm_set_arch_mach (bfd * abfd,
- enum bfd_architecture arch,
- unsigned long machine)
-{
- bfd_default_set_arch_mach (abfd, arch, machine);
- return arch == nlm_architecture (abfd);
-}
diff --git a/bfd/nlm32-alpha.c b/bfd/nlm32-alpha.c
deleted file mode 100644
index 05e36b0..0000000
--- a/bfd/nlm32-alpha.c
+++ /dev/null
@@ -1,859 +0,0 @@
-/* Support for 32-bit Alpha NLM (NetWare Loadable Module)
- Copyright (C) 1993-2018 Free Software Foundation, Inc.
- Written by Ian Lance Taylor, 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-
-/* This file describes the 32 bit Alpha NLM format. You might think
- that an Alpha chip would use a 64 bit format, but, for some reason,
- it doesn't. */
-
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-#include "nlm/alpha-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_alpha_External_Fixed_Header
-
-#include "libnlm.h"
-
-/* Alpha NLM's have a prefix header before the standard NLM. This
- function reads it in, verifies the version, and seeks the bfd to
- the location before the regular NLM header. */
-
-static bfd_boolean
-nlm_alpha_backend_object_p (bfd *abfd)
-{
- struct nlm32_alpha_external_prefix_header s;
- file_ptr size;
-
- if (bfd_bread (&s, (bfd_size_type) sizeof s, abfd) != sizeof s)
- return FALSE;
-
- if (H_GET_32 (abfd, s.magic) != NLM32_ALPHA_MAGIC)
- return FALSE;
-
- /* FIXME: Should we check the format number? */
-
- /* Skip to the end of the header. */
- size = H_GET_32 (abfd, s.size);
- if (bfd_seek (abfd, size, SEEK_SET) != 0)
- return FALSE;
-
- return TRUE;
-}
-
-/* Write out the prefix. */
-
-static bfd_boolean
-nlm_alpha_write_prefix (bfd *abfd)
-{
- struct nlm32_alpha_external_prefix_header s;
-
- memset (&s, 0, sizeof s);
- H_PUT_32 (abfd, NLM32_ALPHA_MAGIC, s.magic);
- H_PUT_32 (abfd, 2, s.format);
- H_PUT_32 (abfd, sizeof s, s.size);
- if (bfd_bwrite (&s, (bfd_size_type) sizeof s, abfd) != sizeof s)
- return FALSE;
- return TRUE;
-}
-
-#define ONES(n) (((bfd_vma) 1 << ((n) - 1) << 1) - 1)
-
-/* How to process the various reloc types. */
-
-static reloc_howto_type nlm32_alpha_howto_table[] =
-{
- /* Reloc type 0 is ignored by itself. However, it appears after a
- GPDISP reloc to identify the location where the low order 16 bits
- of the gp register are loaded. */
- HOWTO (ALPHA_R_IGNORE, /* Type. */
- 0, /* Rightshift. */
- 0, /* Size (0 = byte, 1 = short, 2 = long). */
- 8, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "IGNORE", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* A 32 bit reference to a symbol. */
- HOWTO (ALPHA_R_REFLONG, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "REFLONG", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* A 64 bit reference to a symbol. */
- HOWTO (ALPHA_R_REFQUAD, /* Type. */
- 0, /* Rightshift. */
- 4, /* Size (0 = byte, 1 = short, 2 = long). */
- 64, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "REFQUAD", /* Name. */
- TRUE, /* Partial_inplace. */
- ONES (64), /* Source mask. */
- ONES (64), /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* A 32 bit GP relative offset. This is just like REFLONG except
- that when the value is used the value of the gp register will be
- added in. */
- HOWTO (ALPHA_R_GPREL32, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "GPREL32", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Used for an instruction that refers to memory off the GP
- register. The offset is 16 bits of the 32 bit instruction. This
- reloc always seems to be against the .lita section. */
- HOWTO (ALPHA_R_LITERAL, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "LITERAL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* This reloc only appears immediately following a LITERAL reloc.
- It identifies a use of the literal. It seems that the linker can
- use this to eliminate a portion of the .lita section. The symbol
- index is special: 1 means the literal address is in the base
- register of a memory format instruction; 2 means the literal
- address is in the byte offset register of a byte-manipulation
- instruction; 3 means the literal address is in the target
- register of a jsr instruction. This does not actually do any
- relocation. */
- HOWTO (ALPHA_R_LITUSE, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "LITUSE", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Load the gp register. This is always used for a ldah instruction
- which loads the upper 16 bits of the gp register. The next reloc
- will be an IGNORE reloc which identifies the location of the lda
- instruction which loads the lower 16 bits. The symbol index of
- the GPDISP instruction appears to actually be the number of bytes
- between the ldah and lda instructions. This gives two different
- ways to determine where the lda instruction is; I don't know why
- both are used. The value to use for the relocation is the
- difference between the GP value and the current location; the
- load will always be done against a register holding the current
- address. */
- HOWTO (ALPHA_R_GPDISP, /* Type. */
- 16, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- TRUE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "GPDISP", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- TRUE), /* PCrel_offset. */
-
- /* A 21 bit branch. The native assembler generates these for
- branches within the text segment, and also fills in the PC
- relative offset in the instruction. It seems to me that this
- reloc, unlike the others, is not partial_inplace. */
- HOWTO (ALPHA_R_BRADDR, /* Type. */
- 2, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 21, /* Bitsize. */
- TRUE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "BRADDR", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0x1fffff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* A hint for a jump to a register. */
- HOWTO (ALPHA_R_HINT, /* Type. */
- 2, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 14, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "HINT", /* Name. */
- TRUE, /* Partial_inplace. */
- 0x3fff, /* Source mask. */
- 0x3fff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* 16 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL16, /* Type. */
- 0, /* Rightshift. */
- 1, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- TRUE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "SREL16", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* 32 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL32, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- TRUE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "SREL32", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* A 64 bit PC relative offset. */
- HOWTO (ALPHA_R_SREL64, /* Type. */
- 0, /* Rightshift. */
- 4, /* Size (0 = byte, 1 = short, 2 = long). */
- 64, /* Bitsize. */
- TRUE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "SREL64", /* Name. */
- TRUE, /* Partial_inplace. */
- ONES (64), /* Source mask. */
- ONES (64), /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Push a value on the reloc evaluation stack. */
- HOWTO (ALPHA_R_OP_PUSH, /* Type. */
- 0, /* Rightshift. */
- 0, /* Size (0 = byte, 1 = short, 2 = long). */
- 0, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "OP_PUSH", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Store the value from the stack at the given address. Store it in
- a bitfield of size r_size starting at bit position r_offset. */
- HOWTO (ALPHA_R_OP_STORE, /* Type. */
- 0, /* Rightshift. */
- 4, /* Size (0 = byte, 1 = short, 2 = long). */
- 64, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "OP_STORE", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- ONES (64), /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Subtract the reloc address from the value on the top of the
- relocation stack. */
- HOWTO (ALPHA_R_OP_PSUB, /* Type. */
- 0, /* Rightshift. */
- 0, /* Size (0 = byte, 1 = short, 2 = long). */
- 0, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "OP_PSUB", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Shift the value on the top of the relocation stack right by the
- given value. */
- HOWTO (ALPHA_R_OP_PRSHIFT, /* Type. */
- 0, /* Rightshift. */
- 0, /* Size (0 = byte, 1 = short, 2 = long). */
- 0, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "OP_PRSHIFT", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE), /* PCrel_offset. */
-
- /* Adjust the GP value for a new range in the object file. */
- HOWTO (ALPHA_R_GPVALUE, /* Type. */
- 0, /* Rightshift. */
- 0, /* Size (0 = byte, 1 = short, 2 = long). */
- 0, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "GPVALUE", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE) /* PCrel_offset. */
-};
-
-static reloc_howto_type nlm32_alpha_nw_howto =
- HOWTO (ALPHA_R_NW_RELOC, /* Type. */
- 0, /* Rightshift. */
- 0, /* Size (0 = byte, 1 = short, 2 = long). */
- 0, /* Bitsize. */
- FALSE, /* PC_relative. */
- 0, /* Bitpos. */
- complain_overflow_dont, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "NW_RELOC", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE); /* PCrel_offset. */
-
-/* Read an Alpha NLM reloc. This routine keeps some static data which
- it uses when handling local relocs. This only works correctly
- because all the local relocs are read at once. */
-
-static bfd_boolean
-nlm_alpha_read_reloc (bfd *abfd,
- nlmNAME (symbol_type) *sym,
- asection **secp,
- arelent *rel)
-{
- static bfd_vma gp_value;
- static bfd_vma lita_address;
- struct nlm32_alpha_external_reloc ext;
- bfd_vma r_vaddr;
- long r_symndx;
- int r_type, r_extern, r_offset, r_size;
- asection *code_sec, *data_sec;
-
- /* Read the reloc from the file. */
- if (bfd_bread (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
- return FALSE;
-
- /* Swap in the reloc information. */
- r_vaddr = H_GET_64 (abfd, ext.r_vaddr);
- r_symndx = H_GET_32 (abfd, ext.r_symndx);
-
- BFD_ASSERT (bfd_little_endian (abfd));
-
- r_type = ((ext.r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
- >> RELOC_BITS0_TYPE_SH_LITTLE);
- r_extern = (ext.r_bits[1] & RELOC_BITS1_EXTERN_LITTLE) != 0;
- r_offset = ((ext.r_bits[1] & RELOC_BITS1_OFFSET_LITTLE)
- >> RELOC_BITS1_OFFSET_SH_LITTLE);
- /* Ignore the reserved bits. */
- r_size = ((ext.r_bits[3] & RELOC_BITS3_SIZE_LITTLE)
- >> RELOC_BITS3_SIZE_SH_LITTLE);
-
- /* Fill in the BFD arelent structure. */
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- if (r_extern)
- {
- /* External relocations are only used for imports. */
- BFD_ASSERT (sym != NULL);
- /* We don't need to set sym_ptr_ptr for this case. It is set in
- nlm_canonicalize_reloc. */
- rel->sym_ptr_ptr = NULL;
- rel->addend = 0;
- }
- else
- {
- /* Internal relocations are only used for local relocation
- fixups. If they are not NW_RELOC or GPDISP or IGNORE, they
- must be against .text or .data. */
- BFD_ASSERT (r_type == ALPHA_R_NW_RELOC || sym == NULL);
- if (r_type == ALPHA_R_NW_RELOC
- || r_type == ALPHA_R_GPDISP
- || r_type == ALPHA_R_IGNORE)
- {
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rel->addend = 0;
- }
- else if (r_symndx == ALPHA_RELOC_SECTION_TEXT)
- {
- rel->sym_ptr_ptr = code_sec->symbol_ptr_ptr;
- BFD_ASSERT (bfd_get_section_vma (abfd, code_sec) == 0);
- rel->addend = 0;
- }
- else if (r_symndx == ALPHA_RELOC_SECTION_DATA)
- {
- rel->sym_ptr_ptr = data_sec->symbol_ptr_ptr;
- rel->addend = - bfd_get_section_vma (abfd, data_sec);
- }
- else
- {
- BFD_ASSERT (0);
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rel->addend = 0;
- }
- }
-
- /* We use the address to determine whether the reloc is in the .text
- or .data section. R_NW_RELOC relocs don't really have a section,
- so we put them in .text. */
- if (r_type == ALPHA_R_NW_RELOC
- || r_vaddr < code_sec->size)
- {
- *secp = code_sec;
- rel->address = r_vaddr;
- }
- else
- {
- *secp = data_sec;
- rel->address = r_vaddr - code_sec->size;
- }
-
- /* We must adjust the addend based on the type. */
- BFD_ASSERT ((r_type >= 0 && r_type <= ALPHA_R_GPVALUE)
- || r_type == ALPHA_R_NW_RELOC);
-
- switch (r_type)
- {
- case ALPHA_R_BRADDR:
- case ALPHA_R_SREL16:
- case ALPHA_R_SREL32:
- case ALPHA_R_SREL64:
- /* The PC relative relocs do not seem to use the section VMA as
- a negative addend. */
- rel->addend = 0;
- break;
-
- case ALPHA_R_GPREL32:
- /* Copy the gp value for this object file into the addend, to
- ensure that we are not confused by the linker. */
- if (! r_extern)
- rel->addend += gp_value;
- break;
-
- case ALPHA_R_LITERAL:
- BFD_ASSERT (! r_extern);
- rel->addend += lita_address;
- break;
-
- case ALPHA_R_LITUSE:
- case ALPHA_R_GPDISP:
- /* The LITUSE and GPDISP relocs do not use a symbol, or an
- addend, but they do use a special code. Put this code in the
- addend field. */
- rel->addend = r_symndx;
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- break;
-
- case ALPHA_R_OP_STORE:
- /* The STORE reloc needs the size and offset fields. We store
- them in the addend. */
- BFD_ASSERT (r_offset < 256 && r_size < 256);
- rel->addend = (r_offset << 8) + r_size;
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- /* The PUSH, PSUB and PRSHIFT relocs do not actually use an
- address. I believe that the address supplied is really an
- addend. */
- rel->addend = r_vaddr;
- break;
-
- case ALPHA_R_GPVALUE:
- /* Record the new gp value. */
- gp_value += r_symndx;
- rel->addend = gp_value;
- break;
-
- case ALPHA_R_IGNORE:
- /* If the type is ALPHA_R_IGNORE, make sure this is a reference
- to the absolute section so that the reloc is ignored. For
- some reason the address of this reloc type is not adjusted by
- the section vma. We record the gp value for this object file
- here, for convenience when doing the GPDISP relocation. */
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- rel->address = r_vaddr;
- rel->addend = gp_value;
- break;
-
- case ALPHA_R_NW_RELOC:
- /* If this is SETGP, we set the addend to 0. Otherwise we set
- the addend to the size of the .lita section (this is
- r_symndx) plus 1. We have already set the address of the
- reloc to r_vaddr. */
- if (r_size == ALPHA_R_NW_RELOC_SETGP)
- {
- gp_value = r_vaddr;
- rel->addend = 0;
- }
- else if (r_size == ALPHA_R_NW_RELOC_LITA)
- {
- lita_address = r_vaddr;
- rel->addend = r_symndx + 1;
- }
- else
- BFD_ASSERT (0);
- rel->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- break;
-
- default:
- break;
- }
-
- if (r_type == ALPHA_R_NW_RELOC)
- rel->howto = &nlm32_alpha_nw_howto;
- else
- rel->howto = &nlm32_alpha_howto_table[r_type];
-
- return TRUE;
-}
-
-/* Mangle Alpha NLM relocs for output. */
-
-static bfd_boolean
-nlm_alpha_mangle_relocs (bfd *abfd ATTRIBUTE_UNUSED,
- asection *sec ATTRIBUTE_UNUSED,
- const void * data ATTRIBUTE_UNUSED,
- bfd_vma offset ATTRIBUTE_UNUSED,
- bfd_size_type count ATTRIBUTE_UNUSED)
-{
- return TRUE;
-}
-
-/* Read an ALPHA NLM import record. */
-
-static bfd_boolean
-nlm_alpha_read_import (bfd *abfd, nlmNAME (symbol_type) * sym)
-{
- struct nlm_relent *nlm_relocs; /* Relocation records for symbol. */
- bfd_size_type rcount; /* Number of relocs. */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Temporary 32-bit value. */
- unsigned char symlength; /* Length of symbol name. */
- char *name;
- bfd_size_type amt;
-
- if (bfd_bread (& symlength, (bfd_size_type) sizeof (symlength), abfd)
- != sizeof (symlength))
- return FALSE;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
- if (name == NULL)
- return FALSE;
- if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
- return FALSE;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd)
- != sizeof (temp))
- return FALSE;
- rcount = H_GET_32 (abfd, temp);
- amt = rcount * sizeof (struct nlm_relent);
- nlm_relocs = bfd_alloc (abfd, amt);
- if (!nlm_relocs)
- return FALSE;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (! nlm_alpha_read_reloc (abfd, sym, &section, &nlm_relocs -> reloc))
- return FALSE;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
-
- return TRUE;
-}
-
-/* Write an Alpha NLM reloc. */
-
-static bfd_boolean
-nlm_alpha_write_import (bfd * abfd, asection * sec, arelent * rel)
-{
- asymbol *sym;
- bfd_vma r_vaddr;
- long r_symndx;
- int r_type, r_extern, r_offset, r_size;
- struct nlm32_alpha_external_reloc ext;
-
- sym = *rel->sym_ptr_ptr;
-
- /* Get values for the relocation fields. */
- r_type = rel->howto->type;
- if (r_type != ALPHA_R_NW_RELOC)
- {
- r_vaddr = bfd_get_section_vma (abfd, sec) + rel->address;
- if ((sec->flags & SEC_CODE) == 0)
- r_vaddr += bfd_get_section_by_name (abfd, NLM_CODE_NAME) -> size;
- if (bfd_is_und_section (bfd_get_section (sym)))
- {
- r_extern = 1;
- r_symndx = 0;
- }
- else
- {
- r_extern = 0;
- if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
- r_symndx = ALPHA_RELOC_SECTION_TEXT;
- else
- r_symndx = ALPHA_RELOC_SECTION_DATA;
- }
- r_offset = 0;
- r_size = 0;
-
- switch (r_type)
- {
- case ALPHA_R_LITUSE:
- case ALPHA_R_GPDISP:
- r_symndx = rel->addend;
- break;
-
- case ALPHA_R_OP_STORE:
- r_size = rel->addend & 0xff;
- r_offset = (rel->addend >> 8) & 0xff;
- break;
-
- case ALPHA_R_OP_PUSH:
- case ALPHA_R_OP_PSUB:
- case ALPHA_R_OP_PRSHIFT:
- r_vaddr = rel->addend;
- break;
-
- case ALPHA_R_IGNORE:
- r_vaddr = rel->address;
- break;
-
- default:
- break;
- }
- }
- else
- {
- /* r_type == ALPHA_R_NW_RELOC. */
- r_vaddr = rel->address;
- if (rel->addend == 0)
- {
- r_symndx = 0;
- r_size = ALPHA_R_NW_RELOC_SETGP;
- }
- else
- {
- r_symndx = rel->addend - 1;
- r_size = ALPHA_R_NW_RELOC_LITA;
- }
- r_extern = 0;
- r_offset = 0;
- }
-
- /* Swap out the relocation fields. */
- H_PUT_64 (abfd, r_vaddr, ext.r_vaddr);
- H_PUT_32 (abfd, r_symndx, ext.r_symndx);
-
- BFD_ASSERT (bfd_little_endian (abfd));
-
- ext.r_bits[0] = ((r_type << RELOC_BITS0_TYPE_SH_LITTLE)
- & RELOC_BITS0_TYPE_LITTLE);
- ext.r_bits[1] = ((r_extern ? RELOC_BITS1_EXTERN_LITTLE : 0)
- | ((r_offset << RELOC_BITS1_OFFSET_SH_LITTLE)
- & RELOC_BITS1_OFFSET_LITTLE));
- ext.r_bits[2] = 0;
- ext.r_bits[3] = ((r_size << RELOC_BITS3_SIZE_SH_LITTLE)
- & RELOC_BITS3_SIZE_LITTLE);
-
- /* Write out the relocation. */
- if (bfd_bwrite (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
- return FALSE;
-
- return TRUE;
-}
-
-/* Alpha NetWare does not use the high bit to determine whether a
- public symbol is in the code segment or the data segment. Instead,
- it just uses the address. The set_public_section and
- get_public_offset routines override the default code which uses the
- high bit. */
-
-/* Set the section for a public symbol. */
-
-static bfd_boolean
-nlm_alpha_set_public_section (bfd * abfd, nlmNAME (symbol_type) * sym)
-{
- asection *code_sec, *data_sec;
-
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- if (sym->symbol.value < code_sec->size)
- {
- sym->symbol.section = code_sec;
- sym->symbol.flags |= BSF_FUNCTION;
- }
- else
- {
- sym->symbol.section = data_sec;
- sym->symbol.value -= code_sec->size;
- /* The data segment had better be aligned. */
- BFD_ASSERT ((code_sec->size & 0xf) == 0);
- }
- return TRUE;
-}
-
-/* Get the offset to write out for a public symbol. */
-
-static bfd_vma
-nlm_alpha_get_public_offset (bfd * abfd ATTRIBUTE_UNUSED, asymbol * sym)
-{
- return bfd_asymbol_value (sym);
-}
-
-/* Write an Alpha NLM external symbol. */
-
-static bfd_boolean
-nlm_alpha_write_external (bfd *abfd,
- bfd_size_type count,
- asymbol *sym,
- struct reloc_and_sec *relocs)
-{
- bfd_size_type i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
- arelent r;
-
- len = strlen (sym->name);
- if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- return FALSE;
-
- bfd_put_32 (abfd, count + 2, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- /* The first two relocs for each external symbol are the .lita
- address and the GP value. */
- r.sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
- r.howto = &nlm32_alpha_nw_howto;
-
- r.address = nlm_alpha_backend_data (abfd)->lita_address;
- r.addend = nlm_alpha_backend_data (abfd)->lita_size + 1;
- if (! nlm_alpha_write_import (abfd, NULL, &r))
- return FALSE;
-
- r.address = nlm_alpha_backend_data (abfd)->gp;
- r.addend = 0;
- if (! nlm_alpha_write_import (abfd, NULL, &r))
- return FALSE;
-
- for (i = 0; i < count; i++)
- if (! nlm_alpha_write_import (abfd, relocs[i].sec, relocs[i].rel))
- return FALSE;
-
- return TRUE;
-}
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_alpha_backend =
-{
- "NetWare Alpha Module \032",
- sizeof (Nlm32_alpha_External_Fixed_Header),
- sizeof (struct nlm32_alpha_external_prefix_header),
- bfd_arch_alpha,
- 0,
- TRUE, /* No uninitialized data permitted by Alpha NetWare. */
- nlm_alpha_backend_object_p,
- nlm_alpha_write_prefix,
- nlm_alpha_read_reloc,
- nlm_alpha_mangle_relocs,
- nlm_alpha_read_import,
- nlm_alpha_write_import,
- nlm_alpha_set_public_section,
- nlm_alpha_get_public_offset,
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_alpha_write_external,
- 0, /* Write_export. */
-};
-
-#define TARGET_LITTLE_NAME "nlm32-alpha"
-#define TARGET_LITTLE_SYM alpha_nlm32_vec
-#define TARGET_BACKEND_DATA & nlm32_alpha_backend
-
-#include "nlm-target.h"
diff --git a/bfd/nlm32-i386.c b/bfd/nlm32-i386.c
deleted file mode 100644
index b8de2b8..0000000
--- a/bfd/nlm32-i386.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/* Support for 32-bit i386 NLM (NetWare Loadable Module)
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-#include "nlm/i386-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_i386_External_Fixed_Header
-
-#include "libnlm.h"
-
-/* Adjust the reloc location by an absolute value. */
-
-static reloc_howto_type nlm_i386_abs_howto =
- HOWTO (0, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "32", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE); /* PR rel_offset. */
-
-/* Adjust the reloc location by a PC relative displacement. */
-
-static reloc_howto_type nlm_i386_pcrel_howto =
- HOWTO (1, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- TRUE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "DISP32", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- TRUE); /* PR rel_offset. */
-
-/* Read a NetWare i386 reloc. */
-
-static bfd_boolean
-nlm_i386_read_reloc (bfd *abfd,
- nlmNAME (symbol_type) *sym,
- asection **secp,
- arelent *rel)
-{
- bfd_byte temp[4];
- bfd_vma val;
- const char *name;
-
- if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- val = bfd_get_32 (abfd, temp);
-
- /* The value is an offset into either the code or data segment.
- This is the location which needs to be adjusted.
-
- If this is a relocation fixup rather than an imported symbol (the
- sym argument is NULL) then the high bit is 0 if the location
- needs to be adjusted by the address of the data segment, or 1 if
- the location needs to be adjusted by the address of the code
- segment. If this is an imported symbol, then the high bit is 0
- if the location is 0 if the location should be adjusted by the
- offset to the symbol, or 1 if the location should adjusted by the
- absolute value of the symbol.
-
- The second most significant bit is 0 if the value is an offset
- into the data segment, or 1 if the value is an offset into the
- code segment.
-
- All this translates fairly easily into a BFD reloc. */
-
- if (sym == NULL)
- {
- if ((val & NLM_HIBIT) == 0)
- name = NLM_INITIALIZED_DATA_NAME;
- else
- {
- name = NLM_CODE_NAME;
- val &=~ NLM_HIBIT;
- }
- rel->sym_ptr_ptr = bfd_get_section_by_name (abfd, name)->symbol_ptr_ptr;
- rel->howto = &nlm_i386_abs_howto;
- }
- else
- {
- /* In this case we do not need to set the sym_ptr_ptr field. */
- rel->sym_ptr_ptr = NULL;
- if ((val & NLM_HIBIT) == 0)
- rel->howto = &nlm_i386_pcrel_howto;
- else
- {
- rel->howto = &nlm_i386_abs_howto;
- val &=~ NLM_HIBIT;
- }
- }
-
- if ((val & (NLM_HIBIT >> 1)) == 0)
- *secp = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- else
- {
- *secp = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- val &=~ (NLM_HIBIT >> 1);
- }
-
- rel->address = val;
- rel->addend = 0;
-
- return TRUE;
-}
-
-/* Write a NetWare i386 reloc. */
-
-static bfd_boolean
-nlm_i386_write_import (bfd * abfd, asection * sec, arelent * rel)
-{
- asymbol *sym;
- bfd_vma val;
- bfd_byte temp[4];
-
- /* NetWare only supports two kinds of relocs. We should check
- special_function here, as well, but at the moment coff-i386
- relocs uses a special_function which does not affect what we do
- here. */
- if (rel->addend != 0
- || rel->howto == NULL
- || rel->howto->rightshift != 0
- || rel->howto->size != 2
- || rel->howto->bitsize != 32
- || rel->howto->bitpos != 0
- || rel->howto->src_mask != 0xffffffff
- || rel->howto->dst_mask != 0xffffffff)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
- }
-
- sym = *rel->sym_ptr_ptr;
-
- /* The value we write out is the offset into the appropriate
- segment. This offset is the section vma, adjusted by the vma of
- the lowest section in that segment, plus the address of the
- relocation. */
- val = bfd_get_section_vma (abfd, sec) + rel->address;
-
- /* The second most significant bit is 0 if the value is an offset
- into the data segment, or 1 if the value is an offset into the
- code segment. */
- if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
- {
- val -= nlm_get_text_low (abfd);
- val |= NLM_HIBIT >> 1;
- }
- else
- val -= nlm_get_data_low (abfd);
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- {
- /* NetWare only supports absolute internal relocs. */
- if (rel->howto->pc_relative)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
- }
-
- /* The high bit is 1 if the reloc is against the code section, 0
- if against the data section. */
- if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
- val |= NLM_HIBIT;
- }
- else
- {
- /* The high bit is 1 if this is an absolute reloc, 0 if it is PC
- relative. */
- if (! rel->howto->pc_relative)
- val |= NLM_HIBIT;
- else
- {
- /* PC relative relocs on NetWare must be pcrel_offset. */
- if (! rel->howto->pcrel_offset)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
- }
- }
- }
-
- bfd_put_32 (abfd, val, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- return TRUE;
-}
-
-/* I want to be able to use objcopy to turn an i386 a.out or COFF file
- into a NetWare i386 module. That means that the relocs from the
- source file have to be mapped into relocs that apply to the target
- file. This function is called by nlm_set_section_contents to give
- it a chance to rework the relocs.
-
- This is actually a fairly general concept. However, this is not a
- general implementation. */
-
-static bfd_boolean
-nlm_i386_mangle_relocs (bfd *abfd,
- asection *sec,
- const void * data,
- bfd_vma offset,
- bfd_size_type count)
-{
- arelent **rel_ptr_ptr, **rel_end;
-
- rel_ptr_ptr = sec->orelocation;
- rel_end = rel_ptr_ptr + sec->reloc_count;
- for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
- {
- arelent *rel;
- asymbol *sym;
- bfd_vma addend;
-
- rel = *rel_ptr_ptr;
- sym = *rel->sym_ptr_ptr;
-
- /* Note that no serious harm will ensue if we fail to change a
- reloc. We will wind up failing in nlm_i386_write_import. */
-
- /* Make sure this reloc is within the data we have. We only 4
- byte relocs here, so we insist on having 4 bytes. */
- if (rel->address < offset
- || rel->address + 4 > offset + count)
- continue;
-
- /* NetWare doesn't support reloc addends, so we get rid of them
- here by simply adding them into the object data. We handle
- the symbol value, if any, the same way. */
- addend = rel->addend + sym->value;
-
- /* The value of a symbol is the offset into the section. If the
- symbol is in the .bss segment, we need to include the size of
- the data segment in the offset as well. Fortunately, we know
- that at this point the size of the data section is in the NLM
- header. */
- if (((bfd_get_section_flags (abfd, bfd_get_section (sym))
- & SEC_LOAD) == 0)
- && ((bfd_get_section_flags (abfd, bfd_get_section (sym))
- & SEC_ALLOC) != 0))
- addend += nlm_fixed_header (abfd)->dataImageSize;
-
- if (addend != 0
- && rel->howto != NULL
- && rel->howto->rightshift == 0
- && rel->howto->size == 2
- && rel->howto->bitsize == 32
- && rel->howto->bitpos == 0
- && rel->howto->src_mask == 0xffffffff
- && rel->howto->dst_mask == 0xffffffff)
- {
- bfd_vma val;
-
- val = bfd_get_32 (abfd, (bfd_byte *) data + rel->address - offset);
- val += addend;
- bfd_put_32 (abfd, val, (bfd_byte *) data + rel->address - offset);
- rel->addend = 0;
- }
-
- /* NetWare uses a reloc with pcrel_offset set. We adjust
- pc_relative relocs accordingly. We are going to change the
- howto field, so we can only do this if the current one is
- compatible. We should check special_function here, but at
- the moment coff-i386 uses a special_function which does not
- affect what we are doing here. */
- if (rel->howto != NULL
- && rel->howto->pc_relative
- && ! rel->howto->pcrel_offset
- && rel->howto->rightshift == 0
- && rel->howto->size == 2
- && rel->howto->bitsize == 32
- && rel->howto->bitpos == 0
- && rel->howto->src_mask == 0xffffffff
- && rel->howto->dst_mask == 0xffffffff)
- {
- bfd_vma val;
-
- /* When pcrel_offset is not set, it means that the negative
- of the address of the memory location is stored in the
- memory location. We must add it back in. */
- val = bfd_get_32 (abfd, (bfd_byte *) data + rel->address - offset);
- val += rel->address;
- bfd_put_32 (abfd, val, (bfd_byte *) data + rel->address - offset);
-
- rel->howto = &nlm_i386_pcrel_howto;
- }
- }
-
- return TRUE;
-}
-
-/* Read a NetWare i386 import record. */
-
-static bfd_boolean
-nlm_i386_read_import (bfd * abfd, nlmNAME (symbol_type) * sym)
-{
- struct nlm_relent *nlm_relocs; /* Relocation records for symbol. */
- bfd_size_type rcount; /* Number of relocs. */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Temporary 32-bit value. */
- unsigned char symlength; /* Length of symbol name. */
- char *name;
-
- if (bfd_bread (& symlength, (bfd_size_type) sizeof (symlength), abfd)
- != sizeof (symlength))
- return FALSE;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
- if (name == NULL)
- return FALSE;
- if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
- return FALSE;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
- rcount = H_GET_32 (abfd, temp);
- nlm_relocs = bfd_alloc (abfd, rcount * sizeof (struct nlm_relent));
- if (!nlm_relocs)
- return FALSE;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (! nlm_i386_read_reloc (abfd, sym, &section, &nlm_relocs -> reloc))
- return FALSE;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
- return TRUE;
-}
-
-/* Write out an external reference. */
-
-static bfd_boolean
-nlm_i386_write_external (bfd *abfd,
- bfd_size_type count,
- asymbol *sym,
- struct reloc_and_sec *relocs)
-{
- unsigned int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-
- len = strlen (sym->name);
- if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- return FALSE;
-
- bfd_put_32 (abfd, count, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- for (i = 0; i < count; i++)
- if (! nlm_i386_write_import (abfd, relocs[i].sec, relocs[i].rel))
- return FALSE;
-
- return TRUE;
-}
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_i386_backend =
-{
- "NetWare Loadable Module\032",
- sizeof (Nlm32_i386_External_Fixed_Header),
- 0, /* Optional_prefix_size. */
- bfd_arch_i386,
- 0,
- FALSE,
- 0, /* Backend_object_p. */
- 0, /* Write_prefix_func. */
- nlm_i386_read_reloc,
- nlm_i386_mangle_relocs,
- nlm_i386_read_import,
- nlm_i386_write_import,
- 0, /* Set_public_section. */
- 0, /* Set_public_offset. */
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_i386_write_external,
- 0, /* Write_export. */
-};
-
-#define TARGET_LITTLE_NAME "nlm32-i386"
-#define TARGET_LITTLE_SYM i386_nlm32_vec
-#define TARGET_BACKEND_DATA & nlm32_i386_backend
-
-#include "nlm-target.h"
diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c
deleted file mode 100644
index 3e3fdef..0000000
--- a/bfd/nlm32-ppc.c
+++ /dev/null
@@ -1,986 +0,0 @@
-/* Support for 32-bit PowerPC NLM (NetWare Loadable Module)
- Copyright (C) 1994-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
-
-/* The format of a PowerPC NLM changed. Define OLDFORMAT to get the
- old format. */
-
-#define ARCH_SIZE 32
-
-#include "nlm/ppc-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_powerpc_External_Fixed_Header
-
-#include "libnlm.h"
-
-#ifdef OLDFORMAT
-
-/* The prefix header is only used in the old format. */
-
-/* PowerPC NLM's have a prefix header before the standard NLM. This
- function reads it in, verifies the version, and seeks the bfd to
- the location before the regular NLM header. */
-
-static bfd_boolean
-nlm_powerpc_backend_object_p (bfd *abfd)
-{
- struct nlm32_powerpc_external_prefix_header s;
-
- if (bfd_bread (& s, (bfd_size_type) sizeof s, abfd) != sizeof s)
- return FALSE;
-
- if (memcmp (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature) != 0
- || H_GET_32 (abfd, s.headerVersion) != NLM32_POWERPC_HEADER_VERSION)
- return FALSE;
-
- return TRUE;
-}
-
-/* Write out the prefix. */
-
-static bfd_boolean
-nlm_powerpc_write_prefix (bfd *abfd)
-{
- struct nlm32_powerpc_external_prefix_header s;
-
- memset (&s, 0, sizeof s);
- memcpy (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature);
- H_PUT_32 (abfd, NLM32_POWERPC_HEADER_VERSION, s.headerVersion);
- H_PUT_32 (abfd, 0, s.origins);
-
- /* FIXME: What should we do about the date? */
-
- if (bfd_bwrite (& s, (bfd_size_type) sizeof s, abfd) != sizeof s)
- return FALSE;
-
- return TRUE;
-}
-
-/* This reloc handling is only applicable to the old format. */
-
-/* How to process the various reloc types. PowerPC NLMs use XCOFF
- reloc types, and I have just copied the XCOFF reloc table here. */
-
-static reloc_howto_type nlm_powerpc_howto_table[] =
-{
- /* Standard 32 bit relocation. */
- HOWTO (0, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_POS", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* 32 bit relocation, but store negative value. */
- HOWTO (1, /* Type. */
- 0, /* Rightshift. */
- -2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_NEG", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* 32 bit PC relative relocation. */
- HOWTO (2, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- TRUE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_REL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* 16 bit TOC relative relocation. */
- HOWTO (3, /* Type. */
- 0, /* Rightshift. */
- 1, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_TOC", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* I don't really know what this is. */
- HOWTO (4, /* Type. */
- 1, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RTB", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* External TOC relative symbol. */
- HOWTO (5, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_GL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Local TOC relative symbol. */
- HOWTO (6, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_TCL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- { 7 },
-
- /* Non modifiable absolute branch. */
- HOWTO (8, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 26, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_BA", /* Name. */
- TRUE, /* Partial_inplace. */
- 0x3fffffc, /* Source mask. */
- 0x3fffffc, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- { 9 },
-
- /* Non modifiable relative branch. */
- HOWTO (0xa, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 26, /* Bitsize. */
- TRUE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_BR", /* Name. */
- TRUE, /* Partial_inplace. */
- 0x3fffffc, /* Source mask. */
- 0x3fffffc, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- { 0xb },
-
- /* Indirect load. */
- HOWTO (0xc, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Load address. */
- HOWTO (0xd, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RLA", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- { 0xe },
-
- /* Non-relocating reference. */
- HOWTO (0xf, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_REF", /* Name. */
- FALSE, /* Partial_inplace. */
- 0, /* Source mask. */
- 0, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- { 0x10 },
- { 0x11 },
-
- /* TOC relative indirect load. */
- HOWTO (0x12, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_TRL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* TOC relative load address. */
- HOWTO (0x13, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_TRLA", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable relative branch. */
- HOWTO (0x14, /* Type. */
- 1, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RRTBI", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable absolute branch. */
- HOWTO (0x15, /* Type. */
- 1, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RRTBA", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable call absolute indirect. */
- HOWTO (0x16, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_CAI", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable call relative. */
- HOWTO (0x17, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_REL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable branch absolute. */
- HOWTO (0x18, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RBA", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable branch absolute. */
- HOWTO (0x19, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_RBAC", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable branch relative. */
- HOWTO (0x1a, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 26, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_signed, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_REL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE), /* PC rel offset. */
-
- /* Modifiable branch absolute. */
- HOWTO (0x1b, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 16, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "R_REL", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffff, /* Source mask. */
- 0xffff, /* Dest mask. */
- FALSE) /* PC rel offset. */
-};
-
-#define HOWTO_COUNT (sizeof nlm_powerpc_howto_table \
- / sizeof nlm_powerpc_howto_table[0])
-
-/* Read a PowerPC NLM reloc. */
-
-static bfd_boolean
-nlm_powerpc_read_reloc (bfd *abfd,
- nlmNAME (symbol_type) *sym,
- asection **secp,
- arelent *rel)
-{
- struct nlm32_powerpc_external_reloc ext;
- bfd_vma l_vaddr;
- unsigned long l_symndx;
- int l_rtype;
- int l_rsecnm;
- asection *code_sec, *data_sec, *bss_sec;
-
- /* Read the reloc from the file. */
- if (bfd_bread (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
- return FALSE;
-
- /* Swap in the fields. */
- l_vaddr = H_GET_32 (abfd, ext.l_vaddr);
- l_symndx = H_GET_32 (abfd, ext.l_symndx);
- l_rtype = H_GET_16 (abfd, ext.l_rtype);
- l_rsecnm = H_GET_16 (abfd, ext.l_rsecnm);
-
- /* Get the sections now, for convenience. */
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
-
- /* Work out the arelent fields. */
- if (sym != NULL)
- /* This is an import. sym_ptr_ptr is filled in by
- nlm_canonicalize_reloc. */
- rel->sym_ptr_ptr = NULL;
- else
- {
- asection *sec;
-
- if (l_symndx == 0)
- sec = code_sec;
- else if (l_symndx == 1)
- sec = data_sec;
- else if (l_symndx == 2)
- sec = bss_sec;
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
- rel->sym_ptr_ptr = sec->symbol_ptr_ptr;
- }
-
- rel->addend = 0;
-
- BFD_ASSERT ((l_rtype & 0xff) < HOWTO_COUNT);
-
- rel->howto = nlm_powerpc_howto_table + (l_rtype & 0xff);
-
- BFD_ASSERT (rel->howto->name != NULL
- && ((l_rtype & 0x8000) != 0
- ? (rel->howto->complain_on_overflow
- == complain_overflow_signed)
- : (rel->howto->complain_on_overflow
- == complain_overflow_bitfield))
- && ((l_rtype >> 8) & 0x1f) == rel->howto->bitsize - 1);
-
- if (l_rsecnm == 0)
- *secp = code_sec;
- else if (l_rsecnm == 1)
- {
- *secp = data_sec;
- l_vaddr -= code_sec->size;
- }
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
- rel->address = l_vaddr;
-
- return TRUE;
-}
-
-#else /* not OLDFORMAT */
-
-/* There is only one type of reloc in a PowerPC NLM. */
-
-static reloc_howto_type nlm_powerpc_howto =
- HOWTO (0, /* Type. */
- 0, /* Rightshift. */
- 2, /* Size (0 = byte, 1 = short, 2 = long). */
- 32, /* Bitsize. */
- FALSE, /* PC relative. */
- 0, /* Bitpos. */
- complain_overflow_bitfield, /* Complain_on_overflow. */
- 0, /* Special_function. */
- "32", /* Name. */
- TRUE, /* Partial_inplace. */
- 0xffffffff, /* Source mask. */
- 0xffffffff, /* Dest mask. */
- FALSE); /* PC rel_offset. */
-
-/* Read a PowerPC NLM reloc. */
-
-static bfd_boolean
-nlm_powerpc_read_reloc (bfd *abfd,
- nlmNAME (symbol_type) *sym,
- asection **secp,
- arelent *rel)
-{
- bfd_byte temp[4];
- bfd_vma val;
- const char *name;
-
- if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- val = bfd_get_32 (abfd, temp);
-
- /* The value is a word offset into either the code or data segment.
- This is the location which needs to be adjusted.
-
- The high bit is 0 if the value is an offset into the data
- segment, or 1 if the value is an offset into the text segment.
-
- If this is a relocation fixup rather than an imported symbol (the
- sym argument is NULL), then the second most significant bit is 0
- if the address of the data segment should be added to the
- location addressed by the value, or 1 if the address of the text
- segment should be added.
-
- If this is an imported symbol, the second most significant bit is
- not used and must be 0. */
-
- if ((val & NLM_HIBIT) == 0)
- name = NLM_INITIALIZED_DATA_NAME;
- else
- {
- name = NLM_CODE_NAME;
- val &=~ NLM_HIBIT;
- }
- *secp = bfd_get_section_by_name (abfd, name);
-
- if (sym == NULL)
- {
- if ((val & (NLM_HIBIT >> 1)) == 0)
- name = NLM_INITIALIZED_DATA_NAME;
- else
- {
- name = NLM_CODE_NAME;
- val &=~ (NLM_HIBIT >> 1);
- }
- rel->sym_ptr_ptr = bfd_get_section_by_name (abfd, name)->symbol_ptr_ptr;
- }
-
- rel->howto = & nlm_powerpc_howto;
- rel->address = val << 2;
- rel->addend = 0;
-
- return TRUE;
-}
-
-#endif /* not OLDFORMAT */
-
-/* Mangle PowerPC NLM relocs for output. */
-
-static bfd_boolean
-nlm_powerpc_mangle_relocs (bfd *abfd ATTRIBUTE_UNUSED,
- asection *sec ATTRIBUTE_UNUSED,
- const void * data ATTRIBUTE_UNUSED,
- bfd_vma offset ATTRIBUTE_UNUSED,
- bfd_size_type count ATTRIBUTE_UNUSED)
-{
- return TRUE;
-}
-
-/* Read a PowerPC NLM import record */
-
-static bfd_boolean
-nlm_powerpc_read_import (bfd * abfd, nlmNAME (symbol_type) * sym)
-{
- struct nlm_relent *nlm_relocs; /* Relocation records for symbol. */
- bfd_size_type rcount; /* Number of relocs. */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Temporary 32-bit value. */
- unsigned char symlength; /* Length of symbol name. */
- char *name;
-
- if (bfd_bread (& symlength, (bfd_size_type) sizeof (symlength), abfd)
- != sizeof (symlength))
- return FALSE;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
- if (name == NULL)
- return FALSE;
- if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
- return FALSE;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd)
- != sizeof (temp))
- return FALSE;
- rcount = H_GET_32 (abfd, temp);
- nlm_relocs = bfd_alloc (abfd, rcount * sizeof (struct nlm_relent));
- if (nlm_relocs == NULL)
- return FALSE;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (! nlm_powerpc_read_reloc (abfd, sym, &section, &nlm_relocs -> reloc))
- return FALSE;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
- return TRUE;
-}
-
-#ifndef OLDFORMAT
-
-/* Write a PowerPC NLM reloc. */
-
-static bfd_boolean
-nlm_powerpc_write_import (bfd * abfd, asection * sec, arelent * rel)
-{
- asymbol *sym;
- bfd_vma val;
- bfd_byte temp[4];
-
- /* PowerPC NetWare only supports one kind of reloc. */
- if (rel->addend != 0
- || rel->howto == NULL
- || rel->howto->rightshift != 0
- || rel->howto->size != 2
- || rel->howto->bitsize != 32
- || rel->howto->bitpos != 0
- || rel->howto->pc_relative
- || (rel->howto->src_mask != 0xffffffff && rel->addend != 0)
- || rel->howto->dst_mask != 0xffffffff)
- {
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
- }
-
- sym = *rel->sym_ptr_ptr;
-
- /* The value we write out is the offset into the appropriate
- segment, rightshifted by two. This offset is the section vma,
- adjusted by the vma of the lowest section in that segment, plus
- the address of the relocation. */
- val = bfd_get_section_vma (abfd, sec) + rel->address;
- if ((val & 3) != 0)
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
- val >>= 2;
-
- /* The high bit is 0 if the reloc is in the data section, or 1 if
- the reloc is in the code section. */
- if (bfd_get_section_flags (abfd, sec) & SEC_DATA)
- val -= nlm_get_data_low (abfd);
- else
- {
- val -= nlm_get_text_low (abfd);
- val |= NLM_HIBIT;
- }
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- {
- /* This is an internal relocation fixup. The second most
- significant bit is 0 if this is a reloc against the data
- segment, or 1 if it is a reloc against the text segment. */
- if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
- val |= NLM_HIBIT >> 1;
- }
-
- bfd_put_32 (abfd, val, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- return TRUE;
-}
-
-#else /* OLDFORMAT */
-
-/* This is used for the reloc handling in the old format. */
-
-/* Write a PowerPC NLM reloc. */
-
-static bfd_boolean
-nlm_powerpc_write_reloc (bfd *abfd,
- asection *sec,
- arelent *rel,
- int indx)
-{
- struct nlm32_powerpc_external_reloc ext;
- asection *code_sec, *data_sec, *bss_sec;
- asymbol *sym;
- asection *symsec;
- unsigned long l_symndx;
- int l_rtype;
- int l_rsecnm;
- reloc_howto_type *howto;
- bfd_size_type address;
-
- /* Get the sections now, for convenience. */
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
-
- sym = *rel->sym_ptr_ptr;
- symsec = bfd_get_section (sym);
- if (indx != -1)
- {
- BFD_ASSERT (bfd_is_und_section (symsec));
- l_symndx = indx + 3;
- }
- else
- {
- if (symsec == code_sec)
- l_symndx = 0;
- else if (symsec == data_sec)
- l_symndx = 1;
- else if (symsec == bss_sec)
- l_symndx = 2;
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
- }
-
- H_PUT_32 (abfd, l_symndx, ext.l_symndx);
-
- for (howto = nlm_powerpc_howto_table;
- howto < nlm_powerpc_howto_table + HOWTO_COUNT;
- howto++)
- {
- if (howto->rightshift == rel->howto->rightshift
- && howto->size == rel->howto->size
- && howto->bitsize == rel->howto->bitsize
- && howto->pc_relative == rel->howto->pc_relative
- && howto->bitpos == rel->howto->bitpos
- && (howto->partial_inplace == rel->howto->partial_inplace
- || (! rel->howto->partial_inplace
- && rel->addend == 0))
- && (howto->src_mask == rel->howto->src_mask
- || (rel->howto->src_mask == 0
- && rel->addend == 0))
- && howto->dst_mask == rel->howto->dst_mask
- && howto->pcrel_offset == rel->howto->pcrel_offset)
- break;
- }
- if (howto >= nlm_powerpc_howto_table + HOWTO_COUNT)
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
- l_rtype = howto->type;
- if (howto->complain_on_overflow == complain_overflow_signed)
- l_rtype |= 0x8000;
- l_rtype |= (howto->bitsize - 1) << 8;
- H_PUT_16 (abfd, l_rtype, ext.l_rtype);
-
- address = rel->address;
-
- if (sec == code_sec)
- l_rsecnm = 0;
- else if (sec == data_sec)
- {
- l_rsecnm = 1;
- address += code_sec->size;
- }
- else
- {
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
-
- H_PUT_16 (abfd, l_rsecnm, ext.l_rsecnm);
- H_PUT_32 (abfd, address, ext.l_vaddr);
-
- if (bfd_bwrite (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
- return FALSE;
-
- return TRUE;
-}
-
-/* Write a PowerPC NLM import. */
-
-static bfd_boolean
-nlm_powerpc_write_import (bfd * abfd, asection * sec, arelent * rel)
-{
- return nlm_powerpc_write_reloc (abfd, sec, rel, -1);
-}
-
-#endif /* OLDFORMAT */
-
-/* Write a PowerPC NLM external symbol. This routine keeps a static
- count of the symbol index. FIXME: I don't know if this is
- necessary, and the index never gets reset. */
-
-static bfd_boolean
-nlm_powerpc_write_external (bfd *abfd,
- bfd_size_type count,
- asymbol *sym,
- struct reloc_and_sec *relocs)
-{
- unsigned int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-#ifdef OLDFORMAT
- static int indx;
-#endif
-
- len = strlen (sym->name);
- if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- return FALSE;
-
- bfd_put_32 (abfd, count, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- for (i = 0; i < count; i++)
- {
-#ifndef OLDFORMAT
- if (! nlm_powerpc_write_import (abfd, relocs[i].sec, relocs[i].rel))
- return FALSE;
-#else
- if (! nlm_powerpc_write_reloc (abfd, relocs[i].sec,
- relocs[i].rel, indx))
- return FALSE;
-#endif
- }
-
-#ifdef OLDFORMAT
- ++indx;
-#endif
-
- return TRUE;
-}
-
-#ifndef OLDFORMAT
-
-/* PowerPC Netware uses a word offset, not a byte offset, for public
- symbols. */
-
-/* Set the section for a public symbol. */
-
-static bfd_boolean
-nlm_powerpc_set_public_section (bfd *abfd, nlmNAME (symbol_type) *sym)
-{
- if (sym->symbol.value & NLM_HIBIT)
- {
- sym->symbol.value &= ~NLM_HIBIT;
- 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);
-
- sym->symbol.value <<= 2;
-
- return TRUE;
-}
-
-/* Get the offset to write out for a public symbol. */
-
-static bfd_vma
-nlm_powerpc_get_public_offset (bfd *abfd, asymbol *sym)
-{
- bfd_vma offset;
- asection *sec;
-
- offset = bfd_asymbol_value (sym);
- sec = bfd_get_section (sym);
- if (sec->flags & SEC_CODE)
- {
- offset -= nlm_get_text_low (abfd);
- offset |= NLM_HIBIT;
- }
- else if (sec->flags & (SEC_DATA | SEC_ALLOC))
- {
- /* SEC_ALLOC is for the .bss section. */
- offset -= nlm_get_data_low (abfd);
- }
- else
- {
- /* We can't handle an exported symbol that is not in the code or
- data segment. */
- bfd_set_error (bfd_error_invalid_operation);
- /* FIXME: No way to return error. */
- abort ();
- }
-
- return offset;
-}
-
-#endif /* ! defined (OLDFORMAT) */
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_powerpc_backend =
-{
- "NetWare PowerPC Module \032",
- sizeof (Nlm32_powerpc_External_Fixed_Header),
-#ifndef OLDFORMAT
- 0, /* Optional_prefix_size. */
-#else
- sizeof (struct nlm32_powerpc_external_prefix_header),
-#endif
- bfd_arch_powerpc,
- 0,
- FALSE,
-#ifndef OLDFORMAT
- 0, /* Backend_object_p. */
- 0, /* Write_prefix. */
-#else
- nlm_powerpc_backend_object_p,
- nlm_powerpc_write_prefix,
-#endif
- nlm_powerpc_read_reloc,
- nlm_powerpc_mangle_relocs,
- nlm_powerpc_read_import,
- nlm_powerpc_write_import,
-#ifndef OLDFORMAT
- nlm_powerpc_set_public_section,
- nlm_powerpc_get_public_offset,
-#else
- 0, /* Set_public_section. */
- 0, /* Get_public_offset. */
-#endif
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_powerpc_write_external,
- 0, /* Write_export. */
-};
-
-#define TARGET_BIG_NAME "nlm32-powerpc"
-#define TARGET_BIG_SYM powerpc_nlm32_vec
-#define TARGET_BACKEND_DATA & nlm32_powerpc_backend
-
-#include "nlm-target.h"
diff --git a/bfd/nlm32-sparc.c b/bfd/nlm32-sparc.c
deleted file mode 100644
index 32ec5c4..0000000
--- a/bfd/nlm32-sparc.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/* Support for 32-bit SPARC NLM (NetWare Loadable Module)
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
-
-#define ARCH_SIZE 32
-
-#include "nlm/sparc32-ext.h"
-#define Nlm_External_Fixed_Header Nlm32_sparc_External_Fixed_Header
-
-#include "libnlm.h"
-
-enum reloc_type
-{
- R_SPARC_NONE = 0,
- R_SPARC_8, R_SPARC_16, R_SPARC_32,
- R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
- R_SPARC_WDISP30, R_SPARC_WDISP22,
- R_SPARC_HI22, R_SPARC_22,
- R_SPARC_13, R_SPARC_LO10,
- R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
- R_SPARC_PC10, R_SPARC_PC22,
- R_SPARC_WPLT30,
- R_SPARC_COPY,
- R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
- R_SPARC_RELATIVE,
- R_SPARC_UA32,
- R_SPARC_max
-};
-
-static reloc_howto_type nlm32_sparc_howto_table[] =
-{
- HOWTO (R_SPARC_NONE, 0,3, 0,FALSE,0,complain_overflow_dont, 0,"R_SPARC_NONE", FALSE,0,0x00000000,TRUE),
- HOWTO (R_SPARC_8, 0,0, 8,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_8", FALSE,0,0x000000ff,TRUE),
- HOWTO (R_SPARC_16, 0,1,16,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_16", FALSE,0,0x0000ffff,TRUE),
- HOWTO (R_SPARC_32, 0,2,32,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_32", FALSE,0,0xffffffff,TRUE),
- HOWTO (R_SPARC_DISP8, 0,0, 8,TRUE, 0,complain_overflow_signed, 0,"R_SPARC_DISP8", FALSE,0,0x000000ff,TRUE),
- HOWTO (R_SPARC_DISP16, 0,1,16,TRUE, 0,complain_overflow_signed, 0,"R_SPARC_DISP16", FALSE,0,0x0000ffff,TRUE),
- HOWTO (R_SPARC_DISP32, 0,2,32,TRUE, 0,complain_overflow_signed, 0,"R_SPARC_DISP32", FALSE,0,0x00ffffff,TRUE),
- HOWTO (R_SPARC_WDISP30, 2,2,30,TRUE, 0,complain_overflow_signed, 0,"R_SPARC_WDISP30", FALSE,0,0x3fffffff,TRUE),
- HOWTO (R_SPARC_WDISP22, 2,2,22,TRUE, 0,complain_overflow_signed, 0,"R_SPARC_WDISP22", FALSE,0,0x003fffff,TRUE),
- HOWTO (R_SPARC_HI22, 10,2,22,FALSE,0,complain_overflow_dont, 0,"R_SPARC_HI22", FALSE,0,0x003fffff,TRUE),
- HOWTO (R_SPARC_22, 0,2,22,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_22", FALSE,0,0x003fffff,TRUE),
- HOWTO (R_SPARC_13, 0,2,13,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_13", FALSE,0,0x00001fff,TRUE),
- HOWTO (R_SPARC_LO10, 0,2,10,FALSE,0,complain_overflow_dont, 0,"R_SPARC_LO10", FALSE,0,0x000003ff,TRUE),
- HOWTO (R_SPARC_GOT10, 0,2,10,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_GOT10", FALSE,0,0x000003ff,TRUE),
- HOWTO (R_SPARC_GOT13, 0,2,13,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_GOT13", FALSE,0,0x00001fff,TRUE),
- HOWTO (R_SPARC_GOT22, 10,2,22,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_GOT22", FALSE,0,0x003fffff,TRUE),
- HOWTO (R_SPARC_PC10, 0,2,10,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_PC10", FALSE,0,0x000003ff,TRUE),
- HOWTO (R_SPARC_PC22, 0,2,22,FALSE,0,complain_overflow_bitfield,0,"R_SPARC_PC22", FALSE,0,0x003fffff,TRUE),
- HOWTO (R_SPARC_WPLT30, 0,0,00,FALSE,0,complain_overflow_dont, 0,"R_SPARC_WPLT30", FALSE,0,0x00000000,TRUE),
- HOWTO (R_SPARC_COPY, 0,0,00,FALSE,0,complain_overflow_dont, 0,"R_SPARC_COPY", FALSE,0,0x00000000,TRUE),
- HOWTO (R_SPARC_GLOB_DAT,0,0,00,FALSE,0,complain_overflow_dont, 0,"R_SPARC_GLOB_DAT",FALSE,0,0x00000000,TRUE),
- HOWTO (R_SPARC_JMP_SLOT,0,0,00,FALSE,0,complain_overflow_dont, 0,"R_SPARC_JMP_SLOT",FALSE,0,0x00000000,TRUE),
- HOWTO (R_SPARC_RELATIVE,0,0,00,FALSE,0,complain_overflow_dont, 0,"R_SPARC_RELATIVE",FALSE,0,0x00000000,TRUE),
- HOWTO (R_SPARC_UA32, 0,0,00,FALSE,0,complain_overflow_dont, 0,"R_SPARC_UA32", FALSE,0,0x00000000,TRUE),
-};
-
-/* Read a NetWare sparc reloc. */
-
-struct nlm32_sparc_reloc_ext
-{
- unsigned char offset[4];
- unsigned char addend[4];
- unsigned char type[1];
- unsigned char pad1[3];
-};
-
-static bfd_boolean
-nlm_sparc_read_reloc (bfd *abfd,
- nlmNAME (symbol_type) *sym ATTRIBUTE_UNUSED,
- asection **secp,
- arelent *rel)
-{
- bfd_vma val, addend;
- unsigned int howto_index;
- unsigned int type;
- struct nlm32_sparc_reloc_ext tmp_reloc;
- asection *code_sec;
-
- if (bfd_bread (&tmp_reloc, (bfd_size_type) 12, abfd) != 12)
- return FALSE;
-
- code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- *secp = code_sec;
-
- val = bfd_get_32 (abfd, tmp_reloc.offset);
- addend = bfd_get_32 (abfd, tmp_reloc.addend);
- type = bfd_get_8 (abfd, tmp_reloc.type);
-
- rel->address = val;
- rel->addend = addend;
- rel->howto = NULL;
-
- for (howto_index = 0;
- howto_index < sizeof (nlm32_sparc_howto_table) / sizeof (reloc_howto_type);
- howto_index++)
- if (nlm32_sparc_howto_table[howto_index].type == type)
- {
- rel->howto = &nlm32_sparc_howto_table[howto_index];
- break;
- }
-
-#ifdef DEBUG
- fprintf (stderr, "%s: address = %08lx, addend = %08lx, type = %u, howto = %p\n",
- __FUNCTION__, (unsigned long) rel->address,
- (unsigned long) rel->addend, type, rel->howto);
-#endif
- return TRUE;
-
-}
-
-/* Write a NetWare sparc reloc. */
-
-static bfd_boolean
-nlm_sparc_write_reloc (bfd * abfd, asection * sec, arelent * rel)
-{
- bfd_vma val;
- struct nlm32_sparc_reloc_ext tmp_reloc;
- unsigned int howto_index;
- int type = -1;
- reloc_howto_type *tmp;
-
- for (howto_index = 0;
- howto_index < sizeof (nlm32_sparc_howto_table) / sizeof (reloc_howto_type);
- howto_index++)
- {
- tmp = &nlm32_sparc_howto_table[howto_index];
-
- if (tmp->rightshift == rel->howto->rightshift
- && tmp->size == rel->howto->size
- && tmp->bitsize == rel->howto->bitsize
- && tmp->pc_relative == rel->howto->pc_relative
- && tmp->bitpos == rel->howto->bitpos
- && tmp->src_mask == rel->howto->src_mask
- && tmp->dst_mask == rel->howto->dst_mask)
- {
- type = tmp->type;
- break;
- }
- }
- if (type == -1)
- abort ();
-
- /* Netware wants a list of relocs for each address.
- Format is:
- long offset
- long addend
- char type
- That should be it. */
-
- /* The value we write out is the offset into the appropriate
- segment. This offset is the section vma, adjusted by the vma of
- the lowest section in that segment, plus the address of the
- relocation. */
- val = bfd_get_section_vma (abfd, sec) + rel->address;
-
-#ifdef DEBUG
- fprintf (stderr, "%s: val = %08lx, addend = %08lx, type = %u\n",
- __FUNCTION__, (unsigned long) val, (unsigned long) rel->addend,
- rel->howto->type);
-#endif
- bfd_put_32 (abfd, val, tmp_reloc.offset);
- bfd_put_32 (abfd, rel->addend, tmp_reloc.addend);
- bfd_put_8 (abfd, (short) (rel->howto->type), tmp_reloc.type);
-
- if (bfd_bwrite (&tmp_reloc, (bfd_size_type) 12, abfd) != 12)
- return FALSE;
-
- return TRUE;
-}
-
-/* Mangle relocs for SPARC NetWare. We can just use the standard
- SPARC relocs. */
-
-static bfd_boolean
-nlm_sparc_mangle_relocs (bfd *abfd ATTRIBUTE_UNUSED,
- asection *sec ATTRIBUTE_UNUSED,
- const void * data ATTRIBUTE_UNUSED,
- bfd_vma offset ATTRIBUTE_UNUSED,
- bfd_size_type count ATTRIBUTE_UNUSED)
-{
- return TRUE;
-}
-
-/* Read a NetWare sparc import record. */
-
-static bfd_boolean
-nlm_sparc_read_import (bfd *abfd, nlmNAME (symbol_type) *sym)
-{
- struct nlm_relent *nlm_relocs; /* Relocation records for symbol. */
- bfd_size_type rcount; /* Number of relocs. */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Temporary 32-bit value. */
- unsigned char symlength; /* Length of symbol name. */
- char *name;
-
- /* First, read in the number of relocation
- entries for this symbol. */
- if (bfd_bread (temp, (bfd_size_type) 4, abfd) != 4)
- return FALSE;
-
- rcount = bfd_get_32 (abfd, temp);
-
- /* Next, read in the length of the symbol. */
- if (bfd_bread (& symlength, (bfd_size_type) sizeof (symlength), abfd)
- != sizeof (symlength))
- return FALSE;
- sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
- if (name == NULL)
- return FALSE;
-
- /* Then read in the symbol. */
- if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
- return FALSE;
- name[symlength] = '\0';
- sym -> symbol.name = name;
- sym -> symbol.flags = 0;
- sym -> symbol.value = 0;
- sym -> symbol.section = bfd_und_section_ptr;
-
- /* Next, start reading in the relocs. */
- nlm_relocs = bfd_alloc (abfd, rcount * sizeof (struct nlm_relent));
- if (!nlm_relocs)
- return FALSE;
- sym -> relocs = nlm_relocs;
- sym -> rcnt = 0;
- while (sym -> rcnt < rcount)
- {
- asection *section;
-
- if (! nlm_sparc_read_reloc (abfd, sym, &section, &nlm_relocs -> reloc))
- return FALSE;
- nlm_relocs -> section = section;
- nlm_relocs++;
- sym -> rcnt++;
- }
-
- return TRUE;
-}
-
-static bfd_boolean
-nlm_sparc_write_import (bfd * abfd, asection * sec, arelent * rel)
-{
- char temp[4];
- asection *code, *data, *bss, *symsec;
- bfd_vma base;
-
- code = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- data = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- bss = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
- symsec = (*rel->sym_ptr_ptr)->section;
-
- if (symsec == code)
- base = 0;
- else if (symsec == data)
- base = code->size;
- else if (symsec == bss)
- base = code->size + data->size;
- else
- base = 0;
-
-#ifdef DEBUG
- fprintf (stderr, "%s: <%lx, 1>\n\t",
- __FUNCTION__, (unsigned long) (base + (*rel->sym_ptr_ptr)->value));
-#endif
- bfd_put_32 (abfd, base + (*rel->sym_ptr_ptr)->value, temp);
- if (bfd_bwrite (temp, (bfd_size_type) 4, abfd) != 4)
- return FALSE;
- bfd_put_32 (abfd, (bfd_vma) 1, temp);
- if (bfd_bwrite (temp, (bfd_size_type) 4, abfd) != 4)
- return FALSE;
- if (! nlm_sparc_write_reloc (abfd, sec, rel))
- return FALSE;
- return TRUE;
-}
-
-/* Write out an external reference. */
-
-static bfd_boolean
-nlm_sparc_write_external (bfd *abfd,
- bfd_size_type count,
- asymbol *sym,
- struct reloc_and_sec *relocs)
-{
- unsigned int i;
- bfd_byte len;
- unsigned char temp[NLM_TARGET_LONG_SIZE];
-
- bfd_put_32 (abfd, count, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
- return FALSE;
-
- len = strlen (sym->name);
- if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- return FALSE;
-
- for (i = 0; i < count; i++)
- if (! nlm_sparc_write_reloc (abfd, relocs[i].sec, relocs[i].rel))
- return FALSE;
-
- return TRUE;
-}
-
-static bfd_boolean
-nlm_sparc_write_export (bfd * abfd, asymbol * sym, bfd_vma value)
-{
- bfd_byte len;
- bfd_byte temp[4];
-
-#ifdef DEBUG
- fprintf (stderr, "%s: <%lx, %u, %s>\n",
- __FUNCTION__, (unsigned long) value, strlen (sym->name), sym->name);
-#endif
- bfd_put_32 (abfd, value, temp);
- len = strlen (sym->name);
-
- if (bfd_bwrite (temp, (bfd_size_type) 4, abfd) != 4
- || bfd_bwrite (&len, (bfd_size_type) 1, abfd) != 1
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- return FALSE;
-
- return TRUE;
-}
-
-#undef nlm_swap_fixed_header_in
-#undef nlm_swap_fixed_header_out
-
-#include "nlmswap.h"
-
-static const struct nlm_backend_data nlm32_sparc_backend =
-{
- "NetWare SPARC Module \032",
- sizeof (Nlm32_sparc_External_Fixed_Header),
- 0, /* Optional_prefix_size. */
- bfd_arch_sparc,
- 0,
- FALSE,
- 0, /* Backend_object_p. */
- 0, /* Write_prefix_func. */
- nlm_sparc_read_reloc,
- nlm_sparc_mangle_relocs,
- nlm_sparc_read_import,
- nlm_sparc_write_import,
- 0, /* Set_public_section. */
- 0, /* Get_public_offset. */
- nlm_swap_fixed_header_in,
- nlm_swap_fixed_header_out,
- nlm_sparc_write_external,
- nlm_sparc_write_export
-};
-
-#define TARGET_BIG_NAME "nlm32-sparc"
-#define TARGET_BIG_SYM sparc_nlm32_vec
-#define TARGET_BACKEND_DATA & nlm32_sparc_backend
-
-#include "nlm-target.h"
diff --git a/bfd/nlm32.c b/bfd/nlm32.c
deleted file mode 100644
index 7cc1592..0000000
--- a/bfd/nlm32.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* NLM (NetWare Loadable Module) 32-bit executable support for BFD.
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#define ARCH_SIZE 32
-#include "nlmcode.h"
diff --git a/bfd/nlm64.c b/bfd/nlm64.c
deleted file mode 100644
index d8f1800..0000000
--- a/bfd/nlm64.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* NLM (NetWare Loadable Module) 64-bit executable support for BFD.
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#define ARCH_SIZE 64
-#include "nlmcode.h"
diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h
deleted file mode 100644
index ac7abaf..0000000
--- a/bfd/nlmcode.h
+++ /dev/null
@@ -1,1982 +0,0 @@
-/* NLM (NetWare Loadable Module) executable support for BFD.
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-#include "sysdep.h"
-#include "bfd.h"
-#include "libbfd.h"
-#include "libnlm.h"
-
-/* The functions in this file do not use the names they appear to use.
- This file is actually compiled multiple times, once for each size
- of NLM target we are using. At each size we use a different name,
- constructed by the macro nlmNAME. For example, the function which
- is named nlm_symbol_type below is actually named nlm32_symbol_type
- in the final executable. */
-
-#define Nlm_External_Fixed_Header NlmNAME (External_Fixed_Header)
-#define Nlm_External_Version_Header NlmNAME (External_Version_Header)
-#define Nlm_External_Copyright_Header NlmNAME (External_Copyright_Header)
-#define Nlm_External_Extended_Header NlmNAME (External_Extended_Header)
-#define Nlm_External_Custom_Header NlmNAME (External_Custom_Header)
-#define Nlm_External_Cygnus_Ext_Header NlmNAME (External_Cygnus_Ext_Header)
-
-#define nlm_symbol_type nlmNAME (symbol_type)
-#define nlm_get_symtab_upper_bound nlmNAME (get_symtab_upper_bound)
-#define nlm_canonicalize_symtab nlmNAME (canonicalize_symtab)
-#define nlm_make_empty_symbol nlmNAME (make_empty_symbol)
-#define nlm_print_symbol nlmNAME (print_symbol)
-#define nlm_get_symbol_info nlmNAME (get_symbol_info)
-#define nlm_get_reloc_upper_bound nlmNAME (get_reloc_upper_bound)
-#define nlm_canonicalize_reloc nlmNAME (canonicalize_reloc)
-#define nlm_object_p nlmNAME (object_p)
-#define nlm_set_section_contents nlmNAME (set_section_contents)
-#define nlm_write_object_contents nlmNAME (write_object_contents)
-
-#define nlm_swap_fixed_header_in(abfd,src,dst) \
- (nlm_swap_fixed_header_in_func (abfd)) (abfd, src, dst)
-#define nlm_swap_fixed_header_out(abfd,src,dst) \
- (nlm_swap_fixed_header_out_func (abfd)) (abfd, src, dst)
-
-/* 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 H_PUT_64
-#define get_word H_GET_64
-#endif
-#if ARCH_SIZE == 32
-#define put_word H_PUT_32
-#define get_word H_GET_32
-#endif
-
-/* 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 bfd_boolean
-nlm_swap_variable_header_in (bfd *abfd)
-{
- unsigned char temp[NLM_TARGET_LONG_SIZE];
- bfd_size_type amt;
-
- /* Read the description length and text members. */
- amt = sizeof (nlm_variable_header (abfd)->descriptionLength);
- if (bfd_bread ((void *) &nlm_variable_header (abfd)->descriptionLength,
- amt, abfd) != amt)
- return FALSE;
- amt = nlm_variable_header (abfd)->descriptionLength + 1;
- if (bfd_bread ((void *) nlm_variable_header (abfd)->descriptionText,
- amt, abfd) != amt)
- return FALSE;
-
- /* Read and convert the stackSize field. */
- amt = sizeof (temp);
- if (bfd_bread ((void *) temp, amt, abfd) != amt)
- return FALSE;
- nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp);
-
- /* Read and convert the reserved field. */
- amt = sizeof (temp);
- if (bfd_bread ((void *) temp, amt, abfd) != amt)
- return FALSE;
- nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp);
-
- /* Read the oldThreadName field. This field is a fixed length string. */
- amt = sizeof (nlm_variable_header (abfd)->oldThreadName);
- if (bfd_bread ((void *) nlm_variable_header (abfd)->oldThreadName,
- amt, abfd) != amt)
- return FALSE;
-
- /* Read the screen name length and text members. */
- amt = sizeof (nlm_variable_header (abfd)->screenNameLength);
- if (bfd_bread ((void *) & nlm_variable_header (abfd)->screenNameLength,
- amt, abfd) != amt)
- return FALSE;
- amt = nlm_variable_header (abfd)->screenNameLength + 1;
- if (bfd_bread ((void *) nlm_variable_header (abfd)->screenName,
- amt, abfd) != amt)
- return FALSE;
-
- /* Read the thread name length and text members. */
- amt = sizeof (nlm_variable_header (abfd)->threadNameLength);
- if (bfd_bread ((void *) & nlm_variable_header (abfd)->threadNameLength,
- amt, abfd) != amt)
- return FALSE;
- amt = nlm_variable_header (abfd)->threadNameLength + 1;
- if (bfd_bread ((void *) nlm_variable_header (abfd)->threadName,
- amt, abfd) != amt)
- return FALSE;
- return TRUE;
-}
-
-/* Add a section to the bfd. */
-
-static bfd_boolean
-add_bfd_section (bfd *abfd,
- char *name,
- file_ptr offset,
- bfd_size_type size,
- flagword flags)
-{
- asection *newsect;
-
- newsect = bfd_make_section_with_flags (abfd, name, flags);
- if (newsect == NULL)
- return FALSE;
-
- newsect->vma = 0; /* NLM's are relocatable. */
- newsect->size = size;
- newsect->filepos = offset;
- newsect->alignment_power = bfd_log2 ((bfd_vma) 0); /* FIXME */
-
- 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 bfd_boolean
-nlm_swap_auxiliary_headers_in (bfd *abfd)
-{
- char tempstr[16];
- file_ptr position;
- bfd_size_type amt;
-
- for (;;)
- {
- position = bfd_tell (abfd);
- amt = sizeof (tempstr);
- if (bfd_bread ((void *) tempstr, amt, abfd) != amt)
- return FALSE;
- if (bfd_seek (abfd, position, SEEK_SET) != 0)
- return FALSE;
- if (CONST_STRNEQ (tempstr, "VeRsIoN#"))
- {
- Nlm_External_Version_Header thdr;
-
- amt = sizeof (thdr);
- if (bfd_bread ((void *) &thdr, amt, abfd) != amt)
- 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 (CONST_STRNEQ (tempstr, "MeSsAgEs"))
- {
- Nlm_External_Extended_Header thdr;
-
- amt = sizeof (thdr);
- if (bfd_bread ((void *) &thdr, amt, abfd) != amt)
- 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)->sharedDebugRecordOffset =
- get_word (abfd, (bfd_byte *) thdr.sharedDebugRecordOffset);
- nlm_extended_header (abfd)->sharedDebugRecordCount =
- get_word (abfd, (bfd_byte *) thdr.sharedDebugRecordCount);
- 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 (CONST_STRNEQ (tempstr, "CoPyRiGhT="))
- {
- amt = sizeof (nlm_copyright_header (abfd)->stamp);
- if (bfd_bread ((void *) nlm_copyright_header (abfd)->stamp,
- amt, abfd) != amt)
- return FALSE;
- if (bfd_bread ((void *) &(nlm_copyright_header (abfd)
- ->copyrightMessageLength),
- (bfd_size_type) 1, abfd) != 1)
- return FALSE;
- /* The copyright message is a variable length string. */
- amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1;
- if (bfd_bread ((void *) nlm_copyright_header (abfd)->copyrightMessage,
- amt, abfd) != amt)
- return FALSE;
- }
- else if (CONST_STRNEQ (tempstr, "CuStHeAd"))
- {
- Nlm_External_Custom_Header thdr;
- bfd_size_type hdrLength;
- file_ptr dataOffset;
- bfd_size_type dataLength;
- char dataStamp[8];
- void * hdr;
-
- /* Read the stamp ("CuStHeAd"). */
- amt = sizeof (thdr.stamp);
- if (bfd_bread ((void *) thdr.stamp, amt, abfd) != amt)
- return FALSE;
- /* Read the length of this custom header. */
- amt = sizeof (thdr.length);
- if (bfd_bread ((void *) thdr.length, amt, abfd) != amt)
- return FALSE;
- hdrLength = get_word (abfd, (bfd_byte *) thdr.length);
- /* Read further fields if we have them. */
- if (hdrLength < NLM_TARGET_LONG_SIZE)
- dataOffset = 0;
- else
- {
- amt = sizeof (thdr.dataOffset);
- if (bfd_bread ((void *) thdr.dataOffset, amt, abfd) != amt)
- return FALSE;
- dataOffset = get_word (abfd, (bfd_byte *) thdr.dataOffset);
- }
- if (hdrLength < 2 * NLM_TARGET_LONG_SIZE)
- dataLength = 0;
- else
- {
- amt = sizeof (thdr.dataLength);
- if (bfd_bread ((void *) thdr.dataLength, amt, abfd) != amt)
- return FALSE;
- dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength);
- }
- if (hdrLength < 2 * NLM_TARGET_LONG_SIZE + 8)
- memset (dataStamp, 0, sizeof (dataStamp));
- else
- {
- amt = sizeof (dataStamp);
- if (bfd_bread ((void *) dataStamp, amt, abfd) != amt)
- return FALSE;
- }
-
- /* Read the rest of the header, if any. */
- if (hdrLength <= 2 * NLM_TARGET_LONG_SIZE + 8)
- {
- hdr = NULL;
- hdrLength = 0;
- }
- else
- {
- hdrLength -= 2 * NLM_TARGET_LONG_SIZE + 8;
- hdr = bfd_alloc (abfd, hdrLength);
- if (hdr == NULL)
- return FALSE;
- if (bfd_bread (hdr, hdrLength, abfd) != hdrLength)
- return FALSE;
- }
-
- /* If we have found a Cygnus header, process it. Otherwise,
- just save the associated data without trying to interpret
- it. */
- if (CONST_STRNEQ (dataStamp, "CyGnUsEx"))
- {
- file_ptr pos;
- bfd_byte *contents;
- bfd_byte *p, *pend;
-
- /* See PR 21840 for a reproducer. */
- if (hdrLength != 0 || hdr != NULL)
- return FALSE;
-
- pos = bfd_tell (abfd);
- if (bfd_seek (abfd, dataOffset, SEEK_SET) != 0)
- return FALSE;
- contents = bfd_alloc (abfd, dataLength);
- if (contents == NULL)
- return FALSE;
- if (bfd_bread (contents, dataLength, abfd) != dataLength)
- return FALSE;
- if (bfd_seek (abfd, pos, SEEK_SET) != 0)
- return FALSE;
-
- LITMEMCPY (nlm_cygnus_ext_header (abfd), "CyGnUsEx");
- nlm_cygnus_ext_header (abfd)->offset = dataOffset;
- nlm_cygnus_ext_header (abfd)->length = dataLength;
-
- /* This data this header points to provides a list of
- the sections which were in the original object file
- which was converted to become an NLM. We locate
- those sections and add them to the BFD. Note that
- this is likely to create a second .text, .data and
- .bss section; retrieving the sections by name will
- get the actual NLM sections, which is what we want to
- happen. The sections from the original file, which
- may be subsets of the NLM section, can only be found
- using bfd_map_over_sections. */
- p = contents;
- pend = p + dataLength;
- while (p < pend)
- {
- char *name;
- size_t l;
- file_ptr filepos;
- bfd_size_type size;
- asection *newsec;
-
- /* The format of this information is
- null terminated section name
- zeroes to adjust to 4 byte boundary
- 4 byte section data file pointer
- 4 byte section size. */
-
- name = (char *) p;
- l = strlen (name) + 1;
- l = (l + 3) &~ (size_t) 3;
- p += l;
- filepos = H_GET_32 (abfd, p);
- p += 4;
- size = H_GET_32 (abfd, p);
- p += 4;
-
- newsec = bfd_make_section_anyway (abfd, name);
- if (newsec == NULL)
- return FALSE;
- newsec->size = size;
- if (filepos != 0)
- {
- newsec->filepos = filepos;
- newsec->flags |= SEC_HAS_CONTENTS;
- }
- }
- }
- else
- {
- memcpy (nlm_custom_header (abfd)->stamp, thdr.stamp,
- sizeof (thdr.stamp));
- nlm_custom_header (abfd)->hdrLength = hdrLength;
- nlm_custom_header (abfd)->dataOffset = dataOffset;
- nlm_custom_header (abfd)->dataLength = dataLength;
- memcpy (nlm_custom_header (abfd)->dataStamp, dataStamp,
- sizeof (dataStamp));
- nlm_custom_header (abfd)->hdr = hdr;
- }
- }
- else
- break;
- }
- return TRUE;
-}
-
-const bfd_target *
-nlm_object_p (bfd *abfd)
-{
- struct nlm_obj_tdata *preserved_tdata = nlm_tdata (abfd);
- bfd_boolean (*backend_object_p) (bfd *);
- void * x_fxdhdr = NULL;
- Nlm_Internal_Fixed_Header *i_fxdhdrp;
- struct nlm_obj_tdata *new_tdata = NULL;
- const char *signature;
- enum bfd_architecture arch;
- bfd_size_type amt;
-
- /* Some NLM formats have a prefix before the standard NLM fixed
- header. */
- backend_object_p = nlm_backend_object_p_func (abfd);
- if (backend_object_p)
- {
- if (!(*backend_object_p) (abfd))
- goto got_wrong_format_error;
- }
-
- /* Read in the fixed length portion of the NLM header in external format. */
- amt = nlm_fixed_header_size (abfd);
- x_fxdhdr = bfd_malloc (amt);
- if (x_fxdhdr == NULL)
- goto got_no_match;
-
- if (bfd_bread ((void *) x_fxdhdr, amt, abfd) != amt)
- {
- if (bfd_get_error () != bfd_error_system_call)
- goto got_wrong_format_error;
- else
- goto got_no_match;
- }
-
- /* Allocate an instance of the nlm_obj_tdata structure and hook it up to
- the tdata pointer in the bfd. */
- amt = sizeof (struct nlm_obj_tdata);
- new_tdata = bfd_zalloc (abfd, amt);
- if (new_tdata == NULL)
- goto got_no_match;
-
- nlm_tdata (abfd) = new_tdata;
-
- i_fxdhdrp = nlm_fixed_header (abfd);
- nlm_swap_fixed_header_in (abfd, x_fxdhdr, i_fxdhdrp);
- free (x_fxdhdr);
- x_fxdhdr = NULL;
-
- /* Check to see if we have an NLM file for this backend by matching
- the NLM signature. */
- signature = nlm_signature (abfd);
- if (signature != NULL
- && *signature != '\0'
- && strncmp ((char *) i_fxdhdrp->signature, signature,
- NLM_SIGNATURE_SIZE) != 0)
- goto got_wrong_format_error;
-
- /* There's no supported way to discover the endianness of an NLM, so test for
- a sane version number after doing byte swapping appropriate for this
- XVEC. (Hack alert!) */
- if (i_fxdhdrp->version > 0xFFFF)
- goto got_wrong_format_error;
-
- /* There's no supported way to check for 32 bit versus 64 bit addresses,
- so ignore this distinction for now. (FIXME) */
- /* Swap in the rest of the required header. */
- if (!nlm_swap_variable_header_in (abfd))
- {
- if (bfd_get_error () != bfd_error_system_call)
- goto got_wrong_format_error;
- else
- goto got_no_match;
- }
-
- /* Add the sections supplied by all NLM's, and then read in the
- auxiliary headers. Reading the auxiliary headers may create
- additional sections described in the cygnus_ext header.
- From this point on we assume that we have an NLM, and do not
- treat errors as indicating the wrong format. */
- if (!add_bfd_section (abfd, NLM_CODE_NAME,
- i_fxdhdrp->codeImageOffset,
- i_fxdhdrp->codeImageSize,
- (SEC_CODE | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_RELOC))
- || !add_bfd_section (abfd, NLM_INITIALIZED_DATA_NAME,
- i_fxdhdrp->dataImageOffset,
- i_fxdhdrp->dataImageSize,
- (SEC_DATA | SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_RELOC))
- || !add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME,
- (file_ptr) 0,
- i_fxdhdrp->uninitializedDataSize,
- SEC_ALLOC))
- goto got_no_match;
-
- if (!nlm_swap_auxiliary_headers_in (abfd))
- goto got_no_match;
-
- if (nlm_fixed_header (abfd)->numberOfRelocationFixups != 0
- || nlm_fixed_header (abfd)->numberOfExternalReferences != 0)
- abfd->flags |= HAS_RELOC;
- if (nlm_fixed_header (abfd)->numberOfPublics != 0
- || nlm_fixed_header (abfd)->numberOfDebugRecords != 0
- || nlm_fixed_header (abfd)->numberOfExternalReferences != 0)
- abfd->flags |= HAS_SYMS;
-
- arch = nlm_architecture (abfd);
- if (arch != bfd_arch_unknown)
- bfd_default_set_arch_mach (abfd, arch, (unsigned long) 0);
-
- abfd->flags |= EXEC_P;
- bfd_get_start_address (abfd) = nlm_fixed_header (abfd)->codeStartOffset;
-
- return abfd->xvec;
-
-got_wrong_format_error:
- bfd_set_error (bfd_error_wrong_format);
-got_no_match:
- nlm_tdata (abfd) = preserved_tdata;
- if (new_tdata != NULL)
- bfd_release (abfd, new_tdata);
- if (x_fxdhdr != NULL)
- free (x_fxdhdr);
-
- return NULL;
-}
-
-/* Swap and write out the variable length header. All the fields must
- exist in the NLM, and must exist in this order. */
-
-static bfd_boolean
-nlm_swap_variable_header_out (bfd *abfd)
-{
- bfd_byte temp[NLM_TARGET_LONG_SIZE];
- bfd_size_type amt;
-
- /* Write the description length and text members. */
- amt = sizeof (nlm_variable_header (abfd)->descriptionLength);
- if (bfd_bwrite (& nlm_variable_header (abfd)->descriptionLength, amt,
- abfd) != amt)
- return FALSE;
- amt = nlm_variable_header (abfd)->descriptionLength + 1;
- if (bfd_bwrite ((void *) nlm_variable_header (abfd)->descriptionText, amt,
- abfd) != amt)
- return FALSE;
-
- /* Convert and write the stackSize field. */
- put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize, temp);
- amt = sizeof (temp);
- if (bfd_bwrite (temp, amt, abfd) != amt)
- return FALSE;
-
- /* Convert and write the reserved field. */
- put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved, temp);
- amt = sizeof (temp);
- if (bfd_bwrite (temp, amt, abfd) != amt)
- return FALSE;
-
- /* Write the oldThreadName field. This field is a fixed length string. */
- amt = sizeof (nlm_variable_header (abfd)->oldThreadName);
- if (bfd_bwrite (nlm_variable_header (abfd)->oldThreadName, amt,
- abfd) != amt)
- return FALSE;
-
- /* Write the screen name length and text members. */
- amt = sizeof (nlm_variable_header (abfd)->screenNameLength);
- if (bfd_bwrite (& nlm_variable_header (abfd)->screenNameLength, amt,
- abfd) != amt)
- return FALSE;
- amt = nlm_variable_header (abfd)->screenNameLength + 1;
- if (bfd_bwrite (nlm_variable_header (abfd)->screenName, amt, abfd) != amt)
- return FALSE;
-
- /* Write the thread name length and text members. */
- amt = sizeof (nlm_variable_header (abfd)->threadNameLength);
- if (bfd_bwrite (& nlm_variable_header (abfd)->threadNameLength, amt,
- abfd) != amt)
- return FALSE;
- amt = nlm_variable_header (abfd)->threadNameLength + 1;
- if (bfd_bwrite (nlm_variable_header (abfd)->threadName, amt, abfd) != amt)
- return FALSE;
- return TRUE;
-}
-
-/* Return whether there is a non-zero byte in a memory block. */
-
-static bfd_boolean
-find_nonzero (void * buf, size_t size)
-{
- char *p = (char *) buf;
-
- while (size-- != 0)
- if (*p++ != 0)
- return TRUE;
- return FALSE;
-}
-
-/* Swap out the contents of the auxiliary headers. We create those
- auxiliary headers which have been set non-zero. We do not require
- the caller to set up the stamp fields. */
-
-static bfd_boolean
-nlm_swap_auxiliary_headers_out (bfd *abfd)
-{
- bfd_size_type amt;
-
- /* Write out the version header if there is one. */
- if (find_nonzero (nlm_version_header (abfd),
- sizeof (Nlm_Internal_Version_Header)))
- {
- Nlm_External_Version_Header thdr;
-
- LITMEMCPY (thdr.stamp, "VeRsIoN#");
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->majorVersion,
- (bfd_byte *) thdr.majorVersion);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->minorVersion,
- (bfd_byte *) thdr.minorVersion);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->revision,
- (bfd_byte *) thdr.revision);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->year,
- (bfd_byte *) thdr.year);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->month,
- (bfd_byte *) thdr.month);
- put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day,
- (bfd_byte *) thdr.day);
- if (bfd_bwrite ((void *) &thdr, (bfd_size_type) sizeof (thdr), abfd)
- != sizeof (thdr))
- return FALSE;
- }
-
- /* Note - the CoPyRiGhT tag is emitted before the MeSsAgEs
- tag in order to make the NW4.x and NW5.x loaders happy. */
-
- /* Write out the copyright header if there is one. */
- if (find_nonzero (nlm_copyright_header (abfd),
- sizeof (Nlm_Internal_Copyright_Header)))
- {
- Nlm_External_Copyright_Header thdr;
-
- LITMEMCPY (thdr.stamp, "CoPyRiGhT=");
- amt = sizeof (thdr.stamp);
- if (bfd_bwrite ((void *) thdr.stamp, amt, abfd) != amt)
- return FALSE;
- thdr.copyrightMessageLength[0] =
- nlm_copyright_header (abfd)->copyrightMessageLength;
- amt = 1;
- if (bfd_bwrite ((void *) thdr.copyrightMessageLength, amt, abfd) != amt)
- return FALSE;
- /* The copyright message is a variable length string. */
- amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1;
- if (bfd_bwrite ((void *) nlm_copyright_header (abfd)->copyrightMessage,
- amt, abfd) != amt)
- return FALSE;
- }
-
- /* Write out the extended header if there is one. */
- if (find_nonzero (nlm_extended_header (abfd),
- sizeof (Nlm_Internal_Extended_Header)))
- {
- Nlm_External_Extended_Header thdr;
-
- LITMEMCPY (thdr.stamp, "MeSsAgEs");
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->languageID,
- (bfd_byte *) thdr.languageID);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->messageFileOffset,
- (bfd_byte *) thdr.messageFileOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->messageFileLength,
- (bfd_byte *) thdr.messageFileLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->messageCount,
- (bfd_byte *) thdr.messageCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->helpFileOffset,
- (bfd_byte *) thdr.helpFileOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->helpFileLength,
- (bfd_byte *) thdr.helpFileLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->RPCDataOffset,
- (bfd_byte *) thdr.RPCDataOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->RPCDataLength,
- (bfd_byte *) thdr.RPCDataLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedCodeOffset,
- (bfd_byte *) thdr.sharedCodeOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedCodeLength,
- (bfd_byte *) thdr.sharedCodeLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDataOffset,
- (bfd_byte *) thdr.sharedDataOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDataLength,
- (bfd_byte *) thdr.sharedDataLength);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedRelocationFixupOffset,
- (bfd_byte *) thdr.sharedRelocationFixupOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedRelocationFixupCount,
- (bfd_byte *) thdr.sharedRelocationFixupCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedExternalReferenceOffset,
- (bfd_byte *) thdr.sharedExternalReferenceOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedExternalReferenceCount,
- (bfd_byte *) thdr.sharedExternalReferenceCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedPublicsOffset,
- (bfd_byte *) thdr.sharedPublicsOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedPublicsCount,
- (bfd_byte *) thdr.sharedPublicsCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDebugRecordOffset,
- (bfd_byte *) thdr.sharedDebugRecordOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->sharedDebugRecordCount,
- (bfd_byte *) thdr.sharedDebugRecordCount);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->SharedInitializationOffset,
- (bfd_byte *) thdr.sharedInitializationOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->SharedExitProcedureOffset,
- (bfd_byte *) thdr.SharedExitProcedureOffset);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->productID,
- (bfd_byte *) thdr.productID);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved0,
- (bfd_byte *) thdr.reserved0);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved1,
- (bfd_byte *) thdr.reserved1);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved2,
- (bfd_byte *) thdr.reserved2);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved3,
- (bfd_byte *) thdr.reserved3);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved4,
- (bfd_byte *) thdr.reserved4);
- put_word (abfd,
- (bfd_vma) nlm_extended_header (abfd)->reserved5,
- (bfd_byte *) thdr.reserved5);
- if (bfd_bwrite ((void *) &thdr, (bfd_size_type) sizeof (thdr), abfd)
- != sizeof (thdr))
- return FALSE;
- }
-
- /* Write out the custom header if there is one. */
- if (find_nonzero (nlm_custom_header (abfd),
- sizeof (Nlm_Internal_Custom_Header)))
- {
- Nlm_External_Custom_Header thdr;
- bfd_boolean ds;
- bfd_size_type hdrLength;
-
- ds = find_nonzero (nlm_custom_header (abfd)->dataStamp,
- sizeof (nlm_custom_header (abfd)->dataStamp));
- LITMEMCPY (thdr.stamp, "CuStHeAd");
- hdrLength = (2 * NLM_TARGET_LONG_SIZE + (ds ? 8 : 0)
- + nlm_custom_header (abfd)->hdrLength);
- put_word (abfd, hdrLength, thdr.length);
- put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->dataOffset,
- thdr.dataOffset);
- put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->dataLength,
- thdr.dataLength);
- if (! ds)
- {
- BFD_ASSERT (nlm_custom_header (abfd)->hdrLength == 0);
- amt = sizeof (thdr) - sizeof (thdr.dataStamp);
- if (bfd_bwrite ((void *) &thdr, amt, abfd) != amt)
- return FALSE;
- }
- else
- {
- memcpy (thdr.dataStamp, nlm_custom_header (abfd)->dataStamp,
- sizeof (thdr.dataStamp));
- amt = sizeof (thdr);
- if (bfd_bwrite ((void *) &thdr, amt, abfd) != amt)
- return FALSE;
- amt = nlm_custom_header (abfd)->hdrLength;
- if (bfd_bwrite (nlm_custom_header (abfd)->hdr, amt, abfd) != amt)
- return FALSE;
- }
- }
-
- /* Write out the Cygnus debugging header if there is one. */
- if (find_nonzero (nlm_cygnus_ext_header (abfd),
- sizeof (Nlm_Internal_Cygnus_Ext_Header)))
- {
- Nlm_External_Custom_Header thdr;
-
- LITMEMCPY (thdr.stamp, "CuStHeAd");
- put_word (abfd, (bfd_vma) 2 * NLM_TARGET_LONG_SIZE + 8,
- (bfd_byte *) thdr.length);
- put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->offset,
- (bfd_byte *) thdr.dataOffset);
- put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->length,
- (bfd_byte *) thdr.dataLength);
- LITMEMCPY (thdr.dataStamp, "CyGnUsEx");
- amt = sizeof (thdr);
- if (bfd_bwrite ((void *) &thdr, amt, abfd) != amt)
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* 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. */
-
-long
-nlm_get_symtab_upper_bound (bfd *abfd)
-{
- Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form. */
- long symcount;
- long symtab_size = 0;
-
- i_fxdhdrp = nlm_fixed_header (abfd);
- symcount = (i_fxdhdrp->numberOfPublics
- + i_fxdhdrp->numberOfDebugRecords
- + i_fxdhdrp->numberOfExternalReferences);
- symtab_size = (symcount + 1) * (sizeof (asymbol));
- return symtab_size;
-}
-
-/* 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
-
- We also read in the debugging symbols and import records. Import
- records are treated as undefined symbols. As we read the import
- records we also read in the associated reloc information, which is
- attached to the symbol.
-
- The bfd symbols are copied to SYMvoid *S.
-
- When we return, the bfd symcount is either zero or contains the correct
- number of symbols. */
-
-static bfd_boolean
-nlm_slurp_symbol_table (bfd *abfd)
-{
- Nlm_Internal_Fixed_Header *i_fxdhdrp; /* Nlm file header, internal form. */
- bfd_size_type totsymcount; /* Number of NLM symbols. */
- bfd_size_type symcount; /* Counter of NLM symbols. */
- nlm_symbol_type *sym; /* Pointer to current bfd symbol. */
- unsigned char symlength; /* Symbol length read into here. */
- unsigned char symtype; /* Type of debugging symbol. */
- bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Symbol offsets read into here. */
- bfd_boolean (*read_import_func) (bfd *, nlm_symbol_type *);
- bfd_boolean (*set_public_section_func) (bfd *, nlm_symbol_type *);
- bfd_size_type amt;
-
- if (nlm_get_symbols (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);
- totsymcount = (i_fxdhdrp->numberOfPublics
- + i_fxdhdrp->numberOfDebugRecords
- + i_fxdhdrp->numberOfExternalReferences);
- if (totsymcount == 0)
- return TRUE;
-
- if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) != 0)
- return FALSE;
-
- amt = totsymcount * sizeof (nlm_symbol_type);
- sym = bfd_zalloc (abfd, amt);
- if (!sym)
- return FALSE;
- nlm_set_symbols (abfd, sym);
-
- /* 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. */
-
- set_public_section_func = nlm_set_public_section_func (abfd);
- symcount = i_fxdhdrp->numberOfPublics;
- while (abfd->symcount < symcount)
- {
- amt = sizeof (symlength);
- if (bfd_bread ((void *) &symlength, amt, abfd) != amt)
- return FALSE;
- amt = symlength;
- sym->symbol.the_bfd = abfd;
- sym->symbol.name = bfd_alloc (abfd, amt + 1);
- if (!sym->symbol.name)
- return FALSE;
- if (bfd_bread ((void *) sym->symbol.name, amt, abfd) != amt)
- return FALSE;
- /* Cast away const. */
- ((char *) (sym->symbol.name))[symlength] = '\0';
- amt = sizeof (temp);
- if (bfd_bread ((void *) temp, amt, abfd) != amt)
- return FALSE;
- sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
- sym->symbol.value = get_word (abfd, temp);
- if (set_public_section_func)
- {
- /* Most backends can use the code below, but unfortunately
- some use a different scheme. */
- if (! (*set_public_section_func) (abfd, sym))
- return FALSE;
- }
- else
- {
- if (sym->symbol.value & NLM_HIBIT)
- {
- sym->symbol.value &= ~NLM_HIBIT;
- 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);
- }
- sym->rcnt = 0;
- abfd->symcount++;
- sym++;
- }
-
- /* Read the debugging records. */
-
- if (i_fxdhdrp->numberOfDebugRecords > 0)
- {
- if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) != 0)
- return FALSE;
-
- symcount += i_fxdhdrp->numberOfDebugRecords;
- while (abfd->symcount < symcount)
- {
- amt = sizeof (symtype);
- if (bfd_bread ((void *) &symtype, amt, abfd) != amt)
- return FALSE;
- amt = sizeof (temp);
- if (bfd_bread ((void *) temp, amt, abfd) != amt)
- return FALSE;
- amt = sizeof (symlength);
- if (bfd_bread ((void *) &symlength, amt, abfd) != amt)
- return FALSE;
- amt = symlength;
- sym->symbol.the_bfd = abfd;
- sym->symbol.name = bfd_alloc (abfd, amt + 1);
- if (!sym->symbol.name)
- return FALSE;
- if (bfd_bread ((void *) sym->symbol.name, amt, abfd) != amt)
- return FALSE;
- /* Cast away const. */
- ((char *) (sym->symbol.name))[symlength] = '\0';
- sym->symbol.flags = BSF_LOCAL;
- sym->symbol.value = get_word (abfd, temp);
-
- if (symtype == 0)
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
- else if (symtype == 1)
- {
- sym->symbol.flags |= BSF_FUNCTION;
- sym->symbol.section =
- bfd_get_section_by_name (abfd, NLM_CODE_NAME);
- }
- else
- sym->symbol.section = bfd_abs_section_ptr;
-
- sym->rcnt = 0;
- abfd->symcount++;
- sym++;
- }
- }
-
- /* Read in the import records. We can only do this if we know how
- to read relocs for this target. */
- read_import_func = nlm_read_import_func (abfd);
- if (read_import_func != NULL)
- {
- if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) != 0)
- return FALSE;
-
- symcount += i_fxdhdrp->numberOfExternalReferences;
- while (abfd->symcount < symcount)
- {
- if (! (*read_import_func) (abfd, sym))
- return FALSE;
- sym++;
- abfd->symcount++;
- }
- }
-
- return TRUE;
-}
-
-/* Note that bfd_get_symcount is guaranteed to be zero if slurping the
- symbol table fails. */
-
-long
-nlm_canonicalize_symtab (bfd *abfd, asymbol **alocation)
-{
- nlm_symbol_type *symbase;
- bfd_size_type counter = 0;
-
- if (! nlm_slurp_symbol_table (abfd))
- return -1;
- symbase = nlm_get_symbols (abfd);
- while (counter < bfd_get_symcount (abfd))
- {
- *alocation++ = &symbase->symbol;
- symbase++;
- counter++;
- }
- *alocation = NULL;
- return bfd_get_symcount (abfd);
-}
-
-/* Make an NLM symbol. There is nothing special to do here. */
-
-asymbol *
-nlm_make_empty_symbol (bfd *abfd)
-{
- bfd_size_type amt = sizeof (nlm_symbol_type);
- nlm_symbol_type *new = bfd_zalloc (abfd, amt);
-
- if (new == NULL)
- return NULL;
- new->symbol.the_bfd = abfd;
- return & new->symbol;
-}
-
-/* Get symbol information. */
-
-void
-nlm_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
- asymbol *symbol,
- symbol_info *ret)
-{
- bfd_symbol_info (symbol, ret);
-}
-
-/* Print symbol information. */
-
-void
-nlm_print_symbol (bfd *abfd,
- void * afile,
- asymbol *symbol,
- bfd_print_symbol_type how)
-{
- FILE *file = (FILE *) afile;
-
- switch (how)
- {
- case bfd_print_symbol_name:
- case bfd_print_symbol_more:
- if (symbol->name)
- fprintf (file, "%s", symbol->name);
- break;
- case bfd_print_symbol_all:
- bfd_print_symbol_vandf (abfd, (void *) file, symbol);
- fprintf (file, " %-5s", symbol->section->name);
- if (symbol->name)
- fprintf (file, " %s", symbol->name);
- break;
- }
-}
-
-/* Get the relocs for an NLM file. There are two types of relocs.
- Imports are relocs against symbols defined in other NLM files. We
- treat these as relocs against global symbols. Relocation fixups
- are internal relocs.
-
- The actual format used to store the relocs is machine specific. */
-
-/* Read in the relocation fixup information. This is stored in
- nlm_relocation_fixups, an array of arelent structures, and
- nlm_relocation_fixup_secs, an array of section pointers. The
- section pointers are needed because the relocs are not sorted by
- section. */
-
-static bfd_boolean
-nlm_slurp_reloc_fixups (bfd *abfd)
-{
- bfd_boolean (*read_func) (bfd *, nlm_symbol_type *, asection **, arelent *);
- bfd_size_type count, amt;
- arelent *rels;
- asection **secs;
-
- if (nlm_relocation_fixups (abfd) != NULL)
- return TRUE;
- read_func = nlm_read_reloc_func (abfd);
- if (read_func == NULL)
- return TRUE;
-
- if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
- SEEK_SET) != 0)
- return FALSE;
-
- count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
- amt = count * sizeof (arelent);
- rels = bfd_alloc (abfd, amt);
- amt = count * sizeof (asection *);
- secs = bfd_alloc (abfd, amt);
- if ((rels == NULL || secs == NULL) && count != 0)
- return FALSE;
- nlm_relocation_fixups (abfd) = rels;
- nlm_relocation_fixup_secs (abfd) = secs;
-
- /* We have to read piece by piece, because we don't know how large
- the machine specific reloc information is. */
- while (count-- != 0)
- {
- if (! (*read_func) (abfd, NULL, secs, rels))
- {
- nlm_relocation_fixups (abfd) = NULL;
- nlm_relocation_fixup_secs (abfd) = NULL;
- return FALSE;
- }
- ++secs;
- ++rels;
- }
-
- return TRUE;
-}
-
-/* Get the number of relocs. This really just returns an upper bound,
- since it does not attempt to distinguish them based on the section.
- That will be handled when they are actually read. */
-
-long
-nlm_get_reloc_upper_bound (bfd *abfd, asection *sec)
-{
- nlm_symbol_type *syms;
- bfd_size_type count;
- unsigned int ret;
-
- /* If we don't know how to read relocs, just return 0. */
- if (nlm_read_reloc_func (abfd) == NULL)
- return -1;
- /* Make sure we have either the code or the data section. */
- if ((bfd_get_section_flags (abfd, sec) & (SEC_CODE | SEC_DATA)) == 0)
- return 0;
-
- syms = nlm_get_symbols (abfd);
- if (syms == NULL)
- {
- if (! nlm_slurp_symbol_table (abfd))
- return -1;
- syms = nlm_get_symbols (abfd);
- }
-
- ret = nlm_fixed_header (abfd)->numberOfRelocationFixups;
-
- count = bfd_get_symcount (abfd);
- while (count-- != 0)
- {
- ret += syms->rcnt;
- ++syms;
- }
-
- return (ret + 1) * sizeof (arelent *);
-}
-
-/* Get the relocs themselves. */
-
-long
-nlm_canonicalize_reloc (bfd *abfd,
- asection *sec,
- arelent **relptr,
- asymbol **symbols)
-{
- arelent *rels;
- asection **secs;
- bfd_size_type count, i;
- long ret;
-
- /* Get the relocation fixups. */
- rels = nlm_relocation_fixups (abfd);
- if (rels == NULL)
- {
- if (! nlm_slurp_reloc_fixups (abfd))
- return -1;
- rels = nlm_relocation_fixups (abfd);
- }
- secs = nlm_relocation_fixup_secs (abfd);
-
- ret = 0;
- count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
- for (i = 0; i < count; i++, rels++, secs++)
- {
- if (*secs == sec)
- {
- *relptr++ = rels;
- ++ret;
- }
- }
-
- /* Get the import symbols. */
- count = bfd_get_symcount (abfd);
- for (i = 0; i < count; i++, symbols++)
- {
- asymbol *sym;
-
- sym = *symbols;
- if (bfd_asymbol_flavour (sym) == bfd_target_nlm_flavour)
- {
- nlm_symbol_type *nlm_sym;
- bfd_size_type j;
-
- nlm_sym = (nlm_symbol_type *) sym;
- for (j = 0; j < nlm_sym->rcnt; j++)
- {
- if (nlm_sym->relocs[j].section == sec)
- {
- *relptr = &nlm_sym->relocs[j].reloc;
- (*relptr)->sym_ptr_ptr = symbols;
- ++relptr;
- ++ret;
- }
- }
- }
- }
-
- *relptr = NULL;
-
- return ret;
-}
-
-/* Compute the section file positions for an NLM file. All variable
- length data in the file headers must be set before this function is
- called. If the variable length data is changed later, the
- resulting object file will be incorrect. Unfortunately, there is
- no way to check this.
-
- This routine also sets the Size and Offset fields in the fixed
- header.
-
- It also looks over the symbols and moves any common symbols into
- the .bss section; NLM has no way to represent a common symbol.
- This approach means that either the symbols must already have been
- set at this point, or there must be no common symbols. We need to
- move the symbols at this point so that mangle_relocs can see the
- final values. */
-
-static bfd_boolean
-nlm_compute_section_file_positions (bfd *abfd)
-{
- file_ptr sofar;
- asection *sec;
- bfd_vma text, data, bss;
- bfd_vma text_low, data_low;
- unsigned int text_align, data_align, other_align;
- file_ptr text_ptr, data_ptr, other_ptr;
- asection *bss_sec;
- asymbol **sym_ptr_ptr;
-
- if (abfd->output_has_begun)
- return TRUE;
-
- /* Make sure we have a section to hold uninitialized data. */
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
- if (bss_sec == NULL)
- {
- if (!add_bfd_section (abfd, NLM_UNINITIALIZED_DATA_NAME,
- (file_ptr) 0, (bfd_size_type) 0,
- SEC_ALLOC))
- return FALSE;
- bss_sec = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
- }
-
- abfd->output_has_begun = TRUE;
-
- /* The fixed header. */
- sofar = nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd);
-
- /* The variable header. */
- sofar += (sizeof (nlm_variable_header (abfd)->descriptionLength)
- + nlm_variable_header (abfd)->descriptionLength + 1
- + NLM_TARGET_LONG_SIZE /* stackSize */
- + NLM_TARGET_LONG_SIZE /* reserved */
- + sizeof (nlm_variable_header (abfd)->oldThreadName)
- + sizeof (nlm_variable_header (abfd)->screenNameLength)
- + nlm_variable_header (abfd)->screenNameLength + 1
- + sizeof (nlm_variable_header (abfd)->threadNameLength)
- + nlm_variable_header (abfd)->threadNameLength + 1);
-
- /* The auxiliary headers. */
- if (find_nonzero (nlm_version_header (abfd),
- sizeof (Nlm_Internal_Version_Header)))
- sofar += sizeof (Nlm_External_Version_Header);
- if (find_nonzero (nlm_extended_header (abfd),
- sizeof (Nlm_Internal_Extended_Header)))
- sofar += sizeof (Nlm_External_Extended_Header);
- if (find_nonzero (nlm_copyright_header (abfd),
- sizeof (Nlm_Internal_Copyright_Header)))
- sofar += (sizeof (Nlm_External_Copyright_Header)
- + nlm_copyright_header (abfd)->copyrightMessageLength + 1);
- if (find_nonzero (nlm_custom_header (abfd),
- sizeof (Nlm_Internal_Custom_Header)))
- sofar += (sizeof (Nlm_External_Custom_Header)
- + nlm_custom_header (abfd)->hdrLength);
- if (find_nonzero (nlm_cygnus_ext_header (abfd),
- sizeof (Nlm_Internal_Cygnus_Ext_Header)))
- sofar += sizeof (Nlm_External_Custom_Header);
-
- /* Compute the section file positions in two passes. First get the
- sizes of the text and data sections, and then set the file
- positions. This code aligns the sections in the file using the
- same alignment restrictions that apply to the sections in memory;
- this may not be necessary. */
- text = 0;
- text_low = (bfd_vma) - 1;
- text_align = 0;
- data = 0;
- data_low = (bfd_vma) - 1;
- data_align = 0;
- bss = 0;
- other_align = 0;
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- {
- flagword f;
-
- sec->size = BFD_ALIGN (sec->size, 1 << sec->alignment_power);
-
- f = bfd_get_section_flags (abfd, sec);
- if (f & SEC_CODE)
- {
- text += sec->size;
- if (bfd_get_section_vma (abfd, sec) < text_low)
- text_low = bfd_get_section_vma (abfd, sec);
- if (sec->alignment_power > text_align)
- text_align = sec->alignment_power;
- }
- else if (f & SEC_DATA)
- {
- data += sec->size;
- if (bfd_get_section_vma (abfd, sec) < data_low)
- data_low = bfd_get_section_vma (abfd, sec);
- if (sec->alignment_power > data_align)
- data_align = sec->alignment_power;
- }
- else if (f & SEC_HAS_CONTENTS)
- {
- if (sec->alignment_power > other_align)
- other_align = sec->alignment_power;
- }
- else if (f & SEC_ALLOC)
- bss += sec->size;
- }
-
- nlm_set_text_low (abfd, text_low);
- nlm_set_data_low (abfd, data_low);
-
- if (nlm_no_uninitialized_data (abfd))
- {
- /* This NetWare format does not use uninitialized data. We must
- increase the size of the data section. We will never wind up
- writing those file locations, so they will remain zero. */
- data += bss;
- bss = 0;
- }
-
- text_ptr = BFD_ALIGN (sofar, 1 << text_align);
- data_ptr = BFD_ALIGN (text_ptr + text, 1 << data_align);
- other_ptr = BFD_ALIGN (data_ptr + data, 1 << other_align);
-
- /* Fill in some fields in the header for which we now have the
- information. */
- nlm_fixed_header (abfd)->codeImageOffset = text_ptr;
- nlm_fixed_header (abfd)->codeImageSize = text;
- nlm_fixed_header (abfd)->dataImageOffset = data_ptr;
- nlm_fixed_header (abfd)->dataImageSize = data;
- nlm_fixed_header (abfd)->uninitializedDataSize = bss;
-
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- {
- flagword f;
-
- f = bfd_get_section_flags (abfd, sec);
-
- if (f & SEC_CODE)
- {
- sec->filepos = text_ptr;
- text_ptr += sec->size;
- }
- else if (f & SEC_DATA)
- {
- sec->filepos = data_ptr;
- data_ptr += sec->size;
- }
- else if (f & SEC_HAS_CONTENTS)
- {
- sec->filepos = other_ptr;
- other_ptr += sec->size;
- }
- }
-
- nlm_fixed_header (abfd)->relocationFixupOffset = other_ptr;
-
- /* Move all common symbols into the .bss section. */
-
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- if (sym_ptr_ptr != NULL)
- {
- asymbol **sym_end;
- bfd_vma add;
-
- sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
- add = 0;
- for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
- {
- asymbol *sym;
- bfd_vma size;
-
- sym = *sym_ptr_ptr;
-
- if (!bfd_is_com_section (bfd_get_section (sym)))
- continue;
-
- /* Put the common symbol in the .bss section, and increase
- the size of the .bss section by the size of the common
- symbol (which is the old value of the symbol). */
- sym->section = bss_sec;
- size = sym->value;
- sym->value = bss_sec->size + add;
- add += size;
- add = BFD_ALIGN (add, 1 << bss_sec->alignment_power);
- }
- if (add != 0)
- {
- if (nlm_no_uninitialized_data (abfd))
- {
- /* We could handle this case, but so far it hasn't been
- necessary. */
- abort ();
- }
- nlm_fixed_header (abfd)->uninitializedDataSize += add;
- bss_sec->size += add;
- }
- }
-
- return TRUE;
-}
-
-/* Set the contents of a section. To do this we need to know where
- the section is going to be located in the output file. That means
- that the sizes of all the sections must be set, and all the
- variable size header information must be known. */
-
-bfd_boolean
-nlm_set_section_contents (bfd *abfd,
- asection *section,
- const void * location,
- file_ptr offset,
- bfd_size_type count)
-{
- if (! abfd->output_has_begun
- && ! nlm_compute_section_file_positions (abfd))
- return FALSE;
-
- if (count == 0)
- return TRUE;
-
- /* i386 NetWare has a very restricted set of relocs. In order for
- objcopy to work, the NLM i386 backend needs a chance to rework
- the section contents so that its set of relocs will work. If all
- the relocs are already acceptable, this will not do anything. */
- if (section->reloc_count != 0)
- {
- bfd_boolean (*mangle_relocs_func)
- (bfd *, asection *, const void *, bfd_vma, bfd_size_type);
-
- mangle_relocs_func = nlm_mangle_relocs_func (abfd);
- if (mangle_relocs_func != NULL)
- {
- if (!(*mangle_relocs_func) (abfd, section, location,
- (bfd_vma) offset, count))
- return FALSE;
- }
- }
-
- if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
- || bfd_bwrite (location, count, abfd) != count)
- return FALSE;
-
- return TRUE;
-}
-
-/* We need to sort a list of relocs associated with sections when we
- write out the external relocs. */
-
-static int
-nlm_external_reloc_compare (const void *p1, const void *p2)
-{
- const struct reloc_and_sec *r1 = (const struct reloc_and_sec *) p1;
- const struct reloc_and_sec *r2 = (const struct reloc_and_sec *) p2;
- int cmp;
-
- cmp = strcmp ((*r1->rel->sym_ptr_ptr)->name,
- (*r2->rel->sym_ptr_ptr)->name);
- if (cmp != 0)
- return cmp;
-
- /* We sort by address within symbol to make the sort more stable and
- increase the chances that different hosts will generate bit for
- bit equivalent results. */
- return (int) (r1->rel->address - r2->rel->address);
-}
-
-/* Write out an NLM file. We write out the information in this order:
- fixed header
- variable header
- auxiliary headers
- code sections
- data sections
- other sections (custom data, messages, help, shared NLM, RPC,
- module dependencies)
- relocation fixups
- external references (imports)
- public symbols (exports)
- debugging records
- This is similar to the order used by the NetWare tools; the
- difference is that NetWare puts the sections other than code, data
- and custom data at the end of the NLM. It is convenient for us to
- know where the sections are going to be before worrying about the
- size of the other information.
-
- By the time this function is called, all the section data should
- have been output using set_section_contents. Note that custom
- data, the message file, the help file, the shared NLM file, the RPC
- data, and the module dependencies are all considered to be
- sections; the caller is responsible for filling in the offset and
- length fields in the NLM headers. The relocation fixups and
- imports are both obtained from the list of relocs attached to each
- section. The exports and debugging records are obtained from the
- list of outsymbols. */
-
-bfd_boolean
-nlm_write_object_contents (bfd *abfd)
-{
- asection *sec;
- bfd_boolean (*write_import_func) (bfd *, asection *, arelent *);
- bfd_size_type external_reloc_count, internal_reloc_count, i, c;
- struct reloc_and_sec *external_relocs;
- asymbol **sym_ptr_ptr;
- file_ptr last;
- bfd_boolean (*write_prefix_func) (bfd *);
- unsigned char *fixed_header = NULL;
- file_ptr pos;
- bfd_size_type amt;
-
- fixed_header = bfd_malloc (nlm_fixed_header_size (abfd));
- if (fixed_header == NULL)
- goto error_return;
-
- if (! abfd->output_has_begun
- && ! nlm_compute_section_file_positions (abfd))
- goto error_return;
-
- /* Write out the variable length headers. */
- pos = nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd);
- if (bfd_seek (abfd, pos, SEEK_SET) != 0)
- goto error_return;
- if (! nlm_swap_variable_header_out (abfd)
- || ! nlm_swap_auxiliary_headers_out (abfd))
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
-
- /* A weak check on whether the section file positions were
- reasonable. */
- if (bfd_tell (abfd) > nlm_fixed_header (abfd)->codeImageOffset)
- {
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
-
- /* Advance to the relocs. */
- if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
- SEEK_SET) != 0)
- goto error_return;
-
- /* The format of the relocation entries is dependent upon the
- particular target. We use an external routine to write the reloc
- out. */
- write_import_func = nlm_write_import_func (abfd);
-
- /* Write out the internal relocation fixups. While we're looping
- over the relocs, we also count the external relocs, which is
- needed when they are written out below. */
- internal_reloc_count = 0;
- external_reloc_count = 0;
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- {
- arelent **rel_ptr_ptr, **rel_end;
-
- if (sec->reloc_count == 0)
- continue;
-
- /* We can only represent relocs within a code or data
- section. We ignore them for a debugging section. */
- if ((bfd_get_section_flags (abfd, sec) & (SEC_CODE | SEC_DATA)) == 0)
- continue;
-
- /* We need to know how to write out imports */
- if (write_import_func == NULL)
- {
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
-
- rel_ptr_ptr = sec->orelocation;
- rel_end = rel_ptr_ptr + sec->reloc_count;
- for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
- {
- arelent *rel;
- asymbol *sym;
-
- rel = *rel_ptr_ptr;
- sym = *rel->sym_ptr_ptr;
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- {
- ++internal_reloc_count;
- if (! (*write_import_func) (abfd, sec, rel))
- goto error_return;
- }
- else
- ++external_reloc_count;
- }
- }
- nlm_fixed_header (abfd)->numberOfRelocationFixups = internal_reloc_count;
-
- /* Write out the imports (relocs against external symbols). These
- are output as a symbol name followed by all the relocs for that
- symbol, so we must first gather together all the relocs against
- external symbols and sort them. */
- amt = external_reloc_count * sizeof (struct reloc_and_sec);
- external_relocs = bfd_alloc (abfd, amt);
- if (external_relocs == NULL)
- goto error_return;
- i = 0;
- for (sec = abfd->sections; sec != NULL; sec = sec->next)
- {
- arelent **rel_ptr_ptr, **rel_end;
-
- if (sec->reloc_count == 0)
- continue;
-
- rel_ptr_ptr = sec->orelocation;
- rel_end = rel_ptr_ptr + sec->reloc_count;
- for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
- {
- arelent *rel;
- asymbol *sym;
-
- rel = *rel_ptr_ptr;
- sym = *rel->sym_ptr_ptr;
-
- if (! bfd_is_und_section (bfd_get_section (sym)))
- continue;
-
- external_relocs[i].rel = rel;
- external_relocs[i].sec = sec;
- ++i;
- }
- }
-
- BFD_ASSERT (i == external_reloc_count);
-
- /* Sort the external relocs by name. */
- qsort (external_relocs, (size_t) external_reloc_count,
- sizeof (struct reloc_and_sec), nlm_external_reloc_compare);
-
- /* Write out the external relocs. */
- nlm_fixed_header (abfd)->externalReferencesOffset = bfd_tell (abfd);
- c = 0;
- i = 0;
- while (i < external_reloc_count)
- {
- arelent *rel;
- asymbol *sym;
- bfd_size_type j, cnt;
-
- ++c;
-
- rel = external_relocs[i].rel;
- sym = *rel->sym_ptr_ptr;
-
- cnt = 0;
- for (j = i;
- (j < external_reloc_count
- && *external_relocs[j].rel->sym_ptr_ptr == sym);
- j++)
- ++cnt;
-
- if (! (*nlm_write_external_func (abfd)) (abfd, cnt, sym,
- &external_relocs[i]))
- goto error_return;
-
- i += cnt;
- }
-
- nlm_fixed_header (abfd)->numberOfExternalReferences = c;
-
- /* Write out the public symbols (exports). */
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- if (sym_ptr_ptr != NULL)
- {
- bfd_vma (*get_public_offset_func) (bfd *, asymbol *);
- bfd_boolean (*write_export_func) (bfd *, asymbol *, bfd_vma);
-
- asymbol **sym_end;
-
- nlm_fixed_header (abfd)->publicsOffset = bfd_tell (abfd);
- get_public_offset_func = nlm_get_public_offset_func (abfd);
- write_export_func = nlm_write_export_func (abfd);
- c = 0;
- sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
- for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
- {
- asymbol *sym;
- bfd_byte len;
- bfd_vma offset;
- bfd_byte temp[NLM_TARGET_LONG_SIZE];
-
- sym = *sym_ptr_ptr;
-
- if ((sym->flags & (BSF_EXPORT | BSF_GLOBAL)) == 0
- || bfd_is_und_section (bfd_get_section (sym)))
- continue;
-
- ++c;
-
- if (get_public_offset_func)
- {
- /* Most backends can use the code below, but
- unfortunately some use a different scheme. */
- offset = (*get_public_offset_func) (abfd, sym);
- }
- else
- {
- offset = bfd_asymbol_value (sym);
- sec = sym->section;
- if (sec->flags & SEC_CODE)
- {
- offset -= nlm_get_text_low (abfd);
- offset |= NLM_HIBIT;
- }
- else if (sec->flags & (SEC_DATA | SEC_ALLOC))
- {
- /* SEC_ALLOC is for the .bss section. */
- offset -= nlm_get_data_low (abfd);
- }
- else
- {
- /* We can't handle an exported symbol that is not in
- the code or data segment. */
- bfd_set_error (bfd_error_invalid_operation);
- goto error_return;
- }
- }
-
- if (write_export_func)
- {
- if (! (*write_export_func) (abfd, sym, offset))
- goto error_return;
- }
- else
- {
- len = strlen (sym->name);
- if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- goto error_return;
-
- put_word (abfd, offset, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd)
- != sizeof (temp))
- goto error_return;
- }
- }
- nlm_fixed_header (abfd)->numberOfPublics = c;
-
- /* Write out the debugging records. The NLM conversion program
- wants to be able to inhibit this, so as a special hack if
- debugInfoOffset is set to -1 we don't write any debugging
- information. This can not be handled by fiddling with the
- symbol table, because exported symbols appear in both the
- exported symbol list and the debugging information. */
- if (nlm_fixed_header (abfd)->debugInfoOffset == (file_ptr) - 1)
- {
- nlm_fixed_header (abfd)->debugInfoOffset = 0;
- nlm_fixed_header (abfd)->numberOfDebugRecords = 0;
- }
- else
- {
- nlm_fixed_header (abfd)->debugInfoOffset = bfd_tell (abfd);
- c = 0;
- sym_ptr_ptr = bfd_get_outsymbols (abfd);
- sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
- for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
- {
- asymbol *sym;
- bfd_byte type, len;
- bfd_vma offset;
- bfd_byte temp[NLM_TARGET_LONG_SIZE];
-
- sym = *sym_ptr_ptr;
-
- /* The NLM notion of a debugging symbol is actually what
- BFD calls a local or global symbol. What BFD calls a
- debugging symbol NLM does not understand at all. */
- if ((sym->flags & (BSF_LOCAL | BSF_GLOBAL | BSF_EXPORT)) == 0
- || (sym->flags & BSF_DEBUGGING) != 0
- || bfd_is_und_section (bfd_get_section (sym)))
- continue;
-
- ++c;
-
- offset = bfd_asymbol_value (sym);
- sec = sym->section;
- if (sec->flags & SEC_CODE)
- {
- offset -= nlm_get_text_low (abfd);
- type = 1;
- }
- else if (sec->flags & (SEC_DATA | SEC_ALLOC))
- {
- /* SEC_ALLOC is for the .bss section. */
- offset -= nlm_get_data_low (abfd);
- type = 0;
- }
- else
- type = 2;
-
- /* The type is 0 for data, 1 for code, 2 for absolute. */
- if (bfd_bwrite (&type, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- goto error_return;
-
- put_word (abfd, offset, temp);
- if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd)
- != sizeof (temp))
- goto error_return;
-
- len = strlen (sym->name);
- if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
- != sizeof (bfd_byte))
- || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
- goto error_return;
- }
- nlm_fixed_header (abfd)->numberOfDebugRecords = c;
- }
- }
-
- /* NLMLINK fills in offset values even if there is no data, so we do
- the same. */
- last = bfd_tell (abfd);
- if (nlm_fixed_header (abfd)->codeImageOffset == 0)
- nlm_fixed_header (abfd)->codeImageOffset = last;
- if (nlm_fixed_header (abfd)->dataImageOffset == 0)
- nlm_fixed_header (abfd)->dataImageOffset = last;
- if (nlm_fixed_header (abfd)->customDataOffset == 0)
- nlm_fixed_header (abfd)->customDataOffset = last;
- if (nlm_fixed_header (abfd)->moduleDependencyOffset == 0)
- nlm_fixed_header (abfd)->moduleDependencyOffset = last;
- if (nlm_fixed_header (abfd)->relocationFixupOffset == 0)
- nlm_fixed_header (abfd)->relocationFixupOffset = last;
- if (nlm_fixed_header (abfd)->externalReferencesOffset == 0)
- nlm_fixed_header (abfd)->externalReferencesOffset = last;
- if (nlm_fixed_header (abfd)->publicsOffset == 0)
- nlm_fixed_header (abfd)->publicsOffset = last;
- if (nlm_fixed_header (abfd)->debugInfoOffset == 0)
- nlm_fixed_header (abfd)->debugInfoOffset = last;
-
- /* At this point everything has been written out except the fixed
- header. */
- memcpy (nlm_fixed_header (abfd)->signature, nlm_signature (abfd),
- NLM_SIGNATURE_SIZE);
- nlm_fixed_header (abfd)->version = NLM_HEADER_VERSION;
- nlm_fixed_header (abfd)->codeStartOffset =
- (bfd_get_start_address (abfd)
- - nlm_get_text_low (abfd));
-
- /* We have no convenient way for the caller to pass in the exit
- procedure or the check unload procedure, so the caller must set
- the values in the header to the values of the symbols. */
- nlm_fixed_header (abfd)->exitProcedureOffset -= nlm_get_text_low (abfd);
- if (nlm_fixed_header (abfd)->checkUnloadProcedureOffset != 0)
- nlm_fixed_header (abfd)->checkUnloadProcedureOffset -=
- nlm_get_text_low (abfd);
-
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
- goto error_return;
-
- write_prefix_func = nlm_write_prefix_func (abfd);
- if (write_prefix_func)
- {
- if (! (*write_prefix_func) (abfd))
- goto error_return;
- }
-
- BFD_ASSERT ((bfd_size_type) bfd_tell (abfd)
- == nlm_optional_prefix_size (abfd));
-
- nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
- if (bfd_bwrite (fixed_header, nlm_fixed_header_size (abfd), abfd)
- != nlm_fixed_header_size (abfd))
- goto error_return;
-
- if (fixed_header != NULL)
- free (fixed_header);
- return TRUE;
-
-error_return:
- if (fixed_header != NULL)
- free (fixed_header);
- return FALSE;
-}
diff --git a/bfd/nlmswap.h b/bfd/nlmswap.h
deleted file mode 100644
index 3884d77..0000000
--- a/bfd/nlmswap.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* NLM (NetWare Loadable Module) swapping routines for BFD.
- Copyright (C) 1993-2018 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
- MA 02110-1301, USA. */
-
-
-/* Although this is a header file, it defines functions. It is
- included by NLM backends to define swapping functions that vary
- from one NLM to another. The backend code must arrange for
- Nlm_External_xxxx to be defined appropriately, and can then include
- this file to get the swapping routines.
-
- At the moment this is only needed for one structure, the fixed NLM
- file header. */
-
-/* Translate an NLM fixed length file header in external format into an NLM
- file header in internal format. */
-
-static void
-nlm_swap_fixed_header_in (bfd *abfd,
- void * realsrc,
- Nlm_Internal_Fixed_Header *dst)
-{
- Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
-
- memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
- memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
- dst->version =
- H_GET_32 (abfd, src->version);
- dst->codeImageOffset =
- H_GET_32 (abfd, src->codeImageOffset);
- dst->codeImageSize =
- H_GET_32 (abfd, src->codeImageSize);
- dst->dataImageOffset =
- H_GET_32 (abfd, src->dataImageOffset);
- dst->dataImageSize =
- H_GET_32 (abfd, src->dataImageSize);
- dst->uninitializedDataSize =
- H_GET_32 (abfd, src->uninitializedDataSize);
- dst->customDataOffset =
- H_GET_32 (abfd, src->customDataOffset);
- dst->customDataSize =
- H_GET_32 (abfd, src->customDataSize);
- dst->moduleDependencyOffset =
- H_GET_32 (abfd, src->moduleDependencyOffset);
- dst->numberOfModuleDependencies =
- H_GET_32 (abfd, src->numberOfModuleDependencies);
- dst->relocationFixupOffset =
- H_GET_32 (abfd, src->relocationFixupOffset);
- dst->numberOfRelocationFixups =
- H_GET_32 (abfd, src->numberOfRelocationFixups);
- dst->externalReferencesOffset =
- H_GET_32 (abfd, src->externalReferencesOffset);
- dst->numberOfExternalReferences =
- H_GET_32 (abfd, src->numberOfExternalReferences);
- dst->publicsOffset =
- H_GET_32 (abfd, src->publicsOffset);
- dst->numberOfPublics =
- H_GET_32 (abfd, src->numberOfPublics);
- dst->debugInfoOffset =
- H_GET_32 (abfd, src->debugInfoOffset);
- dst->numberOfDebugRecords =
- H_GET_32 (abfd, src->numberOfDebugRecords);
- dst->codeStartOffset =
- H_GET_32 (abfd, src->codeStartOffset);
- dst->exitProcedureOffset =
- H_GET_32 (abfd, src->exitProcedureOffset);
- dst->checkUnloadProcedureOffset =
- H_GET_32 (abfd, src->checkUnloadProcedureOffset);
- dst->moduleType =
- H_GET_32 (abfd, src->moduleType);
- dst->flags =
- H_GET_32 (abfd, src->flags);
-}
-
-/* Translate an NLM fixed length file header in internal format into
- an NLM file header in external format. */
-
-static void
-nlm_swap_fixed_header_out (bfd *abfd,
- Nlm_Internal_Fixed_Header *src,
- void * realdst)
-{
- Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
-
- memset (dst, 0, sizeof *dst);
- memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
- memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
- H_PUT_32 (abfd, src->version,
- dst->version);
- H_PUT_32 (abfd, src->codeImageOffset,
- dst->codeImageOffset);
- H_PUT_32 (abfd, src->codeImageSize,
- dst->codeImageSize);
- H_PUT_32 (abfd, src->dataImageOffset,
- dst->dataImageOffset);
- H_PUT_32 (abfd, src->dataImageSize,
- dst->dataImageSize);
- H_PUT_32 (abfd, src->uninitializedDataSize,
- dst->uninitializedDataSize);
- H_PUT_32 (abfd, src->customDataOffset,
- dst->customDataOffset);
- H_PUT_32 (abfd, src->customDataSize,
- dst->customDataSize);
- H_PUT_32 (abfd, src->moduleDependencyOffset,
- dst->moduleDependencyOffset);
- H_PUT_32 (abfd, src->numberOfModuleDependencies,
- dst->numberOfModuleDependencies);
- H_PUT_32 (abfd, src->relocationFixupOffset,
- dst->relocationFixupOffset);
- H_PUT_32 (abfd, src->numberOfRelocationFixups,
- dst->numberOfRelocationFixups);
- H_PUT_32 (abfd, src->externalReferencesOffset,
- dst->externalReferencesOffset);
- H_PUT_32 (abfd, src->numberOfExternalReferences,
- dst->numberOfExternalReferences);
- H_PUT_32 (abfd, src->publicsOffset,
- dst->publicsOffset);
- H_PUT_32 (abfd, src->numberOfPublics,
- dst->numberOfPublics);
- H_PUT_32 (abfd, src->debugInfoOffset,
- dst->debugInfoOffset);
- H_PUT_32 (abfd, src->numberOfDebugRecords,
- dst->numberOfDebugRecords);
- H_PUT_32 (abfd, src->codeStartOffset,
- dst->codeStartOffset);
- H_PUT_32 (abfd, src->exitProcedureOffset,
- dst->exitProcedureOffset);
- H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
- dst->checkUnloadProcedureOffset);
- H_PUT_32 (abfd, src->moduleType,
- dst->moduleType);
- H_PUT_32 (abfd, src->flags,
- dst->flags);
-}
diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in
index afa459e..7604f72 100644
--- a/bfd/po/SRC-POTFILES.in
+++ b/bfd/po/SRC-POTFILES.in
@@ -288,7 +288,6 @@ libcoff.h
libecoff.h
libhppa.h
libieee.h
-libnlm.h
liboasys.h
libpei.h
libxcoff.h
@@ -311,16 +310,6 @@ mmo.c
netbsd-core.c
netbsd.h
newsos3.c
-nlm-target.h
-nlm.c
-nlm32-alpha.c
-nlm32-i386.c
-nlm32-ppc.c
-nlm32-sparc.c
-nlm32.c
-nlm64.c
-nlmcode.h
-nlmswap.h
ns32k.h
ns32knetbsd.c
oasys.c
diff --git a/bfd/targets.c b/bfd/targets.c
index 34169c5..c5ebcd6 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -152,7 +152,6 @@ DESCRIPTION
. bfd_target_xcoff_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,
@@ -594,7 +593,6 @@ extern const bfd_target aarch64_mach_o_vec;
extern const bfd_target alpha_ecoff_le_vec;
extern const bfd_target alpha_elf64_vec;
extern const bfd_target alpha_elf64_fbsd_vec;
-extern const bfd_target alpha_nlm32_vec;
extern const bfd_target alpha_vms_vec;
extern const bfd_target alpha_vms_lib_txt_vec;
extern const bfd_target am33_elf32_linux_vec;
@@ -681,7 +679,6 @@ extern const bfd_target i386_elf32_sol2_vec;
extern const bfd_target i386_elf32_vxworks_vec;
extern const bfd_target i386_mach_o_vec;
extern const bfd_target i386_msdos_vec;
-extern const bfd_target i386_nlm32_vec;
extern const bfd_target i386_pe_vec;
extern const bfd_target i386_pei_vec;
extern const bfd_target iamcu_elf32_vec;
@@ -799,7 +796,6 @@ extern const bfd_target powerpc_elf32_vxworks_vec;
extern const bfd_target powerpc_elf64_vec;
extern const bfd_target powerpc_elf64_le_vec;
extern const bfd_target powerpc_elf64_fbsd_vec;
-extern const bfd_target powerpc_nlm32_vec;
extern const bfd_target powerpc_pe_vec;
extern const bfd_target powerpc_pe_le_vec;
extern const bfd_target powerpc_pei_vec;
@@ -861,7 +857,6 @@ extern const bfd_target sparc_elf32_vxworks_vec;
extern const bfd_target sparc_elf64_vec;
extern const bfd_target sparc_elf64_fbsd_vec;
extern const bfd_target sparc_elf64_sol2_vec;
-extern const bfd_target sparc_nlm32_vec;
extern const bfd_target spu_elf32_vec;
extern const bfd_target sym_vec;
extern const bfd_target tic30_aout_vec;
@@ -977,7 +972,6 @@ static const bfd_target * const _bfd_target_vector[] =
&alpha_ecoff_le_vec,
&alpha_elf64_vec,
&alpha_elf64_fbsd_vec,
- &alpha_nlm32_vec,
&alpha_vms_vec,
#endif
&alpha_vms_lib_txt_vec,
@@ -1111,7 +1105,6 @@ static const bfd_target * const _bfd_target_vector[] =
&i386_elf32_vxworks_vec,
&i386_mach_o_vec,
&i386_msdos_vec,
- &i386_nlm32_vec,
&i386_pe_vec,
&i386_pei_vec,
@@ -1291,7 +1284,6 @@ static const bfd_target * const _bfd_target_vector[] =
&powerpc_elf64_le_vec,
&powerpc_elf64_fbsd_vec,
#endif
- &powerpc_nlm32_vec,
&powerpc_pe_vec,
&powerpc_pe_le_vec,
&powerpc_pei_vec,
@@ -1376,7 +1368,6 @@ static const bfd_target * const _bfd_target_vector[] =
&sparc_elf64_fbsd_vec,
&sparc_elf64_sol2_vec,
#endif
- &sparc_nlm32_vec,
&spu_elf32_vec,
@@ -1872,7 +1863,6 @@ bfd_flavour_name (enum bfd_flavour flavour)
case bfd_target_xcoff_flavour: return "XCOFF";
case bfd_target_elf_flavour: return "ELF";
case bfd_target_ieee_flavour: return "IEEE";
- case bfd_target_nlm_flavour: return "NLM";
case bfd_target_oasys_flavour: return "Oasys";
case bfd_target_tekhex_flavour: return "Tekhex";
case bfd_target_srec_flavour: return "Srec";